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.

abstract acquire(*args)

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

abstract get_beam_blanked()

Return whether the beam is blanked.

Return type

bool

New in version 2.0.0.

abstract 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).

abstract 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.

abstract 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

New in version 2.0.

Note

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

abstract 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

New in version 2.0.

abstract get_column_valves_open()

Returns state of the column valves.

Returns

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

abstract get_condenser_mode()

Get condenser mode

Return type

Literal[‘PARALLEL’, ‘PROBE’]

Note

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

New in version 2.0.0.

abstract get_condenser_stigmator()

Return value of condenser shift

Returns

(x, y) tuple with condenser shift value

New in version 1.0.10.

abstract get_convergence_angle()

Return convergence angle (radian)

Return type

float

Note

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

New in version 2.0.0.

abstract get_dark_field_mode()

Get dark field mode.

Note

set_beam_tilt() might change this value.

Return type

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

New in version 2.0.0.

abstract 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.

New 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.

abstract get_diffraction_shift()

Return value of diffraction shift

Returns

(x, y) tuple with diffraction shift value

New in version 1.0.10.

abstract get_family()

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

abstract 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.

New in version 2.0.0.

abstract get_illumination_mode()

Get illumination mode (mini condenser setting)

Return type

Literal[‘NANOPROBE’, ‘MICROPROBE’]

New in version 2.0.0.

abstract 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).

abstract get_indicated_camera_length()

Return (indicated) camera length in meters in diffraction modes. If microscope is in imaging mode, 0 is returned.

New in version 1.0.9.

abstract get_indicated_magnification()

Return (indicated) magnification in imaging modes. If microscope is in diffraction mode, 0 is returned.

Note

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

New in version 1.0.9.

abstract get_instrument_mode()

Get instrument mode.

Return type

Literal[‘TEM’, ‘STEM’]

New in version 2.0.0.

abstract get_intensity()

Return intensity value.

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

New in version 1.0.10.

abstract get_magnification_index()

Return index of current magnification/camera length.

New in version 1.0.9.

abstract get_microscope_id()

Return microscope ID.

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

abstract get_objective_excitation()

Return excitation of objective lens.

New in version 1.0.9.

abstract get_objective_stigmator()

Return value of objective shift

Returns

(x, y) tuple with objective shift value

New in version 1.0.10.

get_optics_state()

Return a dictionary with state of microscope optics.

New in version 1.0.9.

Deprecated since version 2.0: use get_state() instead.

abstract get_probe_defocus()

Return probe defocus (meters).

Return type

float

Note

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

New in version 2.0.0.

abstract get_projection_mode()

Return current projection mode.

New in version 1.0.9.

abstract get_projection_mode_string()

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

New in version 1.0.9.

abstract get_projection_sub_mode()

Return current projection sub mode.

New in version 1.0.10.

abstract get_screen_current()

Get current on fluorescent screen

Returns

Screen currrent in Amperes

New in version 2.0.0.

abstract get_screen_position()

Get position of fluorescent screen

Return type

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

New in version 2.0.0.

abstract get_spot_size_index()

Get spot size index.

Return type

int

New in version 2.0.0.

abstract get_stage_holder()

Return holder currently in stage (see StageHolderType)

abstract 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

abstract 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

abstract get_stage_status()

Return status of stage (see StageStatus)

get_state()

Return a dictionary with state of the microscope.

New in version 1.0.9.

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

abstract 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

New in version 2.0.

Note

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

abstract 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

New in version 2.0.

abstract 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

New in version 2.0.

abstract get_stem_magnification()

Get STEM magnification

Return type

float

New in version 2.0.0.

abstract get_stem_rotation()

Get STEM rotation (radian)

Return type

float

New in version 2.0.0.

abstract 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”)

abstract get_version()

Return version string for temscript.

New in version 1.0.8.

Returns

String “major.minor.patchlevel”

abstract get_voltage()

Return acceleration voltage in kV.

Returns

Float with voltage

abstract is_stem_available()

Return whether the microscope has STEM capabilities.

Return type

bool

New in version 2.0.0.

abstract 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.

New in version 1.0.9.

abstract set_beam_blanked(mode)

Enable beam blanker

New in version 2.0.0.

abstract 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

abstract 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.

abstract 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.

New 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.

abstract 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.

abstract set_condenser_mode(mode)

Set condenser mode

Note

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

New in version 2.0.0.

abstract set_condenser_stigmator(value)

Set condenser stigmator.

Parameters

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

New in version 1.0.10.

abstract set_convergence_angle(value)

Set convergence angle (radian).

Note

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

..versionadded:: 2.0.0

abstract set_dark_field_mode(mode)

Set dark field mode.

Note

set_beam_tilt() might change this value.

New in version 2.0.0.

abstract 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

New 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.

abstract set_diffraction_shift(value)

Set diffraction shift.

Parameters

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

New in version 1.0.10.

abstract 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

abstract set_illumination_mode(mode)

Set illumination mode (mini condenser setting)

New in version 2.0.0.

abstract 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().

abstract set_instrument_mode(mode)

Set instrument mode.

New in version 2.0.0.

abstract 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

New in version 1.0.10.

abstract set_magnification_index(index)

Set magnification / camera length index.

Parameters

index (int) – Magnification/Camera length index

New in version 1.0.9.

abstract set_objective_stigmator(value)

Set objective stigmator.

Parameters

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

New in version 1.0.10.

abstract set_probe_defocus(value)

Set probe defocus (meters).

Note

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

..versionadded:: 2.0.0

