The Microscope classes

Several classes with a more pythonic interface exists. All these classes implement the same methods as described by the BaseMicroscope. Currently the following implementations exists:

The BaseMicroscope class

class temscript.BaseMicroscope

Abstract base class for microscope classes.

Do not use BaseMicroscope directly, instead instantiate one of the subclasses, like Microscope or RemoteMicroscope. The Subclasses implement all the abstract methods.

abstractmethod acquire(*args)

Acquire images for all detectors given as argument. The images are returned in an dict indexed by detector name.

abstractmethod get_beam_blanked()

Return whether the beam is blanked.

Return type:

bool

Added in version 2.0.0.

abstractmethod get_beam_shift()

Return beam shift as (x,y) tuple in meters.

Note

The accuracy of this value depends on the accuracy of the calibration within the microscope.

On FEI microscopes this corresponds to the state of “User Beam Shift” (in different units though).

abstractmethod get_beam_tilt()

Return beam tilt as (x, y) tuple.

The units this is returned in are radians. The accuracy of ths value depends on the accuracy of the calibration within the microscope and thus is better not to be trusted blindly.

On FEI microscopes this corresponds to the state of “DF Tilt”, however the tilt is always returned in cartesian coordinates.

abstractmethod get_camera_param(name)

Return dictionary with parameters for camera name.

The returned dictionary has the following keys:

  • “image_size”: Size of image (see AcqImageSize): “FULL”, “HALF”, …

  • “binning”: Binning

  • “exposure(s)”: Exposure time in seconds

  • “correction”: Correction mode (see AcqImageCorrection)

  • “exposure_mode”: Exposure mode (see AcqExposureMode)

  • “shutter_mode”: Shutter mode (see AcqShutterMode)

  • “pre_exposure(s)”: Pre exposure time in seconds

  • “pre_exposure_pause(s)”: Pre exposure pause time in seconds

Added in version 2.0.

Note

On Titan 1.1 software the “exposure_time(s)” value might not reflect the correct exposure time. See Restrictions.

abstractmethod get_cameras()

Return dictionary with all available cameras. The method will return a dict, indexed by camera name, with another dict as values.

For cameras the embedded dict will additionally have the following keys:

  • “type”: “CAMERA”

  • “height”: Height of the detector

  • “width”: Width of the detector

  • “pixel_size(um)”: Pixel size in micrometers

  • “binnings”: List of supported binnings

  • “shutter_modes”: List of supported shutter modes (see AcqShutterMode)

  • “pre_exposure_limits(s)”: Tuple with Min/Max values of pre exposure times in seconds

  • “pre_exposure_pause_limits(s)”: Tuple with Min/Max values of pre exposure pause times in seconds

For “STEM_DETECTOR” detectors the embedded dict will additionally have the following keys:

  • “binnings”: List of supported binnings

Added in version 2.0.

abstractmethod get_column_valves_open()

Returns state of the column valves.

Returns:

True, if column valves are open. False, otherwise.

abstractmethod get_condenser_mode()

Get condenser mode

Return type:

Literal[‘PARALLEL’, ‘PROBE’]

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

abstractmethod get_condenser_stigmator()

Return value of condenser shift

Returns:

(x, y) tuple with condenser shift value

Added in version 1.0.10.

abstractmethod get_convergence_angle()

Return convergence angle (radian)

Return type:

float

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

abstractmethod get_dark_field_mode()

Get dark field mode.

Note

set_beam_tilt() might change this value.

Return type:

Literal[‘OFF’, ‘CARTESIAN’, ‘CONICAL]

Added in version 2.0.0.

abstractmethod get_defocus()

Return defocus value. The returned value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Note

On Titan 1.1 software the defocus value is the actual defocus relative to the eucentric defocus in meters. The accuracy of this value depends on the accuracy of the calibration within the microscope.

Added in version 1.0.9.

get_detector_param(name)

Return parameters for detector name as dictionary.

For “CAMERA” detectors the dict will have the following keys:

  • “image_size”: Size of image (see AcqImageSize): “FULL”, “HALF”, …

  • “binning”: Binning

  • “exposure(s)”: Exposure time in seconds

  • “correction”: Correction mode (see AcqImageCorrection)

  • “exposure_mode”: Exposure mode (see AcqExposureMode)

  • “shutter_mode”: Shutter mode (see AcqShutterMode)

  • “pre_exposure(s)”: Pre exposure time in seconds

  • “pre_exposure_pause(s)”: Pre exposure pause time in seconds

For “STEM_DETECTORS” the dict will have the following keys:

  • “brightness”: Brightness settings

  • “contrast”: Contrast setting

  • “image_size”: Size of image (see AcqImageSize): “FULL”, “HALF”, …

  • “binning”: Binning

  • “dwell_time(s)”: Dwell time in seconds

Changed in version 2.0: Key returning dwell time renamed from ‘dwelltime(s)’ to ‘dwell_time(s)’

Deprecated since version 2.0: Use the methods get_camera_param(), get_stem_param(), or get_stem_acquisition_param() instead.

get_detectors()

Return dictionary with all available detectors.

The returned dictionary is the combination of the dicts returned by the get_cameras() and get_stem_detectors() methods. The embedded dicts have a key “type” with value “CAMERA” or “STEM_DETECTOR” identifying the detector type.

abstractmethod get_diffraction_shift()

Return value of diffraction shift

Returns:

(x, y) tuple with diffraction shift value

Added in version 1.0.10.

abstractmethod get_family()

Return product family (see ProductFamily for values): “TITAN”, “TECNAI”, …

abstractmethod get_illuminated_area()

Return illuminated area.

TEM scripting manual states the result is in meters, however it is unclear what is actually meant (diameter?)

Return type:

float

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

abstractmethod get_illumination_mode()

Get illumination mode (mini condenser setting)

Return type:

Literal[‘NANOPROBE’, ‘MICROPROBE’]

Added in version 2.0.0.

abstractmethod get_image_shift()

Return image shift as (x,y) tuple in meters.

Note

