science_jubilee.tools.Spectrometer#

Classes#

Labware

A class representing a basic laboratory labware made up of a set of wells/pipette tips.

Location

A location to target as a motion.

Well

A class representing a well of a labware.

Tool

SpectroscopyTool

A class representation for an Ocean Optics Spectrometer, Light source, and Probe

MeasurementManager

A class to manage the measurements taken by the SpectroscopyTool

Functions#

requires_active_tool(func)

Decorator to ensure that a tool cannot complete an action unless it is the

Module Contents#

class science_jubilee.tools.Spectrometer.Labware(labware_filename: str, offset: Tuple[float] = None, order: str = 'rows', path: str = os.path.join(os.path.dirname(__file__), 'labware_definition'))[source]#

Bases: WellSet

A class representing a basic laboratory labware made up of a set of wells/pipette tips.

Parameters:
  • labware_filename (str) – The name of the config .json

  • offset (Tuple[float], optional) – Coordinates to use to offset all the wells in a labware for easier handling of coordinates. For example this is called by the :method:`Deck.load_labware` when assignign a labware to a deck slot, defaults to None

  • order (str, optional) – Option to order the wells of a labware either by row or columns, defaults to ‘rows’

  • path (str, optional) – Path to the folder containing the configuration .json files for the labware, defaults to the ‘labware_definition/’ in the science_jubilee/labware directory.

__repr__()[source]#

Displayed representation of a Labware object indicating the type of labware and its name. Additionally, it will show the :attribute:`Deck.slots` number if the labware has been already assigned to it.

_create_rows_and_columns()[source]#

Creates a dictionary of Row and Column and Well objects from the data in the config .json file.

Returns:

A dictionary of Row and Column and Well objects

Return type:

Row, Column, Well

get_row(row_id: str) Row[source]#

Fucntions to fetch the Well.name of the indicated row.

Parameters:

row_id (str) – The name of a row of the labware, usually indicated by a capital letter (e.g., A, B, etc.)

Returns:

A list of Well objects diplayed by their :attribute:`Well.name`

Return type:

Row

get_column(col_id: int) Column[source]#

Fucntions to fetch the Well.name of the indicated column.

Parameters:

col_id (str) – The name of a column of the labware, usually indicated by an integer number (e.g., 1, 2, etc.)

Returns:

A list of Well objects diplayed by their :attribute:`Well.name`

Return type:

Column

property shape#
Returns the shape of the labware as a tuple of (rows, columns)
Returns:

A tuple of (rows, columns)

Return type:

Tuple[int, int]

property ordering: List[List[str]]#

Returns the ordering of the wells in the labware as a list of lists. Each list represents a row of the labware.

Returns:

A list of lists of Well.name objects

Return type:

List[List[str]]

property brand: dict#

Returns the brand of the labware as a strin

Returns:

A string with the brand of the labware

Return type:

str

metadata() dict[source]#

Returns the metadata of the labware as a dictionary

The metadata of a labware will generally contain the display name, the type of labware, and the units of volume. These can also be found as attributes of the Labware object.

Returns:

A dictionary with the metadata of the labware

Return type:

dict

property display_name#
Returns the display name of the labware as a string
Returns:

A string with the display name of the labware

Return type:

str

property labware_type#
Returns the type of labware as a string

The type fo labware will generally either be a tiprack, wellplate, reservoir, etc.

Returns:

A string with the type of labware

Return type:

str

property volume_units#
Returns the units of volume of the labware as a string

The volume units will be either uL or mL.

Returns:

A string with the units of volume of the labware

Return type:

str

property dimensions: dict#

Returns the dimensions of the labware as a dictionary

Returns:

A dictionary with the x,y, and z dimensions of the labware

Return type:

dict

parameters() dict[source]#

Returns the parameters describing certain features of the labware as a dictionary

The parameters genereally include whether the shape of the labware is regular or irregular, if it is a tiprack, and other Opentrons specific parameters as we are using their ‘Custom Labware Page’ to generate the .json config files.

Returns:

A dictionary with the parameters of the labware

Return type:

dict

property is_tip_rack#
Returns a boolean indicating if the labware is a tiprack
Returns:

True if the labware is a tiprack, False otherwise

Return type:

bool

property load_name#
Returns the name of the labware as a string
Returns:

A string with the name of the labware

Return type:

str

property tip_length#
Returns the length of the tip of the labware as a float if the labware is a tiprack, otherwise returns None
Returns:

A float with the length of the tip of the labware or None otherwise

Return type:

float

property tip_overlap#
Returns the overlap of the tip of the labware as a float if the labware is a tiprack, otherwise returns None
Returns:

A float with the overlap of the tip of the labware or None otherwise

Return type:

float

property offset#
Returns the offset of the labware as a tuple of floats
Returns:

A tuple of floats with the offset of the labware

Return type:

Tuple[float]

