tomoscan.esrf.scan.nxtomoscan.HDF5XRD3DScan

class tomoscan.esrf.scan.nxtomoscan.HDF5XRD3DScan(*args, **kwargs)

Bases: NXtomoScan

Class used to read nexus file representing a 3D-XRD acquisition.

__init__(*args, **kwargs)

Methods

__init__(*args, **kwargs)

clear_caches()

clear caches.

clear_frames_caches()

compute_reduced_darks([reduced_method, ...])

param ReduceMethod method:

method to compute the flats

compute_reduced_flats([reduced_method, ...])

param ReduceMethod method:

method to compute the flats

equal(other)

:param ScanBase other: instance to compare with :return: True if instance are equivalent

flat_field_correction(projs, proj_indexes[, ...])

Apply flat field correction on the given data

from_dict(_dict)

from_identifier(identifier)

Return the Dataset from a identifier

get_bounding_box([axis])

Return the bounding box covered by the Tomo object axis is expected to be in (0, 1, 2) or (x==0, y==1, z==2)

get_dark_expected_location()

get_dataset_basename()

get_detector_data_path()

get_detector_transformations(default)

get_distance([unit])

param Union[MetricSystem, str] unit:

unit requested for the distance

get_distance_expected_location()

get_energy_expected_location()

get_flat_expected_location()

get_identifier()

return the dataset identifier of the scan.

get_master_file(scan_path)

get_pixel_size([unit])

get_pixel_size_expected_location()

get_proj_angle_url()

return a dictionary of all the projection.

get_projection_expected_location()

get_projections_intensity_monitor()

return intensity monitor values for projections

get_relative_file(file_name[, ...])

param str file_name:

name of the file to create

get_sinogram(line[, subsampling, norm_method])

extract the sinogram from projections

get_valid_entries(file_path)

return the list of 'Nxtomo' entries at the root level

get_volume_output_file_name([z, suffix])

if used by tomwer and nabu this should help for tomwer to find out the output files of anbu from a configuration file.

get_x_flipped([default])

get_y_flipped([default])

is_abort(**kwargs)

return:

True if the acquisition has been abort

is_tomoscan_dir(directory, **kwargs)

Check if the given directory is holding an acquisition

load_from_dict(_dict)

Load properties contained in the dictionnary.

load_reduced_darks([inputs_urls, ...])

load reduced dark (median / mean...) into files

load_reduced_flats([inputs_urls, ...])

load reduced dark (median / mean...) into files

map_urls_on_scan_range(urls, n_projection, ...)

map given urls to an angle regarding scan_range and number of projection.

node_is_nxtomo(node)

check if the given h5py node is an nxtomo node or not

save_reduced_darks(darks[, output_urls, ...])

Dump computed dark (median / mean...) into files

save_reduced_flats(flats[, output_urls, ...])

Dump reduced flats (median / mean...) into files

set_check_behavior([run_check, raise_error, ...])

when user require to access to scan frames NXtomoScan build them (frames property).

set_normed_darks(darks[, darks_infos])

set_normed_flats(flats[, flats_infos])

set_reduced_darks(darks[, darks_infos])

set_reduced_flats(flats[, flats_infos])

to_dict()

return:

convert the TomoScanBase object to a dictionary.

update()

Parse the root folder and files to update informations

Attributes

DICT_PATH_KEY

DICT_TYPE_KEY

REDUCED_DARKS_DATAURLS

REDUCED_DARKS_METADATAURLS

REDUCED_FLATS_DATAURLS

REDUCED_FLATS_METADATAURLS

SCHEME

alignment_projections

dict of projections made for alignment with acquisition index as key None if not found

base_tilt

count_time

dark_n

darks

list of darks files

detector_transformations

return tuple of Transformation affecting the NXdetector

dim_1

dim_2

distance

return sample detector distance in meter

electric_current

Return the sample name

end_time

energy

energy in keV

entry

estimated_cor_frm_motor

return:

Estimated center of rotation estimated from motor position

exposure_time

ff_interval

field_of_view

return:

field of view of the scan. None if unknow else Full or Half

flat_n

flats

list of flats files

frames

return tuple of frames.

group_size

if found dict of projections urls with index during acquisition as key

image_key

image_key_control

instrument_name

return:

instrument name

intensity_monitor

intensity_normalization

magnification

number of projection WITHOUT the return projections

nexus_path

nexus_version

normed_darks

normed_flats

path

return:

path of the scan root folder.

pixel_size

return x pixel size in meter

projections

if found dict of projections urls with index during acquisition as key

projections_compacted

Return a compacted view of projection frames.

reduced_darks

reduced_darks_infos

reduced_flats

reduced_flats_infos

return_projs

rocking

rotation_angle

sample_name

if found dict of projections urls with index during acquisition as key

scan_range

sequence_name

Return the sequence name

source

source_name

source_type

start_time

title

tomo_n

number of projection WITHOUT the return projections

type

return:

type of the scanBase (can be 'edf' or 'hdf5' for now).