The accuracy of this value depends on the accuracy of the calibration within the microscope.

On FEI microscopes this corresponds to the state of “User Image Shift” (in different units though).

abstractmethod get_indicated_camera_length()

Return (indicated) camera length in meters in diffraction modes.

Note

The scripting manual states, that this function always returns 0, if microscope is in imaging mode. In STEM mode this function works reportedly nevertheless.

Added in version 1.0.9.

abstractmethod get_indicated_magnification()

Return (indicated) magnification in imaging modes.

Note

The scripting manual states, that this function always returns 0, if microscope is in diffraction mode. In STEM mode this function works reportedly nevertheless.

Note

On Titan 1.1 software this method returns 0.0 regardless of used mode. See Restrictions.

Added in version 1.0.9.

abstractmethod get_instrument_mode()

Get instrument mode.

Return type:

Literal[‘TEM’, ‘STEM’]

Added in version 2.0.0.

abstractmethod get_intensity()

Return intensity value.

The returned value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Added in version 1.0.10.

abstractmethod get_magnification_index()

Return index of current magnification/camera length.

Added in version 1.0.9.

abstractmethod get_microscope_id()

Return microscope ID.

There is no way to read this via the scripting adapter directly, thus this method uses hostname instead.

abstractmethod get_objective_excitation()

Return excitation of objective lens.

Added in version 1.0.9.

abstractmethod get_objective_stigmator()

Return value of objective shift

Returns:

(x, y) tuple with objective shift value

Added in version 1.0.10.

get_optics_state()

Return a dictionary with state of microscope optics.

Added in version 1.0.9.

Deprecated since version 2.0: use get_state() instead.

abstractmethod get_probe_defocus()

Return probe defocus (meters).

Return type:

float

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

abstractmethod get_projection_mode()

Return current projection mode.

Added in version 1.0.9.

abstractmethod get_projection_mode_string()

Return description of current projection mode. Possible return values are: “LM”, Mi”, “SA”, “Mh”, “LAD”, and “D”

Added in version 1.0.9.

abstractmethod get_projection_sub_mode()

Return current projection sub mode.

Added in version 1.0.10.

abstractmethod get_screen_current()

Get current on fluorescent screen

Returns:

Screen currrent in Amperes

Added in version 2.0.0.

abstractmethod get_screen_position()

Get position of fluorescent screen

Return type:

Literal[‘UP’, ‘DOWN’, ‘UNKNOWN’]

Added in version 2.0.0.

abstractmethod get_spot_size_index()

Get spot size index.

Return type:

int

Added in version 2.0.0.

abstractmethod get_stage_holder()

Return holder currently in stage (see StageHolderType)

abstractmethod get_stage_limits()

Returns dictionary with min/max tuples for all holder axes. The tuples are the values, the axis names are the keys. For axes “x”, “y”, “z” the unit is meters For axes “a”, “b” the unit is radians

abstractmethod get_stage_position()

Returns dictionary with stage position (axes names are used as keys). For axes “x”, “y”, “z” the unit is meters For axes “a”, “b” the unit is radians

abstractmethod get_stage_status()

Return status of stage (see StageStatus)

get_state()

Return a dictionary with state of the microscope.

Added in version 1.0.9.

Changed in version 2.0: The method was renamed from get_optics_state() to get_state()

abstractmethod get_stem_acquisition_param()

Return dictionary with STEM acquisition parameters.

The returned dictionary has the following keys:

  • “image_size”: Size of image (see AcqImageSize): “FULL”, “HALF”, …

  • “binning”: Binning

  • “dwell_time(s)”: Dwell time in seconds

Added in version 2.0.

Note

On Titan 1.1 software reading the parameters fails, if STEM is not available. See Restrictions.

abstractmethod get_stem_detector_param(name)

Return dictionary with parameters for detector name.

The returned dictionary has the following keys:

  • “brightness”: Brightness settings

  • “contrast”: Contrast setting

Added in version 2.0.

abstractmethod get_stem_detectors()

Return dictionary with all available stem detectors. The method will return a dict, indexed by camera name, with another dict as values.

The embedded dict will additionally have the following keys:

  • “type”: “STEM_DETECTOR”

  • “binnings”: List of supported binnings

Added in version 2.0.

abstractmethod get_stem_magnification()

Get STEM magnification

Return type:

float

Added in version 2.0.0.

abstractmethod get_stem_rotation()

Get STEM rotation (radian)

Return type:

float

Added in version 2.0.0.

abstractmethod get_vacuum()

Return status of the vacuum system. The method will return a dict with the following entries:

  • “status”: Status of the vacuum system (see VacuumStatus): “READY”, “OFF”, …

  • “column_valves_open”: Whether the column valves are currently open

  • “pvp_running”: Whether the PVP is running

  • “gauges(Pa)”: dict with Gauge values in Pascal (or the string “UNDERFLOW” or “OVERFLOW”)

abstractmethod get_version()

Return version string for temscript.

Added in version 1.0.8.

Returns:

String “major.minor.patchlevel”

abstractmethod get_voltage()

Return acceleration voltage in kV.

Returns:

Float with voltage

abstractmethod is_stem_available()

Return whether the microscope has STEM capabilities.

Return type:

bool

Added in version 2.0.0.

abstractmethod normalize(mode='ALL')

Normalize some or all lenses.

Possible values for lenses are:

  • “SPOTSIZE”: The C1 lens

  • “INTENSITY”: The C2 and - if present - the C3 lens

  • “CONDENSER”: C1, C2, and - if present - the C3 lens

  • “MINI_CONDENSER”: The mini condenser lens

  • “OBJECTIVE”: Objective and mini condenser lens

  • “PROJECTOR”: Projective lenses (DL, IL, P1, P2)

  • “OBJECTIVE_CONDENSER”: Objective and condenser system

  • “OBJECTIVE_PROJECTOR”: Objective and projector system

  • “ALL”: All lenses

Parameters:

mode (str) – What to normalize. If omitted, all lenses are normalized.

Added in version 1.0.9.

abstractmethod set_beam_blanked(mode)

