Skip to content

Lenses

Classes

Brightness(tem)

Bases: Lens

Control object for the Brightness (CL3)

Source code in src/instamatic/TEMController/lenses.py
86
87
88
89
def __init__(self, tem):
    super().__init__(tem=tem)
    self._getter = self._tem.getBrightness
    self._setter = self._tem.setBrightness

DiffFocus(tem)

Bases: Lens

Control the Difffraction focus lens (IL1)

Source code in src/instamatic/TEMController/lenses.py
41
42
43
44
45
def __init__(self, tem):
    super().__init__(tem=tem)
    self._getter = self._tem.getDiffFocus
    self._setter = self._tem.setDiffFocus
    self.is_defocused = False

Functions

defocus(offset)

Apply a defocus to the IL1 lens, use .refocus to restore the previous setting.

Source code in src/instamatic/TEMController/lenses.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def defocus(self, offset):
    """Apply a defocus to the IL1 lens, use `.refocus` to restore the
    previous setting."""
    if self.is_defocused:
        raise TEMControllerError(f'{self.__class__.__name__} is already defocused!')

    try:
        self._focused_value = current = self.get()
    except ValueError:
        self._tem.setFunctionMode('diff')
        self._focused_value = current = self.get()

    target = current + offset
    self.set(target)
    self.is_defocused = True
    print(f'Defocusing from {current} to {target}')
refocus()

Restore the IL1 lens to the focused condition a defocus has been applied using .defocus

Source code in src/instamatic/TEMController/lenses.py
73
74
75
76
77
78
79
80
def refocus(self):
    """Restore the IL1 lens to the focused condition a defocus has been
    applied using `.defocus`"""
    if self.is_defocused:
        target = self._focused_value
        self.set(target)
        self.is_defocused = False
        print(f'Refocusing to {target}')
set(value, confirm_mode=True)

confirm_mode: verify that TEM is set to the correct mode ('diff').

IL1 maps to different values in image and diffraction mode. Turning it off results in a 2x speed-up in the call, but it will silently fail if the TEM is in the wrong mode.

Source code in src/instamatic/TEMController/lenses.py
47
48
49
50
51
52
53
54
def set(self, value: int, confirm_mode: bool = True):
    """confirm_mode: verify that TEM is set to the correct mode ('diff').

    IL1 maps to different values in image and diffraction mode.
    Turning it off results in a 2x speed-up in the call, but it will
    silently fail if the TEM is in the wrong mode.
    """
    self._setter(value, confirm_mode=confirm_mode)

Lens(tem)

Generic microscope lens object defined by one value Must be subclassed to set the self._getter, self._setter functions.

Source code in src/instamatic/TEMController/lenses.py
 5
 6
 7
 8
 9
10
def __init__(self, tem):
    super().__init__()
    self._tem = tem
    self._getter = None
    self._setter = None
    self.key = 'lens'

Magnification(tem)

Bases: Lens

Magnification control.

The magnification can be set directly, or by passing the corresponding index

Source code in src/instamatic/TEMController/lenses.py
105
106
107
108
109
110
def __init__(self, tem):
    super().__init__(tem=tem)
    self._getter = self._tem.getMagnification
    self._setter = self._tem.setMagnification
    self._indexgetter = self._tem.getMagnificationIndex
    self._indexsetter = self._tem.setMagnificationIndex

Functions

get_ranges()

Runs through all modes and fetches all the magnification settings possible on the microscope.

Source code in src/instamatic/TEMController/lenses.py
141
142
143
144
def get_ranges(self) -> dict:
    """Runs through all modes and fetches all the magnification settings
    possible on the microscope."""
    return self._tem.getMagnificationRanges()