x_flipped

warning: deprecated !!!!! return True if the frames are flip through x

x_pixel_size

return x pixel size in meter

x_real_pixel_size

x_translation

y_flipped

warning: deprecated !!!!! return True if the frames are flip through y

y_pixel_size

return y pixel size in meter

y_real_pixel_size

y_translation

z_translation

FRAME_REDUCER_CLASS

alias of HDF5FrameReducer

property alignment_projections: Optional[dict]

dict of projections made for alignment with acquisition index as key None if not found

clear_caches() None

clear caches. Might be call if some data changed after first read of data or metadata

compute_reduced_darks(reduced_method='mean', overwrite=True, output_dtype=<class 'numpy.float32'>, return_info: bool = False)
Parameters:
  • method (ReduceMethod) – method to compute the flats

  • overwrite (bool) – if some flats have already been computed will overwrite them

  • return_info (bool) – do we return (reduced_frames, info) or directly reduced_frames

compute_reduced_flats(reduced_method='median', overwrite=True, output_dtype=<class 'numpy.float32'>, return_info: bool = False)
Parameters:
  • method (ReduceMethod) – method to compute the flats

  • overwrite (bool) – if some flats have already been computed will overwrite them

  • return_info (bool) – do we return (reduced_frames, info) or directly reduced_frames

property darks: Optional[dict]

list of darks files

property detector_transformations: Optional[tuple]

return tuple of Transformation affecting the NXdetector

property distance: Optional[float]

return sample detector distance in meter

property electric_current: Optional[list]

Return the sample name

property energy: Optional[float]

energy in keV

equal(other) bool

:param ScanBase other: instance to compare with :return: True if instance are equivalent

..note:: we cannot use the __eq__ function because this object need to be

pickable

property estimated_cor_frm_motor
Returns:

Estimated center of rotation estimated from motor position

Return type:

Union[None, float]. If return value is in [-frame_width, +frame_width]

property field_of_view
Returns:

field of view of the scan. None if unknow else Full or Half

flat_field_correction(projs: Iterable, proj_indexes: Iterable, line: Optional[int] = None)

Apply flat field correction on the given data

Parameters:
  • projs (Iterable) – list of projection (numpy array) to apply correction on

  • proj_indexes (Iterable data) – list of indexes of the projection in the acquisition sequence. Values can be int or None. If None then the index take will be the one in the middle of the flats taken.

  • line (None or int) – index of the line to apply flat filed. If not provided consider we want to apply flat filed on the entire frame

Returns:

corrected data: list of numpy array

Return type:

list

property flats: Optional[dict]

list of flats files

property frames: Optional[tuple]

return tuple of frames. Frames contains

static from_identifier(identifier)

Return the Dataset from a identifier

get_bounding_box(axis: Optional[Union[str, int]] = None) tuple

Return the bounding box covered by the Tomo object axis is expected to be in (0, 1, 2) or (x==0, y==1, z==2)

get_distance(unit='m') Union[None, float]
Parameters:

unit (Union[MetricSystem, str]) – unit requested for the distance

Returns:

sample / detector distance with the requested unit

get_identifier() ScanIdentifier

return the dataset identifier of the scan. The identifier is insure to be unique for each scan and allow the user to store the scan as a string identifier and to retrieve it later from this single identifier.

get_proj_angle_url() Optional[dict]

return a dictionary of all the projection. key is the angle of the projection and value is the url.

Keys are int for ‘standard’ projections and strings for return projections.

Return dict:

angles as keys, radios as value.

get_projections_intensity_monitor() dict

return intensity monitor values for projections

get_relative_file(file_name: str, with_dataset_prefix=True) Optional[str]
Parameters:
  • file_name (str) – name of the file to create

  • with_dataset_prefix (bool) – If True will prefix the requested file by the dataset name like datasetname_file_name

Returns:

path to the requested file according to the ‘Scan’ / ‘dataset’ location. Return none if Scan has no path

Return type:

Optional[str]

get_sinogram(line, subsampling=1, norm_method: Optional[str] = None, **kwargs) array

extract the sinogram from projections

Parameters:
  • line (int) – which sinogram we want

  • subsampling (int) – subsampling to apply. Allows to skip some io

Returns:

computed sinogram from projections

Return type:

numpy.array

static get_valid_entries(file_path: str) tuple

return the list of ‘Nxtomo’ entries at the root level

Parameters:

file_path (str) –

Returns:

list of valid Nxtomo node (ordered alphabetically)

Return type:

tuple

..note: entries are sorted to insure consistency

static get_volume_output_file_name(z=None, suffix=None)

if used by tomwer and nabu this should help for tomwer to find out the output files of anbu from a configuration file. Could help to get some normalization there

property group_size

if found dict of projections urls with index during acquisition as key

ignore_projections

Extra information for normalization

property instrument_name: Optional[str]
Returns:

instrument name

is_abort(**kwargs)
Returns:

True if the acquisition has been abort

Return type:

bool

static is_tomoscan_dir(directory: str, **kwargs) bool

