xpdsim package

Submodules

xpdsim.area_det module

Spoof detectors

class xpdsim.area_det.SimulatedCam(prefix='', *, name, kind=None, read_attrs=None, configuration_attrs=None, parent=None, **kwargs)[source]

Bases: Device

acquire = SynSignal(name='acquire', value=1, timestamp=1663881639.8495684)
acquire_time = SynSignal(name='acquire_time', value=0.1, timestamp=1663881639.8495572)
component_names = ()
subscriptions: ClassVar[FrozenSet[str]] = frozenset({'acq_done'})
xpdsim.area_det.add_fake_cam(det)[source]

Adding simulated cam device signals to the detector

Parameters

det (SimulatedPE1C instance) – The detector

Returns

det – The detector

Return type

SimulatedPE1C instance

xpdsim.area_det.build_image_cycle(path, key='pe1_image')[source]

Build image cycles, essentially generators with endless images

Parameters
  • path (str) – Path to the files to be used as the base for the cycle.

  • key (str, optional) – key of the entire image sequence. Default to 'pe1_image'.

Returns

The iterable like object to cycle through the images

Return type

Cycler

xpdsim.area_det.det_factory(cycle=None, img_gen_func=<function img_gen>, data_key='pe1_image', *args, **kwargs)[source]

Build a simulated detector yielding input image sequence

Parameters
  • cycle (cycler.Cycler, optional) – The iterable like object to cycle through the images. Default to output images in (2048, 2048) dimension with Gaussian(0, 1) noise.

  • img_gen_func (callable, optional) –

    function to return image sequence will be output from

    this detector. The function signature is expected to be f(cycler, *args, **kwargs). Default to xpdsim.img_gen function where simulated shutter and noise can be included.

  • data_key (str, optional) –

    data key will be shown in Descriptor. Default to

    'pe1_image'.

  • args

    extra arguments will be passed to

    img_gen_func.

  • kwargs

    extra keyword arguments will be

    passed to img_gen_func.

Returns

det – The detector

Return type

SimulatedPE1C instance

See also

xpdsim.img_gen

xpdsim.area_det.img_gen(cycle=None, size=(2048, 2048), shutter=None, noise=None)[source]

Generator of diffraction images from 2D detector.

The output images is determined by cycle argument.

Parameters
  • cycle (cycler.Cycler, optional) – The iterable like object to cycle through the images. Default to images with standard Gaussian noise in

    input size.

  • size (tuple, optional) – Tuple to specify image size from the simulated detector. Default to (2048, 2048) (PE detector). Overridden when cycle argument is passed.

  • shutter (settable, optional) –

    Ophyd objects to represent the shutter associated with

    with the detector. If it is not passed, assuming shutter is always open. If shutter is passed, assuming it follows the same configuration as XPD beamline (60 means open).

  • noise (callable, optional) – function to generate noise based on absolute scale of image. Default to noise-free.

Returns

img – simulated 2D diffraction image with specified size.

Return type

ndarray

xpdsim.build_sim_db module

xpdsim.movers module

class xpdsim.movers.SimFilterBank(prefix='', *, name, kind=None, read_attrs=None, configuration_attrs=None, parent=None, **kwargs)[source]

Bases: Device

Simulated filter bank with only the first filter in by default

component_names = ('flt1', 'flt2', 'flt3', 'flt4')
flt1

A descriptor representing a device component (or signal)

Unrecognized keyword arguments will be passed directly to the component class initializer.