Enable beam blanker

Added in version 2.0.0.

abstractmethod set_beam_shift(shift)

Set beam shift to position shift, which should be an (x, y) tuple, as returned for instance by get_beam_shift().

Parameters:

shift (Tuple[float, float]) – Shift value

abstractmethod set_beam_tilt(tilt)

Set beam tilt to position tilt, which should be an (x, y) tuple, as returned for instance by get_beam_tilt().

On FEI microscopes, this will turn on dark field mode, unless (0, 0) is set. If (0, 0) is set, dark field mode is turned off.

abstractmethod set_camera_param(name, values, ignore_errors=False)

Set parameters for camera name. The parameters should be given as a dictionary. Allowed keys are described in the get_camera_param() method.

When ignore_errors is set and setting of a parameter fails, no error is raised. If an unknown camera name is used, an error is raised nevertheless.

Raises:

KeyError – If an unknown camera name is used.

Added in version 2.0.

Note

  • On Titan 1.1 software setting the “binning” property also changes the exposure time.

  • On Titan 1.1 software images acquired after setting the “exposure_time(s)” property might not be acquired with the new setting, even though this property reflects the new value when read.

Also see Restrictions.

abstractmethod set_column_valves_open(state)

Set state of the column valves. The column valves are opened, if True is passes as state

Parameters:

state (bool) – True, if column valves should be opened. False, if they should be closed.

abstractmethod set_condenser_mode(mode)

Set condenser mode

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

abstractmethod set_condenser_stigmator(value)

Set condenser stigmator.

Parameters:

value – (x, y) tuple, as returned for instance by get_condenser_stigmator().

Added in version 1.0.10.

abstractmethod set_convergence_angle(value)

Set convergence angle (radian).

Note

This method is only available on microscopes of the TITAN family.

..versionadded:: 2.0.0

abstractmethod set_dark_field_mode(mode)

Set dark field mode.

Note

set_beam_tilt() might change this value.

Added in version 2.0.0.

abstractmethod set_defocus(value)

Set defocus value. The value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Note

On Titan 1.1 software the defocus value is the actual defocus relative to the eucentric defocus in meters. The accuracy of this value depends on the accuracy of the calibration within the microscope.

Parameters:

value (float) – Defocus to set

Added in version 1.0.9.

set_detector_param(name, param)

Set parameters for detector name. The parameters should be given as a dictionary. Allowed keys are described in the get_detector_param() method. If setting a parameter fails, no error is given. Unknown parameters are ignored.

Changed in version 2.0: Dwell time can be set by parameters ‘dwelltime(s)’ and ‘dwell_time(s)’.

Deprecated since version 2.0: Use the methods set_camera_param(), set_stem_detector_param(), or set_stem_acquisition_param() instead.

abstractmethod set_diffraction_shift(value)

Set diffraction shift.

Parameters:

value – (x, y) tuple, as returned for instance by get_diffraction_shift().

Added in version 1.0.10.

abstractmethod set_illuminated_area(value)

Set illuminated area.

TEM scripting manual states the result is in meters, however it is unclear what is actually meant (diameter?)

Note

This method is only available on microscopes of the TITAN family.

..versionadded:: 2.0.0

abstractmethod set_illumination_mode(mode)

Set illumination mode (mini condenser setting)

Added in version 2.0.0.

abstractmethod set_image_shift(pos)

Set image shift to position pos, which should be an (x, y) tuple, as returned for instance by get_image_shift().

abstractmethod set_instrument_mode(mode)

Set instrument mode.

Added in version 2.0.0.

abstractmethod set_intensity(value)

Set intensity.

The value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Parameters:

value (float) – Intensity to set

Added in version 1.0.10.

abstractmethod set_magnification_index(index)

Set magnification / camera length index.

Parameters:

index (int) – Magnification/Camera length index

Added in version 1.0.9.

abstractmethod set_objective_stigmator(value)

Set objective stigmator.

Parameters:

value – (x, y) tuple, as returned for instance by get_objective_stigmator().

Added in version 1.0.10.

abstractmethod set_probe_defocus(value)

Set probe defocus (meters).

Note

This method is only available on microscopes of the TITAN family.

..versionadded:: 2.0.0

abstractmethod set_projection_mode(mode)

Set projection mode.

Parameters:

mode (Literal['DIFFRACTION', 'IMAGING']) – Projection mode: “DIFFRACTION” or “IMAGING”

Added in version 1.0.9.

Note

On Titan 1.1 software changing the mode from IMAGING to DIFFRACTION and back again changes the magnification. See Restrictions.

abstractmethod set_screen_position(mode)

Set position of fluorescent screen

Added in version 2.0.0.

abstractmethod set_spot_size_index(index)

Set spot size index.

Added in version 2.0.0.

set_stage_position(pos=None, method=None, speed=None, **kw)

Set new stage position.

The new position can either be passed as dict pos or passed by keywords x, y, z, a, b. If both are present, the keywords override values from the dict. Only the axes are driven which are mentioned in the pos dict or by keywords.

The optional keyword “speed” allows to set movement speed (only “GO” method). A speed of 1.0 corresponds to default speed.

For axes “x”, “y”, “z” the unit is meters. For axes “a”, “b” the unit is radians.

There are two methods of movement:

  • “GO”: Moves directly to new stage position (default)

  • “MOVE”: Avoids pole piece touches, by first zeroing the angle, moving the stage than, and setting the angles again.

Changed in version 1.0.10: “speed” keyword added.

Deprecated since version In: versions < 2.0.0 the “speed” and “method” keywords could also be passed within the pos dictionary. This is usage is deprecated since 2.0.0, use the speed and method keywords instead.

abstractmethod set_stem_acquisition_param(values, ignore_errors=False)

Set parameters for STEM acquisition. The parameters should be given as a dictionary. Allowed keys are described in the get_stem_acquisition_param() method.

When ignore_errors is set and setting of a parameter fails, no error is raised.

Added in version 2.0.

abstractmethod set_stem_detector_param(name, values, ignore_errors=False)