abstract set_projection_mode(mode)

Set projection mode.

Parameters

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

New 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.

abstract set_screen_position(mode)

Set position of fluorescent screen

New in version 2.0.0.

abstract set_spot_size_index(index)

Set spot size index.

New 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.

abstract 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.

New in version 2.0.

abstract 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.

New in version 2.0.

abstract set_stem_magnification(value)

Set STEM magnification

New in version 2.0.0.

abstract set_stem_rotation(value)

Set STEM rotation (radian)

New 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

New 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

New 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

New 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.

New in version 2.0.0.

get_condenser_stigmator()

Return value of condenser shift

Returns

(x, y) tuple with condenser shift value

New 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.

New 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]

New 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.

New in version 1.0.9.

get_diffraction_shift()

Return value of diffraction shift

Returns

(x, y) tuple with diffraction shift value

New 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.

New in version 2.0.0.

get_illumination_mode()

Get illumination mode (mini condenser setting)

Return type

Literal[‘NANOPROBE’, ‘MICROPROBE’]

New 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. If microscope is in imaging mode, 0 is returned.

New in version 1.0.9.

get_indicated_magnification()

Return (indicated) magnification in imaging modes. If microscope is in diffraction mode, 0 is returned.

Note

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

New in version 1.0.9.

get_instrument_mode()

Get instrument mode.

Return type

Literal[‘TEM’, ‘STEM’]

New 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.

New in version 1.0.10.

get_magnification_index()

Return index of current magnification/camera length.

New 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.

New in version 1.0.9.

get_objective_stigmator()

Return value of objective shift

Returns

(x, y) tuple with objective shift value

New 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.

New in version 2.0.0.

get_projection_mode()

Return current projection mode.

New 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”

New in version 1.0.9.

get_projection_sub_mode()

Return current projection sub mode.

New in version 1.0.10.

get_screen_current()

Get current on fluorescent screen

Returns

Screen currrent in Amperes

New in version 2.0.0.

get_screen_position()

Get position of fluorescent screen

Return type

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

New in version 2.0.0.

get_spot_size_index()

Get spot size index.

Return type

int

New 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.

New 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

New 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

New 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

New in version 2.0.

get_stem_magnification()

Get STEM magnification

Return type

float

New in version 2.0.0.

get_stem_rotation()

Get STEM rotation (radian)

Return type

float

New 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.

New 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

New 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.

New in version 1.0.9.

set_beam_blanked(mode)

Enable beam blanker

New 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.

New 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.

New 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().

New 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.

New 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

New 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().

New 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)

New 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.

New 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

New in version 1.0.10.

set_magnification_index(index)

Set magnification / camera length index.

Parameters

index (int) – Magnification/Camera length index

New 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().

New 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”

New 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

New in version 2.0.0.

set_spot_size_index(index)

Set spot size index.

New 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.

New 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.

New in version 2.0.

set_stem_magnification(value)

Set STEM magnification

New in version 2.0.0.

set_stem_rotation(value)

Set STEM rotation (radian)

New 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

New 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

New 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

New 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.

New in version 2.0.0.

get_condenser_stigmator()

Return value of condenser shift

Returns

(x, y) tuple with condenser shift value

New 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.

New 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]

New 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.

New in version 1.0.9.

get_diffraction_shift()

Return value of diffraction shift

Returns

(x, y) tuple with diffraction shift value

New 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.

New in version 2.0.0.

get_illumination_mode()

Get illumination mode (mini condenser setting)

Return type

Literal[‘NANOPROBE’, ‘MICROPROBE’]

New 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. If microscope is in imaging mode, 0 is returned.

New in version 1.0.9.

get_indicated_magnification()

Return (indicated) magnification in imaging modes. If microscope is in diffraction mode, 0 is returned.

Note

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

New in version 1.0.9.

get_instrument_mode()

Get instrument mode.

Return type

Literal[‘TEM’, ‘STEM’]

New 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.

New in version 1.0.10.

get_magnification_index()

Return index of current magnification/camera length.

New 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.

New in version 1.0.9.

get_objective_stigmator()

Return value of objective shift

Returns

(x, y) tuple with objective shift value

New 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.

New in version 2.0.0.

get_projection_mode()

Return current projection mode.

New 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”

New in version 1.0.9.

get_projection_sub_mode()

Return current projection sub mode.

New in version 1.0.10.

get_screen_current()

Get current on fluorescent screen

Returns

Screen currrent in Amperes

New in version 2.0.0.

get_screen_position()

Get position of fluorescent screen

Return type

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

New in version 2.0.0.

get_spot_size_index()

Get spot size index.

Return type

int

New 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

New 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

New 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

New in version 2.0.

get_stem_magnification()

Get STEM magnification

Return type

float

New in version 2.0.0.

get_stem_rotation()

Get STEM rotation (radian)

Return type

float

New 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.

New 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

New 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.

New in version 1.0.9.

set_beam_blanked(mode)

Enable beam blanker

New 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.

New 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.

New 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().

New 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.

New 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

New 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().

New 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)

New 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.

New 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

New in version 1.0.10.

set_magnification_index(index)

Set magnification / camera length index.

Parameters

index (int) – Magnification/Camera length index

New 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().

New 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”

New 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

New in version 2.0.0.

set_spot_size_index(index)

Set spot size index.

New 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.

New 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.

New in version 2.0.

set_stem_magnification(value)

Set STEM magnification

New in version 2.0.0.

set_stem_rotation(value)

Set STEM rotation (radian)

New in version 2.0.0.