Skip to content

Lenses

Classes

Brightness(tem)

Bases: Lens

Control object for the Brightness (CL3)

Source code in src/instamatic/microscope/components/lenses.py
91
92
93
94
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/microscope/components/lenses.py
46
47
48
49
50
def __init__(self, tem):
    super().__init__(tem=tem)
    self._getter = self._tem.getDiffFocus
    self._setter = self._tem.setDiffFocus
    self.is_defocused = False

Methods:

defocus(offset)

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

Source code in src/instamatic/microscope/components/lenses.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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/microscope/components/lenses.py
78
79
80
81
82
83
84
85
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/microscope/components/lenses.py
52
53
54
55
56
57
58
59
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/microscope/components/lenses.py
10
11
12
13
14
15
def __init__(self, tem: MicroscopeBase):
    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/microscope/components/lenses.py
110
111
112
113
114
115
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

Methods:

get_ranges()

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

Source code in src/instamatic/microscope/components/lenses.py
146
147
148
149
def get_ranges(self) -> dict:
    """Runs through all modes and fetches all the magnification settings
    possible on the microscope."""
    return self._tem.getMagnificationRanges()