nabu.resources.dataset_analyzer module

class nabu.resources.dataset_analyzer.DatasetAnalyzer(location, extra_options=None, logger=None)[source]

Bases: object

Initialize a Dataset analyzer.

Parameters:
  • location (str) – Dataset location (directory or file name)

  • extra_options (dict, optional) – Extra options on how to interpret the dataset.

  • logger (logging object, optional) – Logger. If not set, messages will just be printed in stdout.

kind = 'none'

Base class for datasets analyzers.

property energy

Return the energy in kev.

property distance

Return the sample-detector distance in meters.

property pixel_size

Return the pixel size in microns.

property rotation_angles

Return the rotation angles in radians.

property is_halftomo

Indicates whether the current dataset was performed with half acquisition.

property detector_tilt

Return the detector tilt in degrees

property projections
property projections_srcurrent

Return the synchrotron electric current for each projection.

property flats_srcurrent

Return the synchrotron electric current for each flat image.

check_defined_attribute(name, error_msg=None)[source]

Utility function to check that a given attribute is defined.

property flats

Return the REDUCED flat-field images. Either by reducing (median) the raw flats, or a user-defined reduced flats.

property darks

Return the REDUCED flat-field images. Either by reducing (mean) the raw darks, or a user-defined reduced darks.

class nabu.resources.dataset_analyzer.EDFDatasetAnalyzer(location, extra_options=None, logger=None)[source]

Bases: DatasetAnalyzer

EDF Dataset analyzer for legacy ESRF acquisitions

Initialize a Dataset analyzer.

Parameters:
  • location (str) – Dataset location (directory or file name)

  • extra_options (dict, optional) – Extra options on how to interpret the dataset.

  • logger (logging object, optional) – Logger. If not set, messages will just be printed in stdout.

kind = 'edf'

Base class for datasets analyzers.

property hdf5_entry

Return the HDF5 entry of the current dataset. Not applicable for EDF (return None)

get_reduced_flats(**reader_kwargs)[source]
get_reduced_darks(**reader_kwargs)[source]
property files
get_reader(**kwargs)[source]
class nabu.resources.dataset_analyzer.HDF5DatasetAnalyzer(location, extra_options=None, logger=None)[source]

Bases: DatasetAnalyzer

HDF5 dataset analyzer

Initialize a Dataset analyzer.

Parameters:
  • location (str) – Dataset location (directory or file name)

  • extra_options (dict, optional) – Extra options on how to interpret the dataset.

  • logger (logging object, optional) – Logger. If not set, messages will just be printed in stdout.

kind = 'nx'

Base class for datasets analyzers.

property z_translation
property x_translation
property dataset_hdf5_url
property hdf5_entry

Return the HDF5 entry of the current dataset

get_data_slices(what)[source]

Return indices in the data volume where images correspond to a given kind.

Parameters:

what (str) – Which keys to get. Can be “projections”, “flats”, “darks”

Returns:

slices – A list where each item is a slice.

Return type:

list of slice

get_reduced_flats(method='median', force_reload=False, **reader_kwargs)[source]
get_reduced_darks(method='mean', force_reload=False, **reader_kwargs)[source]
frames_slices(frame_type)[source]

Return a list of slice objects corresponding to the data corresponding to “frame_type”. For example, if the dataset flats are located at indices [1, 2, …, 99], then frame_slices(“flats”) will return [slice(0, 100)].

get_reader(**kwargs)[source]
nabu.resources.dataset_analyzer.analyze_dataset(dataset_path, extra_options=None, logger=None)[source]
nabu.resources.dataset_analyzer.get_radio_pair(dataset_info, radio_angles: tuple, return_indices=False)[source]

Get closest radios at radio_angles[0] and radio_angles[1] angles must be in angles

Parameters:
  • dataset_info (DatasetAnalyzer instance) – Data structure with the dataset information

  • radio_angles (tuple) – tuple of two elements: angles (in radian) to get

  • return_indices (bool, optional) – Whether to return radios indices along with the radios array.

Returns:

res – If return_indices is True, return a tuple (radios, indices). Otherwise, return an array with the radios.

Return type:

array or tuple