mxcubecore.HardwareObjects.SampleView#

Functions

combine_images(img1, img2)

Classes

Grid(mpos_list, screen_coord)

Line(mpos_list, screen_coord)

Point(mpos_list, screen_coord)

SampleView(name)

SampleView class

Shape([mpos_list, screen_coord])

Base class for shapes.

TwoDPoint(mpos_list, screen_coord)

class mxcubecore.HardwareObjects.SampleView.Grid(mpos_list, screen_coord)[source]#

Bases: Shape

as_dict() dict[source]#

Convert a shape to a dictionary.

Return type:

dict

class mxcubecore.HardwareObjects.SampleView.Line(mpos_list, screen_coord)[source]#

Bases: Shape

class mxcubecore.HardwareObjects.SampleView.Point(mpos_list, screen_coord)[source]#

Bases: Shape

class mxcubecore.HardwareObjects.SampleView.SampleView(name)[source]#

Bases: AbstractSampleView

SampleView class

accept_centring()[source]#

Accept the current centred position.

add_shape(shape)[source]#

Add the shape <shape> to the dictionary of handled shapes.

Parameters:

shape – Shape to add.

add_shape_from_mpos(mpos_list: list[float], screen_coord: tuple[int, int], t: str, state: Literal['HIDDEN', 'SAVED', 'TMP'] = 'SAVED', user_state: Literal['HIDDEN', 'SAVED', 'TMP'] = 'SAVED')[source]#

Adds a shape of type <t>, with motor positions from mpos_list and screen position screen_coord.

Parameters:
  • mpos_list (list[float]) – List of motor positions

  • screen_coord (tuple[int, int]) – Screen coordinate for shape (x, y)

  • t (str) – Type str for shape, P (Point), L (Line), G (Grid)

  • state (Literal['HIDDEN', 'SAVED', 'TMP']) –

  • user_state (Literal['HIDDEN', 'SAVED', 'TMP']) –

Returns:

(Shape) Shape of type <t>

add_shape_from_refs(refs, t, state: Literal['HIDDEN', 'SAVED', 'TMP'] = 'SAVED', user_state: Literal['HIDDEN', 'SAVED', 'TMP'] = 'SAVED')[source]#

Adds a shape of type <t>, taking motor positions and screen positions from reference points in refs.

Parameters:
  • refs (list[str]) – List of id’s of the reference Points

  • t (str) – Type str for shape, P (Point), L (Line), G (Grid)

  • state (Literal['HIDDEN', 'SAVED', 'TMP']) –

  • user_state (Literal['HIDDEN', 'SAVED', 'TMP']) –

Returns:

Shape of type <t>

Return type:

(Shape)

cancel_centring()[source]#

Cancel current centring procedure.

centring_done()[source]#

Execute if centring accepted.

centring_failed()[source]#

Execute if centring failed or canceled.

clear_all()[source]#

Clear the shapes, remove all contents.

de_select_all()[source]#

De select all shapes.

de_select_shape(sid)[source]#

De-select the shape with id <sid>.

Parameters:

sid (str) – The id of the shape to de-select.

delete_shape(sid)[source]#

Removes the shape with id <sid> from the list of handled shapes.

Parameters:

sid (str) – The id of the shape to remove

Returns:

The removed shape

Return type:

(Shape)

get_centred_point_from_coord(x, y, return_by_names=None)[source]#

Get the motor positions form x,y pixel coordinates

get_grid()[source]#

Get the first of the selected grids, (the one that was selected first in a sequence of select operations)

Returns:

The first selected grid as a dictionary

Return type:

(dict)

get_grids() list[source]#

Get all Grids currently handled.

Returns:

List[Grid] - All currently handled grids,

Return type:

list

get_lines() list[source]#

Get all Lines currently handled.

Returns:

List[Line] - All currently handled lines.

Return type:

list

get_points() list[source]#

Get all Points currently handled.

Returns:

List[Point] - All currently handled points.

Return type:

list

get_positions() dict[str, float][source]#

Get motor positions for the centring motors.

Returns:

position}

Return type:

