darfix.core.datapathfinder.DataPathFinder#

class darfix.core.datapathfinder.DataPathFinder(file_, pattern, filter_entries=None, allowed_keywords=('{scan}', '{first_scan}', '{last_scan}', '{detector}'))[source]#

Bases: object

Util class to format path from a provided pattern At the moment it allows the following keywords: * {scan}: will replace the ‘{scan}’ by an HDF5 first level group name * {first_scan}: will replace the ‘{first_scan}’ by the first HDF5 group of the list * {last_scan}: will replace the ‘{last_scan}’ by the first HDF5 group of the list * {detector}: will try to detect automatically the dataset to be used as detector

Parameters:
  • file_ (str | h5py.File)

  • pattern (str)

  • filter_entries (tuple | None)

  • allowed_keywords (tuple)

property allowed_keywords: tuple#
property can_be_solved: bool#
static check_is_a_3d_dataset(dataset)[source]#
Parameters:

dataset (h5py.Dataset | h5py.Group)

property file: str | h5py.File#
static find_detector_dataset(group, check_nexus_metadata=None)[source]#

browse all datasets / groups in the group and return the dataset the most likely to be the detector dataset.

Parameters:
  • group (h5py.Group) – HDF5 group containing all elements to check.

  • check_nexus_metadata (bool | None) – policy regarding checking possible metadata. * If True will return the first ‘data’ dataset contained in a group identified as an ‘NXdetector’ and being 3D. * If False will return the first 3D dataset found (can be in a sub group if named ‘data’) * If None then will look first for detector with nexus metadata else without

Return type:

Optional[h5py.Dataset]

format(scan, first_scan, last_scan)[source]#

Once the class is instanciated we can call the ‘format’ function to replace keywords by the scan, first_scan, last_scan values

Parameters:
  • scan (str | None)

  • first_scan (str | None)

  • last_scan (str | None)

Return type:

str | None

static format_str_for_scans_keywords(my_str, scan, first_scan, last_scan)[source]#
Parameters:
  • my_str (str)

  • scan (str | None)

  • first_scan (str | None)

  • last_scan (str | None)

static from_found_detector_dataset_to_pattern(detector_dataset, scan_path)[source]#

Recreate the ‘detector_dataset’ pattern like ‘/{scan}/path/to/detectors/groups/detector’ from the path of the detector for a specific entry (“scan_path”) ‘existing’ pattern like ‘/{scan}/path/to/detectors/groups/detector/data’ or ‘/{scan}/path/to/detectors/groups/detector_data’

Parameters:
  • detector_dataset (str)

  • scan_path (str)

static get_detector(elmt, check_nexus_metadata)[source]#
Parameters:
  • elmt (h5py.Dataset | h5py.Group)

  • check_nexus_metadata (bool)

Return type:

Optional[h5py.Dataset]

property pattern: str#