Set parameters for STEM detector name. The parameters should be given as a dictionary. Allowed keys are described in the get_stem_detector_param() method.

When ignore_errors is set and setting of a parameter fails, no error is raised. If an unknown detector name is used, an error is raised nevertheless.

Raises:

KeyError – If an unknown detector name is used.

Added in version 2.0.

abstractmethod set_stem_magnification(value)

Set STEM magnification

Added in version 2.0.0.

abstractmethod set_stem_rotation(value)

Set STEM rotation (radian)

Added in version 2.0.0.

The Microscope class itself

The Microscope class provides a interface to the microscope if the script is run locally on the microscope’s computer. See BaseMicroscope for a description of its methods.

class temscript.Microscope

Hich level interface to local microscope.

Creating an instance of this class, already queries the COM interface for the instrument.

Usage:

>>> microscope = Microscope()
>>> microscope.get_family()
"TITAN"

The RemoteMicroscope class

The RemoteMicroscope provides the same methods as the Microscope class, but connects to a remote microscope server.

The temscript server must be running on the microscope PC. See section The temscript server for details.

class temscript.RemoteMicroscope(address, transport=None, timeout=None)

Microscope-like class, which connects to a remote microscope server.

Parameters:
  • address (Tuple[str, int]) – (host, port) combination for the remote microscope.

  • transport (Literal['JSON', 'PICKLE']) – Underlying transport protocol, either ‘JSON’ (default) or ‘PICKLE’

acquire(*detectors)

Acquire images for all detectors given as argument. The images are returned in an dict indexed by detector name.

get_beam_blanked()

Return whether the beam is blanked.

Return type:

bool

Added in version 2.0.0.

get_beam_shift()

Return beam shift as (x,y) tuple in meters.

Note

The accuracy of this value depends on the accuracy of the calibration within the microscope.

On FEI microscopes this corresponds to the state of “User Beam Shift” (in different units though).

get_beam_tilt()

Return beam tilt as (x, y) tuple.

The units this is returned in are radians. The accuracy of ths value depends on the accuracy of the calibration within the microscope and thus is better not to be trusted blindly.

On FEI microscopes this corresponds to the state of “DF Tilt”, however the tilt is always returned in cartesian coordinates.

get_camera_param(name)

Return dictionary with parameters for camera name.

The returned dictionary has the following keys:

  • “image_size”: Size of image (see AcqImageSize): “FULL”, “HALF”, …

  • “binning”: Binning

  • “exposure(s)”: Exposure time in seconds

  • “correction”: Correction mode (see AcqImageCorrection)

  • “exposure_mode”: Exposure mode (see AcqExposureMode)

  • “shutter_mode”: Shutter mode (see AcqShutterMode)

  • “pre_exposure(s)”: Pre exposure time in seconds

  • “pre_exposure_pause(s)”: Pre exposure pause time in seconds

Added in version 2.0.

Note

On Titan 1.1 software the “exposure_time(s)” value might not reflect the correct exposure time. See Restrictions.

get_cameras()

Return dictionary with all available cameras. The method will return a dict, indexed by camera name, with another dict as values.

For cameras the embedded dict will additionally have the following keys:

  • “type”: “CAMERA”

  • “height”: Height of the detector

  • “width”: Width of the detector

  • “pixel_size(um)”: Pixel size in micrometers

  • “binnings”: List of supported binnings

  • “shutter_modes”: List of supported shutter modes (see AcqShutterMode)

  • “pre_exposure_limits(s)”: Tuple with Min/Max values of pre exposure times in seconds

  • “pre_exposure_pause_limits(s)”: Tuple with Min/Max values of pre exposure pause times in seconds

For “STEM_DETECTOR” detectors the embedded dict will additionally have the following keys:

  • “binnings”: List of supported binnings

Added in version 2.0.

get_column_valves_open()

Returns state of the column valves.

Returns:

True, if column valves are open. False, otherwise.

get_condenser_mode()

Get condenser mode

Return type:

Literal[‘PARALLEL’, ‘PROBE’]

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

get_condenser_stigmator()

Return value of condenser shift

Returns:

(x, y) tuple with condenser shift value

Added in version 1.0.10.

get_convergence_angle()

Return convergence angle (radian)

Return type:

float

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

get_dark_field_mode()

Get dark field mode.

Note

set_beam_tilt() might change this value.

Return type:

Literal[‘OFF’, ‘CARTESIAN’, ‘CONICAL]

Added in version 2.0.0.

get_defocus()

Return defocus value. The returned value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Note

On Titan 1.1 software the defocus value is the actual defocus relative to the eucentric defocus in meters. The accuracy of this value depends on the accuracy of the calibration within the microscope.

Added in version 1.0.9.

get_diffraction_shift()

Return value of diffraction shift

Returns:

(x, y) tuple with diffraction shift value

Added in version 1.0.10.

get_family()

Return product family (see ProductFamily for values): “TITAN”, “TECNAI”, …

get_illuminated_area()

Return illuminated area.

TEM scripting manual states the result is in meters, however it is unclear what is actually meant (diameter?)

Return type:

float

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

get_illumination_mode()

Get illumination mode (mini condenser setting)

Return type:

Literal[‘NANOPROBE’, ‘MICROPROBE’]

Added in version 2.0.0.

get_image_shift()

Return image shift as (x,y) tuple in meters.

Note

The accuracy of this value depends on the accuracy of the calibration within the microscope.

On FEI microscopes this corresponds to the state of “User Image Shift” (in different units though).

get_indicated_camera_length()

Return (indicated) camera length in meters in diffraction modes.

Note

The scripting manual states, that this function always returns 0, if microscope is in imaging mode. In STEM mode this function works reportedly nevertheless.

Added in version 1.0.9.

get_indicated_magnification()

Return (indicated) magnification in imaging modes.

Note

The scripting manual states, that this function always returns 0, if microscope is in diffraction mode. In STEM mode this function works reportedly nevertheless.

Note

On Titan 1.1 software this method returns 0.0 regardless of used mode. See Restrictions.

