STConverter#

class pyrost.simulation.STConverter(sim_obj, data, crd_rat=1e-06, basis_vectors=None, translations=None)#

Converter class to export simulated data from STSim to a CXI file. Takes an instance of STSim and a generated stack of frames and automatically generates all the attributes necessary for the robust speckle tracking reconstruction (see pyrost.STData).

Parameters

Notes

Necessary attributes:

  • data : Simulated intensity frames.

Automatically generated attributes:

  • basis_vectors : Detector basis vectors.

  • defocus_x : Defocus distance along the horizontal detector axis.

  • defocus_y : Defocus distance along the vertical detector axis.

  • distance : Sample-to-detector distance.

  • translations : Sample’s translations.

  • wavelength : Incoming beam’s wavelength.

  • x_pixel_size : Pixel’s size along the horizontal detector axis.

  • y_pixel_size : Pixel’s size along the vertical detector axis.

contents()#

Return a list of the attributes stored in the container that are initialised.

Return type

List[str]

Returns

List of the attributes stored in the container.

export_data(out_path, apply_transform=True, protocol=CXIProtocol(datatypes={'basis_vectors': 'float', 'data': 'uint', 'defocus_x': 'float', 'defocus_y': 'float', 'distance': 'float', 'mask': 'bool', 'phase': 'float', 'pixel_aberrations': 'float', 'pixel_translations': 'float', 'reference_image': 'float', 'scale_map': 'float', 'translations': 'float', 'wavelength': 'float', 'whitefield': 'float', 'whitefields': 'float', 'x_pixel_size': 'float', 'y_pixel_size': 'float'}, load_paths={'basis_vectors': ['/speckle_tracking/basis_vectors', '/entry_1/instrument_1/detector_1/basis_vectors', '/entry/instrument/detector/basis_vectors'], 'data': ['/entry/data/data', '/entry/instrument/detector/data', '/entry_1/instrument_1/detector_1/data', '/entry_1/data_1/data'], 'defocus_x': ['/speckle_tracking/defocus_x', '/speckle_tracking/defocus_fs', '/speckle_tracking/defocus'], 'defocus_y': ['/speckle_tracking/defocus_y', '/speckle_tracking/defocus_ss'], 'distance': ['/entry/instrument/detector/distance', '/entry_1/instrument_1/detector_1/distance'], 'mask': ['/speckle_tracking/mask', '/mask_maker/mask', '/entry_1/instrument_1/detector_1/mask', '/entry/instrument/detector/mask'], 'phase': ['/speckle_tracking/phase'], 'pixel_aberrations': ['/speckle_tracking/pixel_aberrations'], 'pixel_translations': ['/speckle_tracking/pixel_translations'], 'reference_image': ['/speckle_tracking/reference_image'], 'scale_map': ['/speckle_tracking/scale_map'], 'translations': ['/speckle_tracking/translations', '/entry_1/sample_1/geometry/translations', '/entry/sample/geometry/translations', '/entry_1/sample_1/geometry/translation', '/pos_refine/translation', '/entry_1/sample_3/geometry/translation'], 'wavelength': ['/entry/instrument/source/wavelength', '/entry_1/instrument_1/source_1/wavelength', 'entry/instrument/beam/incident_wavelength'], 'whitefield': ['/speckle_tracking/whitefield', '/process_1/whitefield', '/make_whitefield/whitefield', '/process_2/whitefield', '/process_3/whitefield'], 'whitefields': ['/speckle_tracking/whitefields', '/speckle_tracking/flatfields'], 'x_pixel_size': ['/entry/instrument/detector/x_pixel_size', '/entry_1/instrument_1/detector_1/x_pixel_size'], 'y_pixel_size': ['/entry/instrument/detector/y_pixel_size', '/entry_1/instrument_1/detector_1/y_pixel_size']}, kinds={'basis_vectors': 'sequence', 'data': 'stack', 'defocus_x': 'scalar', 'defocus_y': 'scalar', 'distance': 'scalar', 'mask': 'stack', 'phase': 'frame', 'pixel_aberrations': 'frame', 'pixel_translations': 'sequence', 'reference_image': 'scalar', 'scale_map': 'frame', 'translations': 'sequence', 'wavelength': 'scalar', 'whitefield': 'frame', 'whitefields': 'stack', 'x_pixel_size': 'scalar', 'y_pixel_size': 'scalar'}))#

Save simulated data to the path specified in out_path and return pyrost.STData object.

Parameters
  • out_path (str) – Path to the folder, where all the files are saved.

  • apply_transform (bool) – Apply the cropping transform from STSim.get_transform().

  • protocol (CXIProtocol) – CXI file protocol.

Return type

STData

Returns

Data container pyrost.STData.

get(attr, value=None)#

Retrieve a dataset, return value if the attribute is not found.