Centring motor positions as {role

get_selected_shapes()[source]#

Get all selected shapes.

Returns:

(list[Shape]) List of selected Shapes

get_shape(sid: str)[source]#

Get Shape with id <sid>.

Parameters:

sid (str) – id of Shape to retrieve

Returns:

(Shape) All the shapes

get_shapes() list[source]#

Get all Shapes.

Returns:

(list[Shape]) All the shapes

Return type:

list

get_snapshot(overlay: str | None = None, bw: bool = False, return_as_array: bool = False) BytesIO[source]#

Get snapshot(s)

Parameters:
  • overlay (str | None) – Image data with shapes and other items to display on the snapshot

  • bw (bool) – return grayscale image

  • return_as_array (bool) – return as np array if True, Default False

Returns:

(BytesIO) snapshot as bytes image

Return type:

BytesIO

inc_used_for_collection(cpos)[source]#

Increase counter that keepts on collect made on this shape, shape with associated CenteredPosition cpos

Parameters:

cpos (CenteredPosition) – CenteredPosition of shape

init()[source]#

‘public’ post-initialization method. Override as needed.

For ConfiguredObjects called after loading contained objects.

is_selected(sid)[source]#

Check if Shape with <sid> is selected.

Returns:

(Boolean) True if Shape with <sid> is selected False otherwise

motor_positions_to_screen(positions_dict: dict[str, float]) tuple[int, int][source]#

Get the x,y pixel value according to the calibration.

Parameters:

positions_dict (dict[str, float]) – Dictionary {role: position}

Return type:

tuple[int, int]

move_to_beam(x: float, y: float)[source]#

Move the sample to the x,y coordinates. :param x: Pixels on x axis :param y: Pixels on y axis

Parameters:
reject_centring()[source]#

Reject the current centred position.

run_custom_auto_centring()[source]#

Run custom script for the automatic centring

save_snapshot(filename: str, overlay: str | None = None, bw: bool = False)[source]#

Save a snapshot to file.

Parameters:
  • filename (str) – The filename.

  • overlay (str | None) – Image data with shapes and other items to display on the snapshot

  • bw) – return grayscale image if true. Default False

  • bw (bool) –

select_shape(sid)[source]#

Select the shape <shape>.

Parameters:

sid (str) – Id of the shape to select.

select_shape_with_cpos(cpos)[source]#

Selects shape with the assocaitaed centred position <cpos>

Parameters:

cpos (CenteredPosition) –

set_grid_data(sid: str, result_data, data_file_path: str)[source]#

Sets grid rsult data for a shape with the specified id.

Parameters:
  • sid (str) – The id of the shape to set grid data for.

  • result_data – The result data to set for the shape. Either a base64 encoded string for PNG/image or a dictionary for RGB (keys are cell number and value RGBa list). Data is only updated if result is RGB based

  • data_file_path (str) – The path to the data file associated with the result data.

Raises:

AttributeError – If no shape with the specified id exists.

set_rotation_axis_position(value: float)[source]#

Set the reference position for the rotation axis.

value: the position

Parameters:

value (float) –

start_auto_centring()[source]#

Start automatic centring procedure

start_manual_centring(nb_click: int = 3)[source]#

Do the manual centring procedure.

Parameters:

nb_click (int) – Number of clicks.

take_acq_snapshot(image_path_list: list)[source]#

Take snapshot in the acquisition sequence. :param image_path_list: List of file name(s) to save the snapshot(s}

(full path).

Parameters:

image_path_list (list) –

take_snapshot(overlay_data: str | None = None, bw: bool = False)[source]#

Get snapshot with overlaid data.

Parameters:
  • overlay_data (str | None) – base64 encoded image to lay over camera image

  • bw (bool) – return grayscale image if True, Default False

Returns:

(Image) rgb or grayscale image

class mxcubecore.HardwareObjects.SampleView.Shape(mpos_list=None, screen_coord=(-1, -1))[source]#

Bases: object

Base class for shapes.

get_centred_positions()[source]#
Returns:

The centred position(s) associated with the shape.

Return type:

List of CentredPosition objects.

class mxcubecore.HardwareObjects.SampleView.TwoDPoint(mpos_list, screen_coord)[source]#

Bases: Point