Added in version 1.0.9.

get_instrument_mode()

Get instrument mode.

Return type:

Literal[‘TEM’, ‘STEM’]

Added in version 2.0.0.

get_intensity()

Return intensity value.

The returned value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Added in version 1.0.10.

get_magnification_index()

Return index of current magnification/camera length.

Added in version 1.0.9.

get_microscope_id()

Return microscope ID.

There is no way to read this via the scripting adapter directly, thus this method uses hostname instead.

get_objective_excitation()

Return excitation of objective lens.

Added in version 1.0.9.

get_objective_stigmator()

Return value of objective shift

Returns:

(x, y) tuple with objective shift value

Added in version 1.0.10.

get_probe_defocus()

Return probe defocus (meters).

Return type:

float

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

get_projection_mode()

Return current projection mode.

Added in version 1.0.9.

get_projection_mode_string()

Return description of current projection mode. Possible return values are: “LM”, Mi”, “SA”, “Mh”, “LAD”, and “D”

Added in version 1.0.9.

get_projection_sub_mode()

Return current projection sub mode.

Added in version 1.0.10.

get_screen_current()

Get current on fluorescent screen

Returns:

Screen currrent in Amperes

Added in version 2.0.0.

get_screen_position()

Get position of fluorescent screen

Return type:

Literal[‘UP’, ‘DOWN’, ‘UNKNOWN’]

Added in version 2.0.0.

get_spot_size_index()

Get spot size index.

Return type:

int

Added in version 2.0.0.

get_stage_holder()

Return holder currently in stage (see StageHolderType)

get_stage_limits()

Returns dictionary with min/max tuples for all holder axes. The tuples are the values, the axis names are the keys. For axes “x”, “y”, “z” the unit is meters For axes “a”, “b” the unit is radians

get_stage_position()

Returns dictionary with stage position (axes names are used as keys). For axes “x”, “y”, “z” the unit is meters For axes “a”, “b” the unit is radians

get_stage_status()

Return status of stage (see StageStatus)

get_state()

Return a dictionary with state of the microscope.

Added in version 1.0.9.

Changed in version 2.0: The method was renamed from get_optics_state() to get_state()

get_stem_acquisition_param()

Return dictionary with STEM acquisition parameters.

The returned dictionary has the following keys:

  • “image_size”: Size of image (see AcqImageSize): “FULL”, “HALF”, …

  • “binning”: Binning

  • “dwell_time(s)”: Dwell time in seconds

Added in version 2.0.

Note

On Titan 1.1 software reading the parameters fails, if STEM is not available. See Restrictions.

get_stem_detector_param(name)

Return dictionary with parameters for detector name.

The returned dictionary has the following keys:

  • “brightness”: Brightness settings

  • “contrast”: Contrast setting

Added in version 2.0.

get_stem_detectors()

Return dictionary with all available stem detectors. The method will return a dict, indexed by camera name, with another dict as values.

The embedded dict will additionally have the following keys:

  • “type”: “STEM_DETECTOR”

  • “binnings”: List of supported binnings

Added in version 2.0.

get_stem_magnification()

Get STEM magnification

Return type:

float

Added in version 2.0.0.

get_stem_rotation()

Get STEM rotation (radian)

Return type:

float

Added in version 2.0.0.

get_vacuum()

Return status of the vacuum system. The method will return a dict with the following entries:

  • “status”: Status of the vacuum system (see VacuumStatus): “READY”, “OFF”, …

  • “column_valves_open”: Whether the column valves are currently open

  • “pvp_running”: Whether the PVP is running

  • “gauges(Pa)”: dict with Gauge values in Pascal (or the string “UNDERFLOW” or “OVERFLOW”)

get_version()

Return version string for temscript.

Added in version 1.0.8.

Returns:

String “major.minor.patchlevel”

get_voltage()

Return acceleration voltage in kV.

Returns:

Float with voltage

is_stem_available()

Return whether the microscope has STEM capabilities.

Return type:

bool

Added in version 2.0.0.

normalize(mode='ALL')

Normalize some or all lenses.

Possible values for lenses are:

  • “SPOTSIZE”: The C1 lens

  • “INTENSITY”: The C2 and - if present - the C3 lens

  • “CONDENSER”: C1, C2, and - if present - the C3 lens

  • “MINI_CONDENSER”: The mini condenser lens

  • “OBJECTIVE”: Objective and mini condenser lens

  • “PROJECTOR”: Projective lenses (DL, IL, P1, P2)

  • “OBJECTIVE_CONDENSER”: Objective and condenser system

  • “OBJECTIVE_PROJECTOR”: Objective and projector system

  • “ALL”: All lenses

Parameters:

mode (str) – What to normalize. If omitted, all lenses are normalized.

Added in version 1.0.9.

set_beam_blanked(mode)

Enable beam blanker

Added in version 2.0.0.

set_beam_shift(pos)

Set beam shift to position shift, which should be an (x, y) tuple, as returned for instance by get_beam_shift().

Parameters:

shift (Tuple[float, float]) – Shift value

set_beam_tilt(pos)

Set beam tilt to position tilt, which should be an (x, y) tuple, as returned for instance by get_beam_tilt().

On FEI microscopes, this will turn on dark field mode, unless (0, 0) is set. If (0, 0) is set, dark field mode is turned off.

set_camera_param(name, values, ignore_errors=None)

Set parameters for camera name. The parameters should be given as a dictionary. Allowed keys are described in the get_camera_param() method.

When ignore_errors is set and setting of a parameter fails, no error is raised. If an unknown camera name is used, an error is raised nevertheless.

Raises:

KeyError – If an unknown camera name is used.

Added in version 2.0.

Note

  • On Titan 1.1 software setting the “binning” property also changes the exposure time.

  • On Titan 1.1 software images acquired after setting the “exposure_time(s)” property might not be acquired with the new setting, even though this property reflects the new value when read.

Also see Restrictions.

set_column_valves_open(state)

Set state of the column valves. The column valves are opened, if True is passes as state

Parameters:

