io_handling

load_data_field(file_path, data_field, wavelength=None)[source]
load_hdf5(file_path, file_dictionary_path='/')[source]

Loads a dictionary from an hdf5 file.

Parameters:
  • file_path – Path of the file to load the dictionary from.

  • file_dictionary_path – Path in dictionary structure of hdf5 file to lo the dictionary in.

Returns:

Dictionary

Return type:

dict

save_data_field(data, file_path, data_field, wavelength=None)[source]
save_hdf5(save_item, file_path: str, file_dictionary_path: str = '/', file_compression: Optional[str] = None)[source]

Saves a dictionary with arbitrary content or an item of any kind to an hdf5-file with given filepath.

Parameters:
  • save_item – Dictionary to save.

  • file_path – Path of the file to save the dictionary in.

  • file_dictionary_path – Path in dictionary structure of existing hdf5 file to store the dictionary in.

  • file_compression – possible file compression for the hdf5 output file. Values are: gzip, lzf and szip.

Returns:

Null

class IpascSimpaAdapter(hdf5_file_path: str, device: DigitalDeviceTwinBase, settings: Optional[Settings] = None)[source]

Bases: BaseAdapter

This class contains the logic to extract the needed meta data from the SIMPA simulation files to fulfill the requirements of the IPASC standard data format.

generate_binary_data() ndarray[source]

The binary data is the raw time series data. It is internally stored as an N-dimensional numpy array. The binary data must be formatted the following way:

[detectors, samples, wavelengths, measurements]

Returns:

A numpy array containing the binary data

Return type:

np.ndarray

generate_device_meta_data() dict[source]

Must be implemented to define a digital twin of the photoacoustic imaging device. This method can be implemented using the DeviceMetaDataCreator.

Returns:

A dictionary containing all key-value pair necessary to describe a digital twin of a photoacoustic device.

Return type:

dict

set_metadata_value(metadata_tag: MetaDatum) object[source]

This method must be implemented to yield appropriate data for all MetaDatum elements in the MetadataTags class.

You are given a certain meta datum nd have to return the appropriate information.

Parameters:

metadatum (MetaDatum) – The MetaDatum for which to return the correct data.

Returns:

The data corresponding to the given MetaDatum

Return type:

object

export_to_ipasc(hdf5_file_path: str, device: DigitalDeviceTwinBase, settings: Optional[Settings] = None)[source]

This function exports parts of the SIMPA simulation results of the given hdf5_file_path into the IPASC standard data format.

Parameters:
  • hdf5_file_path – A string with the path to an HDF5 file containing a SIMPA simulation result

  • device – A PhotoacousticDevice that describes the digital device twin

  • settings – The settings dictionary used for the simulation. if not given, it is attempted to recover the settings dictionary from the HDF5 file.

Returns:

None

download_from_zenodo(record_id: str, save_dir: str, sandbox: bool = False)[source]

Downloads a .zip folder from zenodo.org with the specified Record ID.

Parameters:
  • record_id – Record ID of the specified Zenodo file.

  • save_dir – Output directory where the Zenodo file will be stored.

  • sandbox – Boolean to specify whether to download from zenodo.org or sandbox.zenodo.org.