API

Create Ophyd Devices from rml file

RaypyngOphydDevices

class raypyng_bluesky.RaypyngOphydDevices.RaypyngOphydDevices(*args, RE, rml_path, temporary_folder=None, name_space=None, prefix=None, ray_ui_location=None, simulation_engine='rayui', **kwargs)

Create ophyd devices from a RAY-UI rml file and adds them to a name space.

If you are using ipython sys._getframe(0) returns the name space of the ipython instance. (Remember to import sys)

Parameters:
  • RE (RunEngine) – Bluesky RunEngine

  • rml_path (str) – the path to the rml file

  • temporary_folder (str) – path where to create temporary folder. If None it is automatically set into the ipython profile folder. Default to None.

  • name_space (frame, optional) – If None the class will try to understand the correct namespace to add the Ophyd devices to. If the automatic retrieval fails, pass sys._getframe(0). Defaults to None.

  • prefix (str) – the prefix to prepend to the oe names found in the rml file

  • ray_ui_location (str) – the location of the RAY-UI installation folder. If None the program will try to find it automatically. Deafault to None.

append_preprocessor()

Add supplemental data to the RunEngine to trigger the simulations

create_raypyng_elements_from_rml()

Iterate through the raypyng objects created by RMLFile and create corresponding Ophyd Devices

Returns:

the Ophyd devices created

Return type:

OphydDevices

create_trigger_detector()

Create a trigger detector called RaypyngTriggerDetector

prepend_to_oe_name()

Prepend a prefix to the name of all the Ophyd object created

trigger_detector()

Return the RaypyngTriggerDetector

Returns:

the trigger detector

Return type:

RaypyngTriggerDetector (RaypyngTriggerDetector)

RaypyngDictionary

class raypyng_bluesky.RaypyngOphydDevices.RaypyngDictionary(*args, **kwargs)

A class defining a dictionary of the differen elements in rayui and the classe to be used as Ophyd devices

Simulation Engine

RaypyngOphydDevices

class raypyng_bluesky.simulation_engine.SimulatonEngineRAYUI(ray_ui_location: str)

A class that takes care of the communication with the RAY-UI api

This class is used in case the simulation engine requested is RAY-UI on the local machine

Args:
ray_ui_location (str): the location of RAY-UI program. If None the program will look

into the defaults folders.

check_if_simulation_is_done()

Retrieve the simulation done signal of the RayUIAPI.

Returns:

The simulation done signal.

Return type:

(bool)

setup_simulation()

Get ready to simulate, by calling the RayUIRunner and the RayUIAPI

Returns:

an instance of the RayUIAPI class

Return type:

(RayUIAPI)

simulate(path, rml, exports_list)

Start the simulations with RAY-UI usig the RayUIAPI

Parameters:
  • path (str) – the path to the temporary folder

  • rml (RMLFile) – the instance of the RMLFile class used to save the rml file

  • exports_list (list) – list of the exported objects

Ophyd Signals

RayPySignal

class raypyng_bluesky.signal.RayPySignal(*args, **kwargs)
get()

The readback value

put(*args, **kwargs)

Low-level method for writing to a Signal.

The value is optionally checked first, depending on the value of force. In addition, VALUE subscriptions are run.

Extra kwargs are ignored (for API compatibility with EpicsSignal kwargs pass through).

Parameters:
  • value (any) – Value to set

  • timestamp (float, optional) – The timestamp associated with the value, defaults to time.time()

  • metadata (dict, optional) – Further associated metadata with the value (such as alarm status, severity, etc.)

  • force (bool, optional) – Check the value prior to setting it, defaults to False

set(value)

Set the value of the Signal and return a Status object.

Returns:

st – This status object will be finished upon return in the case of basic soft Signals

Return type:

Status

RayPySignalRO

class raypyng_bluesky.signal.RayPySignalRO(*args, **kwargs)
put(value, *, timestamp=None, force=False)