state (bool) – True, if column valves should be opened. False, if they should be closed.

set_condenser_mode(mode)

Set condenser mode

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

set_condenser_stigmator(value)

Set condenser stigmator.

Parameters:

value – (x, y) tuple, as returned for instance by get_condenser_stigmator().

Added in version 1.0.10.

set_convergence_angle(value)

Set convergence angle (radian).

Note

This method is only available on microscopes of the TITAN family.

..versionadded:: 2.0.0

set_dark_field_mode(mode)

Set dark field mode.

Note

set_beam_tilt() might change this value.

Added in version 2.0.0.

set_defocus(value)

Set defocus value. The value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Note

On Titan 1.1 software the defocus value is the actual defocus relative to the eucentric defocus in meters. The accuracy of this value depends on the accuracy of the calibration within the microscope.

Parameters:

value (float) – Defocus to set

Added in version 1.0.9.

set_diffraction_shift(value)

Set diffraction shift.

Parameters:

value – (x, y) tuple, as returned for instance by get_diffraction_shift().

Added in version 1.0.10.

set_illuminated_area(value)

Set illuminated area.

TEM scripting manual states the result is in meters, however it is unclear what is actually meant (diameter?)

Note

This method is only available on microscopes of the TITAN family.

..versionadded:: 2.0.0

set_illumination_mode(mode)

Set illumination mode (mini condenser setting)

Added in version 2.0.0.

set_image_shift(pos)

Set image shift to position pos, which should be an (x, y) tuple, as returned for instance by get_image_shift().

set_instrument_mode(mode)

Set instrument mode.

Added in version 2.0.0.

set_intensity(value)

Set intensity.

The value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Parameters:

value (float) – Intensity to set

Added in version 1.0.10.

set_magnification_index(index)

Set magnification / camera length index.

Parameters:

index (int) – Magnification/Camera length index

Added in version 1.0.9.

set_objective_stigmator(value)

Set objective stigmator.

Parameters:

value – (x, y) tuple, as returned for instance by get_objective_stigmator().

Added in version 1.0.10.

set_probe_defocus(value)

Set probe defocus (meters).

Note

This method is only available on microscopes of the TITAN family.

..versionadded:: 2.0.0

set_projection_mode(mode)

Set projection mode.

Parameters:

mode (Literal['DIFFRACTION', 'IMAGING']) – Projection mode: “DIFFRACTION” or “IMAGING”

Added in version 1.0.9.

Note

On Titan 1.1 software changing the mode from IMAGING to DIFFRACTION and back again changes the magnification. See Restrictions.

set_screen_position(mode)

Set position of fluorescent screen

Added in version 2.0.0.

set_spot_size_index(index)

Set spot size index.

Added in version 2.0.0.

set_stem_acquisition_param(values, ignore_errors=None)

Set parameters for STEM acquisition. The parameters should be given as a dictionary. Allowed keys are described in the get_stem_acquisition_param() method.

When ignore_errors is set and setting of a parameter fails, no error is raised.

Added in version 2.0.

set_stem_detector_param(name, values, ignore_errors=None)

Set parameters for STEM detector name. The parameters should be given as a dictionary. Allowed keys are described in the get_stem_detector_param() method.

When ignore_errors is set and setting of a parameter fails, no error is raised. If an unknown detector name is used, an error is raised nevertheless.

Raises:

KeyError – If an unknown detector name is used.

Added in version 2.0.

set_stem_magnification(value)

Set STEM magnification

Added in version 2.0.0.

set_stem_rotation(value)

Set STEM rotation (radian)

Added in version 2.0.0.

The NullMicroscope class

The NullMicroscope is a dummy replacement Microscope class, which emulates the microscope.

class temscript.NullMicroscope(wait_exposure=None, voltage=200.0)

Microscope-like class which emulates an microscope.

Parameters:
  • wait_exposure (bool) – Whether the acquire calls waits the exposure time until returning, emulating the timing of the real microscope

  • voltage (float) – High tension value the microscope report in kV

acquire(*args)

Acquire images for all detectors given as argument. The images are returned in an dict indexed by detector name.

get_beam_blanked()

Return whether the beam is blanked.

Return type:

bool

Added in version 2.0.0.

get_beam_shift()

Return beam shift as (x,y) tuple in meters.

Note

The accuracy of this value depends on the accuracy of the calibration within the microscope.

On FEI microscopes this corresponds to the state of “User Beam Shift” (in different units though).

get_beam_tilt()

Return beam tilt as (x, y) tuple.

The units this is returned in are radians. The accuracy of ths value depends on the accuracy of the calibration within the microscope and thus is better not to be trusted blindly.

On FEI microscopes this corresponds to the state of “DF Tilt”, however the tilt is always returned in cartesian coordinates.

get_camera_param(name)

Return dictionary with parameters for camera name.

The returned dictionary has the following keys:

  • “image_size”: Size of image (see AcqImageSize): “FULL”, “HALF”, …

  • “binning”: Binning

  • “exposure(s)”: Exposure time in seconds

  • “correction”: Correction mode (see AcqImageCorrection)

  • “exposure_mode”: Exposure mode (see AcqExposureMode)

  • “shutter_mode”: Shutter mode (see AcqShutterMode)

  • “pre_exposure(s)”: Pre exposure time in seconds

  • “pre_exposure_pause(s)”: Pre exposure pause time in seconds

Added in version 2.0.

Note

On Titan 1.1 software the “exposure_time(s)” value might not reflect the correct exposure time. See Restrictions.

get_cameras()

Return dictionary with all available cameras. The method will return a dict, indexed by camera name, with another dict as values.

For cameras the embedded dict will additionally have the following keys:

  • “type”: “CAMERA”

  • “height”: Height of the detector

  • “width”: Width of the detector

  • “pixel_size(um)”: Pixel size in micrometers

  • “binnings”: List of supported binnings

  • “shutter_modes”: List of supported shutter modes (see AcqShutterMode)

  • “pre_exposure_limits(s)”: Tuple with Min/Max values of pre exposure times in seconds

  • “pre_exposure_pause_limits(s)”: Tuple with Min/Max values of pre exposure pause times in seconds