add_slot(slot_)[source]#

Add name of deck slot after labware has been loaded

Parameters:

slot (str) – The name of the deck slot

withWellOrder(order) list[source]#

Reorders the wells by rows or by columns. Automatically updates the :attribute:`Labware.wells`

Parameters:

order (str) – The order in which to reorder the wells. Can be either ‘rows’ or ‘columns’

Returns:

A list of Well objects diplayed by their :attribute:`Well.name`

Return type:

list

_translate_point(well: Well, theta: float, x_space: float, y_space: float, upper_left: Tuple[float])[source]#

Helper function to translate the coordinates of a well by a given angle theta.

Parameters:
  • well (Well) – A Well object

  • theta (float) – The angle by which to translate the coordinates of the well

Returns:

The new x and y coordinates of the well

Return type:

float, float

static _nominal_coordinates(well: Well, x_space: float, y_space: float)[source]#

Helper function to calculate the nominal coordinates of a well in a labware based on its row and column index.

manual_offset(corner_wells: List[Tuple[float]], save: bool = False)[source]#

Allows the user to manually offset the coordinates of the labware based on three corner wells.

Adapted from https://github.com/machineagency/sonication_station labware calibration procedure.

Parameters:
  • offset (Tuple[float]) – A list containing tuples of floats

  • save (bool, optional) – Option to save the manual offset to the original config .json file, defaults to False

Returns:

An updated Labware object with the new coordinates of the wells

Return type:

Labware

load_manualOffset(apply: bool = True)[source]#

Loads the manual offset of a labware from its config .json file for a specific slot

Parameters:

apply (bool, optional) – Option to apply the manual offset to the labware or return values, defaults to False

Returns:

A list of tuples containing the manual offset of the labware

Return type:

List[Tuple[float]]

static _getxyz(location: Well | Tuple | Location)[source]#

Helper function to extract the x, y, z coordinates of a location object.

Parameters:

location (Union[Well, Tuple, Location]) – The location object to extract the coordinates from. This can either be a Well, a :tuple: of x, y, z coordinates, or a Location object

Raises:

ValueError – If the location is not a Well, a tuple, or a Location object

Returns:

The x, y, z coordinates of the location

Return type:

float, float, float

class science_jubilee.tools.Spectrometer.Location(point: Point, labware: Well | Labware)[source]#

A location to target as a motion.

The location contains a Point and possibly an associated Labware or Well instance.

property point: Point#

The coordinates (x,y,z) of a Well or a Labware

Returns:

A tuple of coordinates (x,y,z)

Return type:

Point

property labware#
The :class:`Well` object associated with the coordinates (x,y,z)
Returns:

A Well object

Return type:

Well

__iter__() Iterable[Point | Well | Labware][source]#

Iterable interface to support unpacking of Location objects.

Returns:

An interable of Location objects

Return type:

Iterable[Union[Point, Well, Labware]]

__eq__(other: object) bool[source]#

Comparison between two Location objects.

Parameters:

other (Location) – A Location object

Returns:

True if the two Location objects are equal, False otherwise

Return type:

bool

__repr__() str[source]#

Returns a string representation of the Location object.

Returns:

A string representation of the Location object

Return type:

str

class science_jubilee.tools.Spectrometer.Well[source]#

A class representing a well of a labware.

Each Well is associated with a specific name, depth, total liquid volume, shape, diameter, x, y, and z dimension, y-dimension, as well as its coordinates and any applied offset

Returns:

A Well object with various information about the geometry of the well and its position in the labware

Return type:

Well

name: str#
depth: float#
totalLiquidVolume: float#
shape: str#
diameter: float = None#
xDimension: float = None#
yDimension: float = None#
x: float#
y: float#
z: float#
offset: Tuple[float] = None#
slot: int = None#
has_tip: bool = False#
clean_tip: bool = False#
labware_name: str = None#
property x#
Offsets the x-position of the each well with respect to the deck-slot coordinates
Returns:

The x-coordinate of the well

Return type:

float

property y#
Offsets the y-position of the each well with respect to the deck-slot coordinates
Returns:

The y-coordinate of the well

Return type:

float

property z#
Offsets the z-position of each well with respect to the deck-slot coordinates
Returns:

The z-coordinate of the well

Return type:

float

apply_offset(offset: Tuple[float])[source]#

Allows the user to offset the coordinates of the well with respect to the deck-slot coordinates

Parameters:

offset (Tuple[float]) – A tuple of floats with the new offset of the well

property top_#
Defines the top-most point of the well
Returns:

The z-coordinate of the top of the well

Return type:

float

property bottom_#
Defines the bottom-most point of the well
Returns:

The z-coordinate of the bottom of the well

Return type:

float

bottom(z: float, check=False)[source]#

Allows the user to dinamically indicate a new Z location relative to the bottom of the well.