Low-level method for writing to a Signal.

The value is optionally checked first, depending on the value of force. In addition, VALUE subscriptions are run.

Extra kwargs are ignored (for API compatibility with EpicsSignal kwargs pass through).

Parameters:
  • value (any) – Value to set

  • timestamp (float, optional) – The timestamp associated with the value, defaults to time.time()

  • metadata (dict, optional) – Further associated metadata with the value (such as alarm status, severity, etc.)

  • force (bool, optional) – Check the value prior to setting it, defaults to False

set(value, *, timestamp=None, force=False)

Set the value of the Signal and return a Status object.

Returns:

st – This status object will be finished upon return in the case of basic soft Signals

Return type:

Status

Ophyd Axes

Axes

class raypyng_bluesky.axes.RaypyngAxis(*args, **kwargs)

The Axis used by all the Raypyng devices.

At the moment it is a comparator, in the future some other positioner will be used, probably a SoftPositioner. The class defines an empty dictionary, the axes_dict that will be then filled by each device.

get()

Return the value of a certain axis as in the RMLFile

Returns:

the value of the axis in the RML file

Return type:

float

property position

The current position of the motor in its engineering units :returns: position :rtype: any

set(value)

Write a value in the RMLFile for a certain element/axis

Parameters:

value (float,int) – the value to set to the axis

set_axis(obj, axis)

Set what axis should be used, based on the axes_dict

Parameters:
  • obj (_type_) – _description_

  • axis (_type_) – _description_

SimulatedAxisSource

class raypyng_bluesky.axes.SimulatedAxisSource(*args, **kwargs)

Define basic properties of the source:

Available axes:

  • number of rays [a.u.]

  • photon energy [eV]

  • bandwidth [% of photon energy]

class SimulatedAxisMisalign(RaypyngAxis):

class raypyng_bluesky.axes.SimulatedAxisMisalign(*args, **kwargs)

Define misalignment axes:

Available axes:

  • translationXerror [mm]

  • translationYerror [mm]

  • translationZerror [mm]

  • rotationXerror [um]

  • rotationYerror [um]

  • rotationZerror [um]

SimulatedAxisAperture

class raypyng_bluesky.axes.SimulatedAxisAperture(*args, **kwargs)

Define basic properties of apertures:

Available axes:

  • width [mm]

  • height [mm]

SimulatedAxisGrating

class raypyng_bluesky.axes.SimulatedAxisGrating(*args, **kwargs)

Define basic properties of the gratings:

Available axes:

  • lineDensity [lines/mm]

  • orderDiffraction

  • cFactor

  • lineProfile (laminar, sinus, blaze, unknown)

  • blazeAngle [°]

  • aspectAngle [°]

  • grooveDepth [nm]

  • grooveRatio (groove width divided by spacing)

Ophyd Detectors

Detector

class raypyng_bluesky.detector.RaypyngDetector(*args, information_to_extract='intensity', parent_detector_name=None, **kwargs)

Defining a raypyng detector using a signal. The detector is created when an Image Plane or an Image Plane Bundle is found in the rml file.

get()

The readback value

put(value, *, timestamp=None, force=False)

Low-level method for writing to a Signal.

The value is optionally checked first, depending on the value of force. In addition, VALUE subscriptions are run.

Extra kwargs are ignored (for API compatibility with EpicsSignal kwargs pass through).

Parameters:
  • value (any) – Value to set

  • timestamp (float, optional) – The timestamp associated with the value, defaults to time.time()

  • metadata (dict, optional) – Further associated metadata with the value (such as alarm status, severity, etc.)

  • force (bool, optional) – Check the value prior to setting it, defaults to False

set(value, *, timestamp=None, force=False)

Set the value of the Signal and return a Status object.

Returns:

st – This status object will be finished upon return in the case of basic soft Signals

Return type:

Status

trigger()

Call that is used by bluesky prior to read()

Trigger Detector