For “STEM_DETECTOR” detectors the embedded dict will additionally have the following keys:

  • “binnings”: List of supported binnings

Added in version 2.0.

get_column_valves_open()

Returns state of the column valves.

Returns:

True, if column valves are open. False, otherwise.

get_condenser_mode()

Get condenser mode

Return type:

Literal[‘PARALLEL’, ‘PROBE’]

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

get_condenser_stigmator()

Return value of condenser shift

Returns:

(x, y) tuple with condenser shift value

Added in version 1.0.10.

get_convergence_angle()

Return convergence angle (radian)

Return type:

float

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

get_dark_field_mode()

Get dark field mode.

Note

set_beam_tilt() might change this value.

Return type:

Literal[‘OFF’, ‘CARTESIAN’, ‘CONICAL]

Added in version 2.0.0.

get_defocus()

Return defocus value. The returned value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Note

On Titan 1.1 software the defocus value is the actual defocus relative to the eucentric defocus in meters. The accuracy of this value depends on the accuracy of the calibration within the microscope.

Added in version 1.0.9.

get_diffraction_shift()

Return value of diffraction shift

Returns:

(x, y) tuple with diffraction shift value

Added in version 1.0.10.

get_family()

Return product family (see ProductFamily for values): “TITAN”, “TECNAI”, …

get_illuminated_area()

Return illuminated area.

TEM scripting manual states the result is in meters, however it is unclear what is actually meant (diameter?)

Return type:

float

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

get_illumination_mode()

Get illumination mode (mini condenser setting)

Return type:

Literal[‘NANOPROBE’, ‘MICROPROBE’]

Added in version 2.0.0.

get_image_shift()

Return image shift as (x,y) tuple in meters.

Note

The accuracy of this value depends on the accuracy of the calibration within the microscope.

On FEI microscopes this corresponds to the state of “User Image Shift” (in different units though).

get_indicated_camera_length()

Return (indicated) camera length in meters in diffraction modes.

Note

The scripting manual states, that this function always returns 0, if microscope is in imaging mode. In STEM mode this function works reportedly nevertheless.

Added in version 1.0.9.

get_indicated_magnification()

Return (indicated) magnification in imaging modes.

Note

The scripting manual states, that this function always returns 0, if microscope is in diffraction mode. In STEM mode this function works reportedly nevertheless.

Note

On Titan 1.1 software this method returns 0.0 regardless of used mode. See Restrictions.

Added in version 1.0.9.

get_instrument_mode()

Get instrument mode.

Return type:

Literal[‘TEM’, ‘STEM’]

Added in version 2.0.0.

get_intensity()

Return intensity value.

The returned value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Added in version 1.0.10.

get_magnification_index()

Return index of current magnification/camera length.

Added in version 1.0.9.

get_microscope_id()

Return microscope ID.

There is no way to read this via the scripting adapter directly, thus this method uses hostname instead.

get_objective_excitation()

Return excitation of objective lens.

Added in version 1.0.9.

get_objective_stigmator()

Return value of objective shift

Returns:

(x, y) tuple with objective shift value

Added in version 1.0.10.

get_probe_defocus()

Return probe defocus (meters).

Return type:

float

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

get_projection_mode()

Return current projection mode.

Added in version 1.0.9.

get_projection_mode_string()

Return description of current projection mode. Possible return values are: “LM”, Mi”, “SA”, “Mh”, “LAD”, and “D”

Added in version 1.0.9.

get_projection_sub_mode()

Return current projection sub mode.

Added in version 1.0.10.

get_screen_current()

Get current on fluorescent screen

Returns:

Screen currrent in Amperes

Added in version 2.0.0.

get_screen_position()

Get position of fluorescent screen

Return type:

Literal[‘UP’, ‘DOWN’, ‘UNKNOWN’]

Added in version 2.0.0.

get_spot_size_index()

Get spot size index.

Return type:

int

Added in version 2.0.0.

get_stage_holder()

Return holder currently in stage (see StageHolderType)

get_stage_limits()

Returns dictionary with min/max tuples for all holder axes. The tuples are the values, the axis names are the keys. For axes “x”, “y”, “z” the unit is meters For axes “a”, “b” the unit is radians

get_stage_position()

Returns dictionary with stage position (axes names are used as keys). For axes “x”, “y”, “z” the unit is meters For axes “a”, “b” the unit is radians

get_stage_status()

Return status of stage (see StageStatus)

get_stem_acquisition_param()

Return dictionary with STEM acquisition parameters.

The returned dictionary has the following keys:

  • “image_size”: Size of image (see AcqImageSize): “FULL”, “HALF”, …

  • “binning”: Binning

  • “dwell_time(s)”: Dwell time in seconds

Added in version 2.0.

Note

On Titan 1.1 software reading the parameters fails, if STEM is not available. See Restrictions.

get_stem_detector_param(name)

Return dictionary with parameters for detector name.

The returned dictionary has the following keys:

  • “brightness”: Brightness settings

  • “contrast”: Contrast setting

Added in version 2.0.

get_stem_detectors()

Return dictionary with all available stem detectors. The method will return a dict, indexed by camera name, with another dict as values.

The embedded dict will additionally have the following keys:

  • “type”: “STEM_DETECTOR”

  • “binnings”: List of supported binnings

Added in version 2.0.

get_stem_magnification()

Get STEM magnification

Return type:

float

Added in version 2.0.0.

get_stem_rotation()

Get STEM rotation (radian)

Return type:

float

Added in version 2.0.0.

get_vacuum()

Return status of the vacuum system. The method will return a dict with the following entries:

  • “status”: Status of the vacuum system (see VacuumStatus): “READY”, “OFF”, …

  • “column_valves_open”: Whether the column valves are currently open

  • “pvp_running”: Whether the PVP is running

  • “gauges(Pa)”: dict with Gauge values in Pascal (or the string “UNDERFLOW” or “OVERFLOW”)

get_version()

Return version string for temscript.

