daxs.sources: Sources#

The module provides classes to deal with different types of data sources.

class daxs.sources.BlissPath(root: str, proposal: str, beamline: str, session: str, sample: str, dataset: str, data_type: str = 'RAW_DATA')[source]#

Bases: object

__init__(root: str, proposal: str, beamline: str, session: str, sample: str, dataset: str, data_type: str = 'RAW_DATA') None[source]#
property collection: str#
property filename: str#
property path: str#
classmethod from_path(path: str) BlissPath[source]#

Create a BlissPath object from a path.

Parameters:

path – The file path to parse.

Returns:

A new BlissPath object.

Raises:

ValueError – If the path is invalid.

class daxs.sources.Source[source]#

Bases: ABC

Base class for sources of scans.

abstract property filename: str | None#

The filename of the source.

abstract property scans: Scans#

Return all source scans.

abstract property data_mappings: dict[str, Any]#

The mappings between scan attributes and paths in the source.

abstract read_scans(scan_ids: list[int] | ndarray[tuple[int, ...], dtype[int64]] | None = None) Scans[source]#

Return all source scans.

class daxs.sources.Hdf5Source(filename: str, scan_ids: int | list[int] | ndarray[tuple[int, ...], dtype[int64]] | str, data_mappings: dict[str, Any])[source]#

Bases: Source

__init__(filename: str, scan_ids: int | list[int] | ndarray[tuple[int, ...], dtype[int64]] | str, data_mappings: dict[str, Any]) None[source]#

Class for a HDF5 source of scans.

Parameters:
  • filename – Name of the HDF5 file.

  • scan_ids – Scan indices to read.

  • data_mappings – Mappings between scan attributes (x, signal, monitor, etc.) and paths in the HDF5 file.

property filename: str#

The filename of the source.

property scan_ids: list[int]#
property data_mappings: dict[str, Any]#

The mappings between scan attributes and paths in the source.

property scans: Scans#

Return all source scans.

read_scans(scan_ids: list[int] | ndarray[tuple[int, ...], dtype[int64]] | None = None) Scans[source]#

Read the scans from the source.

read_scan(scan_id: int) Scan[source]#

Return a scan object at the index.

class daxs.sources.TxtSource(filename: str, data_mappings: dict[str, int], **kwargs: Any)[source]#

Bases: Source

__init__(filename: str, data_mappings: dict[str, int], **kwargs: Any) None[source]#

Class for a text file source of scans.

Parameters:
  • filename – Name of the text file.

  • data_mappings – Dictionary mapping scan attributes to column indices. Must contain entries for “x” and “signal”. Column indices are 0-based.

  • **kwargs – Additional keyword arguments passed to np.loadtxt, e.g., delimiter, skiprows, etc.

property filename: str#

The filename of the source.

property data_mappings: dict[str, Any]#

The mappings between scan attributes and paths in the source.

property scans: Scans#

Return all source scans.

read_scans(scan_ids: list[int] | ndarray[tuple[int, ...], dtype[int64]] | None = None) Scans[source]#

Read the scans from the source.

read_scan(scan_id: int) Scan[source]#

Return the scan object.