class raypyng_bluesky.detector.RaypyngTriggerDetector(*args, rml, temporary_folder, simulation_api, **kwargs)

The trigger detector is used to start the simulations. The simulations are done on the machine where bluesky is running.

put(value, *, timestamp=None, force=False)

Low-level method for writing to a Signal.

The value is optionally checked first, depending on the value of force. In addition, VALUE subscriptions are run.

Extra kwargs are ignored (for API compatibility with EpicsSignal kwargs pass through).

Parameters:
  • value (any) – Value to set

  • timestamp (float, optional) – The timestamp associated with the value, defaults to time.time()

  • metadata (dict, optional) – Further associated metadata with the value (such as alarm status, severity, etc.)

  • force (bool, optional) – Check the value prior to setting it, defaults to False

set(value, *, timestamp=None, force=False)

Set the value of the Signal and return a Status object.

Returns:

st – This status object will be finished upon return in the case of basic soft Signals

Return type:

Status

trigger()

Call that is used by bluesky prior to read()

Ophyd Devices

MisalignComponents

class raypyng_bluesky.devices.MisalignComponents(*args, obj, **kwargs)

Define the misalignment components of an optical element using SimulatedAxisMisalign

SimulatedPGM

class raypyng_bluesky.devices.SimulatedPGM(*args, obj, **kwargs)

Define the Plan Grating Monochromator using SimulatedAxisMisalign and SimulatedAxisGrating.

Additionaly defines a two dictionaries to store different grating parameters and a method change_grating() to switch between them.

change_grating(grating_name)

Change between gratings based on the line density

Parameters:

grating_name (str) – the name you of the grating you want to use

rename_default_grating(new_name)

Rename the default grating

Parameters:

new_name (str) – the new name for the default grating

rename_grating(new_name, old_name)

Rename any grating

Parameters:
  • new_name (str) – the new name for the default grating

  • old_name (str) – the old name of the grating

SimulatedApertures

class raypyng_bluesky.devices.SimulatedApertures(*args, obj, **kwargs)

Define the apertures using SimulatedAxisMisalign and SimulatedAxisAperture.

SimulatedMirror

class raypyng_bluesky.devices.SimulatedMirror(*args, obj, **kwargs)

Define the mirrors using SimulatedAxisMisalign.

SimulatedSource

class raypyng_bluesky.devices.SimulatedSource(*args, obj, **kwargs)

Define the source using SimulatedAxisSource.

Preprocessor

MisalignComponents

raypyng_bluesky.preprocessor.trigger_sim(plan, trigger_detector)

Trigger simulations for raypyng plans

This function is composed of four steps:

1- populate_raypyng_devices_list_at_stage:

at the ‘stage message’ each device is classified and saved into two list. One list is dedicated to raypng devices, and one for all the others

2- prepare_simulations_at_open_run:

when the message is ‘open_run’, if both raypyng devices and normal devices have been staged raise an exception. Otherwise the list of exports is prepared(consists of detector names included in the plan) and passed to the trigger detector.

3- insert_before_first_det_trigger:

before the first detector is triggered, a trigger message for the raypyng trigger detector is inserted in the same group as the other detectors

4- cleanup_at_close_run:

when the message is ‘close_run’ the simulation_done file is removed and the list containing the raypyng and other devices, created at point 1, are cleared.

Parameters:
  • plan (bluesky.plan) – the plan that is being executed

  • trigger_detector (RaypyngTriggerDetector) – the trigger detector

Raises:
  • ValueError – if in the plan a mix of raypyng devices are other devices

  • are used raise an exeption

SupplementalDataRaypyng

class raypyng_bluesky.preprocessor.SupplementalDataRaypyng(*args, trigger_detector, **kwargs)

Supplemental data for raypyng.

The Run engine is needed to be able to include the trigger detector automatically

Parameters:

trigger_detector (RaypyngTriggerDetector) – The detector to trigger raypyng