Added in version 1.0.8.

Returns:

String “major.minor.patchlevel”

get_voltage()

Return acceleration voltage in kV.

Returns:

Float with voltage

is_stem_available()

Return whether the microscope has STEM capabilities.

Return type:

bool

Added in version 2.0.0.

normalize(mode='ALL')

Normalize some or all lenses.

Possible values for lenses are:

  • “SPOTSIZE”: The C1 lens

  • “INTENSITY”: The C2 and - if present - the C3 lens

  • “CONDENSER”: C1, C2, and - if present - the C3 lens

  • “MINI_CONDENSER”: The mini condenser lens

  • “OBJECTIVE”: Objective and mini condenser lens

  • “PROJECTOR”: Projective lenses (DL, IL, P1, P2)

  • “OBJECTIVE_CONDENSER”: Objective and condenser system

  • “OBJECTIVE_PROJECTOR”: Objective and projector system

  • “ALL”: All lenses

Parameters:

mode (str) – What to normalize. If omitted, all lenses are normalized.

Added in version 1.0.9.

set_beam_blanked(mode)

Enable beam blanker

Added in version 2.0.0.

set_beam_shift(pos)

Set beam shift to position shift, which should be an (x, y) tuple, as returned for instance by get_beam_shift().

Parameters:

shift (Tuple[float, float]) – Shift value

set_beam_tilt(tilt)

Set beam tilt to position tilt, which should be an (x, y) tuple, as returned for instance by get_beam_tilt().

On FEI microscopes, this will turn on dark field mode, unless (0, 0) is set. If (0, 0) is set, dark field mode is turned off.

set_camera_param(name, param, ignore_errors=False)

Set parameters for camera name. The parameters should be given as a dictionary. Allowed keys are described in the get_camera_param() method.

When ignore_errors is set and setting of a parameter fails, no error is raised. If an unknown camera name is used, an error is raised nevertheless.

Raises:

KeyError – If an unknown camera name is used.

Added in version 2.0.

Note

  • On Titan 1.1 software setting the “binning” property also changes the exposure time.

  • On Titan 1.1 software images acquired after setting the “exposure_time(s)” property might not be acquired with the new setting, even though this property reflects the new value when read.

Also see Restrictions.

set_column_valves_open(state)

Set state of the column valves. The column valves are opened, if True is passes as state

Parameters:

state (bool) – True, if column valves should be opened. False, if they should be closed.

set_condenser_mode(mode)

Set condenser mode

Note

This method is only available on microscopes of the TITAN family.

Added in version 2.0.0.

set_condenser_stigmator(value)

Set condenser stigmator.

Parameters:

value – (x, y) tuple, as returned for instance by get_condenser_stigmator().

Added in version 1.0.10.

set_convergence_angle(value)

Set convergence angle (radian).

Note

This method is only available on microscopes of the TITAN family.

..versionadded:: 2.0.0

set_dark_field_mode(mode)

Set dark field mode.

Note

set_beam_tilt() might change this value.

Added in version 2.0.0.

set_defocus(value)

Set defocus value. The value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Note

On Titan 1.1 software the defocus value is the actual defocus relative to the eucentric defocus in meters. The accuracy of this value depends on the accuracy of the calibration within the microscope.

Parameters:

value (float) – Defocus to set

Added in version 1.0.9.

set_diffraction_shift(value)

Set diffraction shift.

Parameters:

value – (x, y) tuple, as returned for instance by get_diffraction_shift().

Added in version 1.0.10.

set_illuminated_area(value)

Set illuminated area.

TEM scripting manual states the result is in meters, however it is unclear what is actually meant (diameter?)

Note

This method is only available on microscopes of the TITAN family.

..versionadded:: 2.0.0

set_illumination_mode(mode)

Set illumination mode (mini condenser setting)

Added in version 2.0.0.

set_image_shift(pos)

Set image shift to position pos, which should be an (x, y) tuple, as returned for instance by get_image_shift().

set_instrument_mode(mode)

Set instrument mode.

Added in version 2.0.0.

set_intensity(value)

Set intensity.

The value is in arbitrary units. Increasing values go into overfocus direction, negative values into underfocus direction.

Parameters:

value (float) – Intensity to set

Added in version 1.0.10.

set_magnification_index(index)

Set magnification / camera length index.

Parameters:

index (int) – Magnification/Camera length index

Added in version 1.0.9.

set_objective_stigmator(value)

Set objective stigmator.

Parameters:

value – (x, y) tuple, as returned for instance by get_objective_stigmator().

Added in version 1.0.10.

set_probe_defocus(value)

Set probe defocus (meters).

Note

This method is only available on microscopes of the TITAN family.

..versionadded:: 2.0.0

set_projection_mode(mode)

Set projection mode.

Parameters:

mode (Literal['DIFFRACTION', 'IMAGING']) – Projection mode: “DIFFRACTION” or “IMAGING”

Added in version 1.0.9.

Note

On Titan 1.1 software changing the mode from IMAGING to DIFFRACTION and back again changes the magnification. See Restrictions.

set_screen_position(mode)

Set position of fluorescent screen

Added in version 2.0.0.

set_spot_size_index(index)

Set spot size index.

Added in version 2.0.0.

set_stem_acquisition_param(param, ignore_errors=False)

Set parameters for STEM acquisition. The parameters should be given as a dictionary. Allowed keys are described in the get_stem_acquisition_param() method.

When ignore_errors is set and setting of a parameter fails, no error is raised.

Added in version 2.0.

set_stem_detector_param(name, values, ignore_errors=False)

Set parameters for STEM detector name. The parameters should be given as a dictionary. Allowed keys are described in the get_stem_detector_param() method.

When ignore_errors is set and setting of a parameter fails, no error is raised. If an unknown detector name is used, an error is raised nevertheless.

Raises:

KeyError – If an unknown detector name is used.

Added in version 2.0.

set_stem_magnification(value)

Set STEM magnification

Added in version 2.0.0.

set_stem_rotation(value)

Set STEM rotation (radian)

Added in version 2.0.0.