Parameters:
  • z (float) – the distance in mm to offset the coordinates from the bottom of the well. Should be +

  • check (bool, optional) – the ‘z’ parameters can either be + or -. If negative, an assert error is raised to avoid collision with the labware. However, there might be instances of custom labware where the bottom of the well is purposely set as higher during the generation of its config .json file., defaults to False

Returns:

A Location which contains information about the new coordinates generated and the Well object

Return type:

Location

top(z: float)[source]#

Allows the user to dinamically indicate a new Z location relative to the top of the well.

Parameters:

z (float) – the distance in mm to offset the coordinates from the top of the well.Can be either + or -

Returns:

A Location which contains information about the new coordinates generated and the Well object.

Return type:

Location

__repr__()[source]#

Displayed representation of a Well object indicating its name and its coordinates

Returns:

A string representation of the name and coordinates of a well

Return type:

str

set_has_tip(value: bool)[source]#

Set the value of the has_tip attribute.

Parameters:

value (bool) – The new value for the has_tip attribute

set_clean_tip(value: bool)[source]#

Returns the value of the clean_tip attribute.

Parameters:

value (bool) – The new value for the clean_tip attribute

class science_jubilee.tools.Spectrometer.Tool(index, name, **kwargs)[source]#
post_load()[source]#

Run any code after tool has been associated with the machine.

science_jubilee.tools.Spectrometer.requires_active_tool(func)[source]#

Decorator to ensure that a tool cannot complete an action unless it is the current active tool.

class science_jubilee.tools.Spectrometer.SpectroscopyTool(index, name)[source]#

Bases: science_jubilee.tools.Tool.Tool, oceandirect.OceanDirectAPI.OceanDirectAPI

A class representation for an Ocean Optics Spectrometer, Light source, and Probe

For that we wil be unfortunately using their own SDK package, which is NOT open-source.

property _api_version[source]#
The version of the Ocean Insight SDK
property _usb_device[source]#
property _device_id[source]#
The ID of the spectrometer
_open_device()[source]#

Connects to the spectrometer device

property _model[source]#
The spectrometer model
property _serial_number[source]#
The spectrometer serial number
property _integration_time[source]#
integration_time(t: float, units: str = 'ms')[source]#

Sets the integration time for the spectrometer.

Parameters:
  • t (float) – integration time

  • units (str, optional) – units of integration time, defaults to ‘ms’

property wavelengths[source]#
Return list containing the wavelengths of the spectrometer.
Returns:

A list of wavelengths

Return type:

list

scans_to_average(n: int)[source]#

Set the number of scans to average together to compose a single spectrum.

Parameters:

n – number of scans to average

:type n:int

boxcar_width(w: int = None)[source]#

Unit used to smooth the spectrum.

The boxcar width is the number of adjacent pixels that are averaged together to smooth the spectrum. Pixel average = 2* boxcar_width + 1

Parameters:

w (int) – boxcar width

lamp_shutter(open=True)[source]#

Opens or closes light source shutter, if feature is available on light source.)

Parameters:

open – True opens the shutter/False closes it, defaults to False

_take_spectrum(open=True)[source]#

Collect a spectrum with the specified experimental parameters

dark_spectrum(int_time: float, scan_num: int, boxcar_w: int = None, save: bool = False, path: str = None, filename: str = None)[source]#

Collect a dark spectrum with the specified experimental parameters.

A dark spectrum is collected when no light is incident on the detector. This shuold later be used to correct the actual spectrum for dark counts (i.e. thermal noise). Note: these shuold be the same as the ones used for the actual spectrum.

Parameters:

int_time – integration time

_collect_raw_spectrum(int_time: float, scan_num: int, boxcar_w: int, int_time_units: str = 'ms')[source]#

Collect a spectrum with the specified experimental parameters

Parameters:
  • int_time (float) – integration time

  • scan_num (int) – number of scans to average

  • boxcar_w (int, optional) – boxcar width for smoothing the spectrum, defaults to None

  • int_time_units (str, optional) – units of integration time, defaults to ‘ms’

Returns:

spectrum

Return type:

numpy array

collect_spectrum(location: science_jubilee.labware.Labware.Well | Tuple | science_jubilee.labware.Labware.Location, int_time, scan_num, boxcar_w, int_time_units='ms', save: bool = False, filename: str = None, path: str = None)[source]#

Collect spectrum at the specified location on the labware

save_to_file(data, dark: bool = False, path: str = None, filename: str = None)[source]#

Save the spectrum to a file

read_from_file(filepath, scale=True, reference_spectrum=None)[source]#
static scale_intensity(data: list, reference_spectrum: list)[source]#
class science_jubilee.tools.Spectrometer.MeasurementManager(metadata, raw_data)[source]#

A class to manage the measurements taken by the SpectroscopyTool

pretty_print()[source]#
generate_file(filename, path)[source]#
read_file()[source]#