Skip to content

States

Classes

Beam(tem)

Bases: State

Control for the beam blanker.

Source code in src/instamatic/TEMController/states.py
31
32
33
34
35
def __init__(self, tem):
    super().__init__(tem=tem)
    self._setter = self._tem.setBeamBlank
    self._getter = self._tem.isBeamBlanked
    self._states = 'unblanked', 'blanked'

Attributes

is_blanked: bool property

Return the status of the beam blanker as a bool

state property

Return the status of the beam blanker as a str (on/off)

Functions

blank(delay=0.0)

Turn the beamblank on, optionally wait for delay in ms to allow the beam to settle.

Source code in src/instamatic/TEMController/states.py
47
48
49
50
51
52
def blank(self, delay: float = 0.0) -> None:
    """Turn the beamblank on, optionally wait for `delay` in ms to allow
    the beam to settle."""
    self._setter(True)
    if delay:
        time.sleep(delay)
get()

Get current state of the beam.

Source code in src/instamatic/TEMController/states.py
67
68
69
def get(self) -> str:
    """Get current state of the beam."""
    return self._states[self.is_blanked]
set(state, delay=0.0)

Set state of the beam, with optional delay in ms.

Source code in src/instamatic/TEMController/states.py
61
62
63
64
65
def set(self, state: str, delay: float = 0.0):
    """Set state of the beam, with optional delay in ms."""
    index = self._states.index(state)
    f = (self.unblank, self.blank)[index]
    f(delay=delay)
unblank(delay=0.0)

Turn the beamblank off, optionally wait for delay in ms to allow the beam to settle.

Source code in src/instamatic/TEMController/states.py
54
55
56
57
58
59
def unblank(self, delay: float = 0.0) -> None:
    """Turn the beamblank off, optionally wait for `delay` in ms to allow
    the beam to settle."""
    self._setter(False)
    if delay:
        time.sleep(delay)

Mode(tem)

Bases: State

Control for the magnification mode.

Source code in src/instamatic/TEMController/states.py
75
76
77
78
def __init__(self, tem):
    super().__init__(tem=tem)
    self._setter = self._tem.setFunctionMode
    self._getter = self._tem.getFunctionMode

Attributes

state: str property

Return magnification mode.

Functions

get()

Returns the function mode.

Source code in src/instamatic/TEMController/states.py
89
90
91
def get(self) -> str:
    """Returns the function mode."""
    return self._getter()
set(mode)

Set the function mode.

Source code in src/instamatic/TEMController/states.py
85
86
87
def set(self, mode: str) -> None:
    """Set the function mode."""
    self._setter(mode)

Screen(tem)

Bases: State

Control for the fluorescence screen.

Source code in src/instamatic/TEMController/states.py
 97
 98
 99
100
101
102
def __init__(self, tem):
    super().__init__(tem=tem)
    self._setter = self._tem.setScreenPosition
    self._getter = self._tem.getScreenPosition
    self._DOWN = 'down'
    self._UP = 'up'

Attributes

is_up: bool property

Return the position of the screen as a bool

state: str property

Return the position of the screen as a str

Functions

down()

Lower the fluorescence screen.

Source code in src/instamatic/TEMController/states.py
118
119
120
def down(self) -> None:
    """Lower the fluorescence screen."""
    self.set(self._DOWN)
get()

Get the position of the fluorescence screen.

Source code in src/instamatic/TEMController/states.py
122
123
124
def get(self) -> str:
    """Get the position of the fluorescence screen."""
    return self._getter()
set(state)

Set the position of the fluorescence screen (up/down).

Source code in src/instamatic/TEMController/states.py
126
127
128
def set(self, state: str) -> None:
    """Set the position of the fluorescence screen (up/down)."""
    self._setter(state)
up()

Raise the fluorescence screen.

Source code in src/instamatic/TEMController/states.py
114
115
116
def up(self) -> None:
    """Raise the fluorescence screen."""
    self.set(self._UP)

State(tem)

Generic class for describing microscope state objects.

Source code in src/instamatic/TEMController/states.py
 7
 8
 9
10
11
def __init__(self, tem):
    super().__init__()
    self._tem = tem
    self._getter = None
    self._setter = None

Attributes

name: str property

Return name of the state control.

Functions

__eq__(other)

Allow str comparison.

Source code in src/instamatic/TEMController/states.py
16
17
18
19
20
def __eq__(self, other):
    """Allow `str` comparison."""
    if isinstance(other, str):
        return self.state == other
    return False