Parameters
  • cls (class) – Class of signal to create. The required signature of cls.__init__ is (if suffix is given):

    def __init__(self, pv_name, parent=None, **kwargs):
    

    or (if suffix is None)

    def __init__(self, parent=None, **kwargs):
    

    The class may have a wait_for_connection() which is called during the component instance creation.

  • suffix (str, optional) – The PV suffix, which gets appended onto parent.prefix to generate the final PV that the instance component will bind to. Also see add_prefix

  • lazy (bool, optional) – Lazily instantiate the signal. If False, the signal will be instantiated upon component instantiation. Defaults to component.lazy_default.

  • trigger_value (any, optional) – Mark as a signal to be set on trigger. The value is sent to the signal at trigger time.

  • add_prefix (sequence, optional) – Keys in the kwargs to prefix with the Device PV prefix during creation of the component instance. Defaults to ('suffix', 'write_pv', )

  • doc (str, optional) – string to attach to component DvcClass.component.__doc__

flt2

A descriptor representing a device component (or signal)

Unrecognized keyword arguments will be passed directly to the component class initializer.

Parameters
  • cls (class) – Class of signal to create. The required signature of cls.__init__ is (if suffix is given):

    def __init__(self, pv_name, parent=None, **kwargs):
    

    or (if suffix is None)

    def __init__(self, parent=None, **kwargs):
    

    The class may have a wait_for_connection() which is called during the component instance creation.

  • suffix (str, optional) – The PV suffix, which gets appended onto parent.prefix to generate the final PV that the instance component will bind to. Also see add_prefix

  • lazy (bool, optional) – Lazily instantiate the signal. If False, the signal will be instantiated upon component instantiation. Defaults to component.lazy_default.

  • trigger_value (any, optional) – Mark as a signal to be set on trigger. The value is sent to the signal at trigger time.

  • add_prefix (sequence, optional) – Keys in the kwargs to prefix with the Device PV prefix during creation of the component instance. Defaults to ('suffix', 'write_pv', )

  • doc (str, optional) – string to attach to component DvcClass.component.__doc__

flt3

A descriptor representing a device component (or signal)

Unrecognized keyword arguments will be passed directly to the component class initializer.

Parameters
  • cls (class) – Class of signal to create. The required signature of cls.__init__ is (if suffix is given):

    def __init__(self, pv_name, parent=None, **kwargs):
    

    or (if suffix is None)

    def __init__(self, parent=None, **kwargs):
    

    The class may have a wait_for_connection() which is called during the component instance creation.

  • suffix (str, optional) – The PV suffix, which gets appended onto parent.prefix to generate the final PV that the instance component will bind to. Also see add_prefix

  • lazy (bool, optional) – Lazily instantiate the signal. If False, the signal will be instantiated upon component instantiation. Defaults to component.lazy_default.

  • trigger_value (any, optional) – Mark as a signal to be set on trigger. The value is sent to the signal at trigger time.

  • add_prefix (sequence, optional) – Keys in the kwargs to prefix with the Device PV prefix during creation of the component instance. Defaults to ('suffix', 'write_pv', )

  • doc (str, optional) – string to attach to component DvcClass.component.__doc__

flt4

A descriptor representing a device component (or signal)

Unrecognized keyword arguments will be passed directly to the component class initializer.

Parameters
  • cls (class) – Class of signal to create. The required signature of cls.__init__ is (if suffix is given):

    def __init__(self, pv_name, parent=None, **kwargs):
    

    or (if suffix is None)

    def __init__(self, parent=None, **kwargs):
    

    The class may have a wait_for_connection() which is called during the component instance creation.

  • suffix (str, optional) – The PV suffix, which gets appended onto parent.prefix to generate the final PV that the instance component will bind to. Also see add_prefix

  • lazy (bool, optional) – Lazily instantiate the signal. If False, the signal will be instantiated upon component instantiation. Defaults to component.lazy_default.

  • trigger_value (any, optional) – Mark as a signal to be set on trigger. The value is sent to the signal at trigger time.

  • add_prefix (sequence, optional) – Keys in the kwargs to prefix with the Device PV prefix during creation of the component instance. Defaults to ('suffix', 'write_pv', )

  • doc (str, optional) – string to attach to component DvcClass.component.__doc__

subscriptions: ClassVar[FrozenSet[str]] = frozenset({'acq_done'})

Module contents