ophyd_async.sim#

Some simulated devices to be used in tutorials and testing.

Package Contents#

Classes#

SimMotor

For usage when simulating a motor.

SimStage

A simulated sample stage with X and Y movables.

PatternGenerator

Generates pattern images in files.

SimPointDetector

Simalutes a point detector with multiple channels.

SimBlobDetector

Simulates a detector and writes Blobs to file.

VerticalMirror

Common base class for all Ophyd Async Devices.

HorizontalMirror

Common base class for all Ophyd Async Devices.

HorizontalMirrorDerived

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

TwoJackTransform

Baseclass for bidirectional transforms for Derived Signals.

TwoJackDerived

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

TwoJackRaw

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

API#

class ophyd_async.sim.SimMotor(name: str = '', instant: bool = True, initial_value: float = 0.0, units: str = 'mm')[source]#

Bases: ophyd_async.core.StandardReadable, ophyd_async.core.StandardMovable[float]

For usage when simulating a motor.

movable_logic()#

The logic object that describes how this device moves.

This is intentionally public so that mock helpers (e.g. InstantMovableMock) and subclasses can access the setpoint and readback signals directly. Subclasses must implement this as a @cached_property that returns a MovableLogic instance.

async prepare(value: FlyMotorInfo)[source]#

Calculate run-up and move there, setting fly velocity when there.

async kickoff()[source]#

Begin moving motor from prepared position to final position.

complete() WatchableAsyncStatus[source]#

Mark as complete once motor reaches completed position.

class ophyd_async.sim.SimStage(pattern_generator: PatternGenerator, name='')[source]#

Bases: ophyd_async.core.StandardReadable

A simulated sample stage with X and Y movables.

stage()[source]#

Stage the motors and report the position to the pattern generator.

unstage()[source]#

Unstage the motors and remove the position subscription.

class ophyd_async.sim.PatternGenerator(sleep=asyncio.sleep)[source]#

Generates pattern images in files.

set_x(x: float)[source]#
set_y(y: float)[source]#
generate_point(channel: int = 1, high_energy: bool = False) float[source]#

Make a point between 0 and 1 based on x and y.

open_file(path: PurePath, width: int, height: int)[source]#
setup_acquisition_parameters(exposure: float, period: float, number_of_frames: int)[source]#
async write_images_to_file()[source]#
close_file()[source]#
class ophyd_async.sim.SimPointDetector(pattern_generator: PatternGenerator | None, num_channels: int = 3, name: str = '')[source]#

Bases: ophyd_async.core.StandardReadable

Simalutes a point detector with multiple channels.

async trigger()[source]#
class ophyd_async.sim.SimBlobDetector(path_provider: PathProvider, pattern_generator: PatternGenerator | None = None, config_sigs: Sequence[SignalR] = (), name: str = '')[source]#

Bases: ophyd_async.core.StandardDetector

Simulates a detector and writes Blobs to file.

class ophyd_async.sim.VerticalMirror(name='')[source]#

Bases: ophyd_async.core.Device, bluesky.protocols.Movable[ophyd_async.sim._mirror_vertical.TwoJackDerived]

Common base class for all Ophyd Async Devices.

Parameters:
  • name – Optional name of the Device

  • connector – Optional DeviceConnector instance to use at connect()

async set(derived: TwoJackDerived) None[source]#
class ophyd_async.sim.HorizontalMirror(name='')[source]#

Bases: ophyd_async.core.Device, bluesky.protocols.Movable

Common base class for all Ophyd Async Devices.

Parameters:
  • name – Optional name of the Device

  • connector – Optional DeviceConnector instance to use at connect()

async set(value: HorizontalMirrorDerived) None[source]#
class ophyd_async.sim.HorizontalMirrorDerived[source]#

Bases: typing.TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

x: float#

None

roll: float#

None

class ophyd_async.sim.TwoJackTransform(/, **data: Any)[source]#

Bases: ophyd_async.core.Transform

Baseclass for bidirectional transforms for Derived Signals.

Subclass and add:

  • type hinted parameters that should be fetched from Signals

  • a raw_to_derived method that takes the elements of RawT and returns a DerivedT

  • a derived_to_raw method that takes the elements of DerivedT and returns a RawT

Example:

class MyRaw(TypedDict):
    raw1: float
    raw2: float

class MyDerived(TypedDict):
    derived1: float
    derived2: float

class MyTransform(Transform):
    param1: float

    def raw_to_derived(self, *, raw1: float, raw2: float) -> MyDerived:
        derived1, derived2 = some_maths(self.param1, raw1, raw2)
        return MyDerived(derived1=derived1, derived2=derived2)

    def derived_to_raw(self, *, derived1: float, derived2: float) -> MyRaw:
        raw1, raw2 = some_inverse_maths(self.param1, derived1, derived2)
        return MyRaw(raw1=raw1, raw2=raw2)
distance: float#

None

raw_to_derived(*, jack1: float, jack2: float) TwoJackDerived[source]#
derived_to_raw(*, height: float, angle: float) TwoJackRaw[source]#
class ophyd_async.sim.TwoJackDerived[source]#

Bases: typing.TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

height: float#

None

angle: float#

None

class ophyd_async.sim.TwoJackRaw[source]#

Bases: typing.TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

jack1: float#

None

jack2: float#

None