Check if the given directory is holding an acquisition

Parameters:

directory (str) –

Returns:

does the given directory contains any acquisition

Return type:

bool

load_from_dict(_dict: dict) TomoScanBase

Load properties contained in the dictionnary.

Parameters:

_dict (dict) – dictionary to load

Returns:

self

Raises:

ValueError if dict is invalid

load_reduced_darks(inputs_urls: tuple = (DataUrl(valid=True, scheme='silx', file_path='{scan_prefix}_darks.hdf5', data_path='{entry}/darks/{index}', data_slice=None),), metadata_input_urls=(DataUrl(valid=True, scheme='silx', file_path='{scan_prefix}_darks.hdf5', data_path='{entry}/darks/', data_slice=None),), return_as_url: bool = False, return_info: bool = False) dict

load reduced dark (median / mean…) into files

load_reduced_flats(inputs_urls: tuple = (DataUrl(valid=True, scheme='silx', file_path='{scan_prefix}_flats.hdf5', data_path='{entry}/flats/{index}', data_slice=None),), metadata_input_urls=(DataUrl(valid=True, scheme='silx', file_path='{scan_prefix}_flats.hdf5', data_path='{entry}/flats/', data_slice=None),), return_as_url: bool = False, return_info: bool = False) dict

load reduced dark (median / mean…) into files

property magnification

number of projection WITHOUT the return projections

static map_urls_on_scan_range(urls, n_projection, scan_range) dict

map given urls to an angle regarding scan_range and number of projection. We take the hypothesis that ‘extra projection’ are taken regarding the ‘id19’ policy:

  • If the acquisition has a scan range of 360 then:

    • if 4 extra projection, the angles are (270, 180, 90, 0)

    • if 5 extra projection, the angles are (360, 270, 180, 90, 0)

  • If the acquisition has a scan range of 180 then:

    • if 2 extra projections: the angles are (90, 0)

    • if 3 extra projections: the angles are (180, 90, 0)

..warning:: each url should contain only one radio.

Parameters:
  • urls (dict) – dict with all the urls. First url should be the first radio acquire, last url should match the last radio acquire.

  • n_projection (int) – number of projection for the sample.

  • scan_range (float) – acquisition range (usually 180 or 360)

Returns:

angle in degree as key and url as value

Return type:

dict

Raises:

ValueError if the number of extra images found and scan_range are incoherent

static node_is_nxtomo(node: Group) bool

check if the given h5py node is an nxtomo node or not

property path: Union[None, str]
Returns:

path of the scan root folder.

Return type:

Union[str,None]

property pixel_size: Optional[float]

return x pixel size in meter

property projections: Optional[dict]

if found dict of projections urls with index during acquisition as key

property projections_compacted

Return a compacted view of projection frames.

Returns:

Dictionary where the key is a list of indices, and the value is the corresponding silx.io.url.DataUrl with merged data_slice

Return type:

dict

property sample_name

if found dict of projections urls with index during acquisition as key

save_reduced_darks(darks: dict, output_urls: tuple = (DataUrl(valid=True, scheme='silx', file_path='{scan_prefix}_darks.hdf5', data_path='{entry}/darks/{index}', data_slice=None),), darks_infos=None, metadata_output_urls=(DataUrl(valid=True, scheme='silx', file_path='{scan_prefix}_darks.hdf5', data_path='{entry}/darks/', data_slice=None),), overwrite: bool = False)

Dump computed dark (median / mean…) into files

save_reduced_flats(flats: dict, output_urls: tuple = (DataUrl(valid=True, scheme='silx', file_path='{scan_prefix}_flats.hdf5', data_path='{entry}/flats/{index}', data_slice=None),), flats_infos=None, metadata_output_urls: tuple = (DataUrl(valid=True, scheme='silx', file_path='{scan_prefix}_flats.hdf5', data_path='{entry}/flats/', data_slice=None),), overwrite: bool = False) dict

Dump reduced flats (median / mean…) into files

property sequence_name

Return the sequence name

set_check_behavior(run_check=True, raise_error=False, log_level=30)

when user require to access to scan frames NXtomoScan build them (frames property). Some check can be made during this stage to know if the scan has some broken virtual-dataset (vds) or if the vds is linked to more file than the system might handle.

In this case the ‘vds-check’ can either raise an error or log potential issues with a specific log level

to_dict() dict
Returns:

convert the TomoScanBase object to a dictionary. Used to serialize the object for example.

Return type:

dict

property tomo_n: Optional[int]

number of projection WITHOUT the return projections

property type: str
Returns:

type of the scanBase (can be ‘edf’ or ‘hdf5’ for now).

Return type:

str

update() None

Parse the root folder and files to update informations

property x_flipped: bool

warning: deprecated !!!!! return True if the frames are flip through x

property x_pixel_size: Optional[float]

return x pixel size in meter

property y_flipped: bool

warning: deprecated !!!!! return True if the frames are flip through y

property y_pixel_size: Optional[float]

return y pixel size in meter