Parameters
  • attr (str) – Data attribute.

  • value (Optional[Any]) – Data which is returned if the attribute is not found.

Return type

Any

Returns

Attribute’s data stored in the container, value if attr is not found.

get_transform()#

Return a pyrost.Crop transform corresponding to the ROI of the beam on the detector.

Returns

pyrost.Crop transform corresponding to the ROI of the beam.

items()#

Return (key, value) pairs of the datasets stored in the container.

Return type

ItemsView

Returns

(key, value) pairs of the datasets stored in the container.

keys()#

Return a list of the attributes available in the container.

Return type

List[str]

Returns

List of the attributes available in the container.

replace(**kwargs)#

Return a new container object with a set of attributes replaced.

Parameters

kwargs (Any) – A set of attributes and the values to to replace.

Return type

~D

Returns

A new container object with updated attributes.

save(out_path, apply_transform=True, protocol=CXIProtocol(datatypes={'basis_vectors': 'float', 'data': 'uint', 'defocus_x': 'float', 'defocus_y': 'float', 'distance': 'float', 'mask': 'bool', 'phase': 'float', 'pixel_aberrations': 'float', 'pixel_translations': 'float', 'reference_image': 'float', 'scale_map': 'float', 'translations': 'float', 'wavelength': 'float', 'whitefield': 'float', 'whitefields': 'float', 'x_pixel_size': 'float', 'y_pixel_size': 'float'}, load_paths={'basis_vectors': ['/speckle_tracking/basis_vectors', '/entry_1/instrument_1/detector_1/basis_vectors', '/entry/instrument/detector/basis_vectors'], 'data': ['/entry/data/data', '/entry/instrument/detector/data', '/entry_1/instrument_1/detector_1/data', '/entry_1/data_1/data'], 'defocus_x': ['/speckle_tracking/defocus_x', '/speckle_tracking/defocus_fs', '/speckle_tracking/defocus'], 'defocus_y': ['/speckle_tracking/defocus_y', '/speckle_tracking/defocus_ss'], 'distance': ['/entry/instrument/detector/distance', '/entry_1/instrument_1/detector_1/distance'], 'mask': ['/speckle_tracking/mask', '/mask_maker/mask', '/entry_1/instrument_1/detector_1/mask', '/entry/instrument/detector/mask'], 'phase': ['/speckle_tracking/phase'], 'pixel_aberrations': ['/speckle_tracking/pixel_aberrations'], 'pixel_translations': ['/speckle_tracking/pixel_translations'], 'reference_image': ['/speckle_tracking/reference_image'], 'scale_map': ['/speckle_tracking/scale_map'], 'translations': ['/speckle_tracking/translations', '/entry_1/sample_1/geometry/translations', '/entry/sample/geometry/translations', '/entry_1/sample_1/geometry/translation', '/pos_refine/translation', '/entry_1/sample_3/geometry/translation'], 'wavelength': ['/entry/instrument/source/wavelength', '/entry_1/instrument_1/source_1/wavelength', 'entry/instrument/beam/incident_wavelength'], 'whitefield': ['/speckle_tracking/whitefield', '/process_1/whitefield', '/make_whitefield/whitefield', '/process_2/whitefield', '/process_3/whitefield'], 'whitefields': ['/speckle_tracking/whitefields', '/speckle_tracking/flatfields'], 'x_pixel_size': ['/entry/instrument/detector/x_pixel_size', '/entry_1/instrument_1/detector_1/x_pixel_size'], 'y_pixel_size': ['/entry/instrument/detector/y_pixel_size', '/entry_1/instrument_1/detector_1/y_pixel_size']}, kinds={'basis_vectors': 'sequence', 'data': 'stack', 'defocus_x': 'scalar', 'defocus_y': 'scalar', 'distance': 'scalar', 'mask': 'stack', 'phase': 'frame', 'pixel_aberrations': 'frame', 'pixel_translations': 'sequence', 'reference_image': 'scalar', 'scale_map': 'frame', 'translations': 'sequence', 'wavelength': 'scalar', 'whitefield': 'frame', 'whitefields': 'stack', 'x_pixel_size': 'scalar', 'y_pixel_size': 'scalar'}), mode='overwrite', idxs=None)#

Save simulated data to the path specified in out_path.

Parameters
  • out_path (str) – Path to the folder, where all the files are saved.

  • apply_transform (bool) – Apply the cropping transform from STSim.get_transform().

  • protocol (CXIProtocol) – CXI file protocol.

  • mode (str) –

    Writing mode:

    • append : Append the data array to already existing dataset.

    • insert : Insert the data under the given indices idxs.

    • overwrite : Overwrite the existing dataset.

  • idxs (Optional[Iterable[int]]) – A set of frame indices where the data is saved if mode is insert.

Returns

None

values()#

Return the attributes’ data stored in the container.

Return type

ValuesView

Returns

List of data stored in the container.