islatu.io¶
This module contains:
Parsing functions used to extract information from experimental files.
Classes used to help make parsing more modular. These include the NexusBase class and its children.
- class islatu.io.I07Nexus(local_path: str)[source]¶
Bases:
NexusBase
This class extends NexusBase with methods useful for scraping information from nexus files produced at the I07 beamline at Diamond.
- property background_regions: List[Region]¶
Returns a list of region objects that define the location of background. Currently we just ignore the zeroth region and call the rest of them background regions.
- property default_axis_name: str¶
Returns the name of the default axis.
- property default_axis_type: str¶
Returns the type of our default axis, either being ‘q’, ‘th’ or ‘tth’.
- property detector_distance¶
Returns the distance between sample and detector.
- property detector_name: str¶
Returns the name of the detector that we’re using. Because life sucks, this is a function of time.
- excalibur_04_2022 = 'exr'¶
- excalibur_detector_2021 = 'excroi'¶
- property local_data_path: str¶
The local path to the data (.h5) file. Note that this isn’t in the NexusBase class because it need not be reasonably expected to point at a .h5 file.
- Raises
FileNotFoundError if the data file cant be found. –
- property probe_energy¶
Returns the energy of the probe particle parsed from this NexusFile.
- property signal_regions: List[Region]¶
Returns a list of region objects that define the location of the signal. Currently there is nothing better to do than assume that this is a list of length 1.
- property transmission¶
Proportional to the fraction of probe particles allowed by an attenuator to strike the sample.
- class islatu.io.NexusBase(local_path: str)[source]¶
Bases:
Metadata
This class contains mostly beamline agnostic nexus parsing convenience stuff. It’s worth noting that this class still makes a series of assumptions about how data is laid out in a nexus file that can be broken. Instead of striving for some impossible perfection, this class is practical in its assumptions of how data is laid out in a .nxs file, and will raise if an assumption is violated. All instrument-specific assumptions that one must inevitably make to extract truly meaningful information from a nexus file are made in children of this class.
- Attrs:
- file_path:
The local path to the file on the local filesystem.
- nxfile:
The object produced by loading the file at file_path with nxload.
- property default_axis: ndarray¶
Returns the nxdata associated with the default axis.
- property default_axis_name: str¶
Returns the name of the default axis.
- abstract property default_axis_type: str¶
Returns what type of default axis we have. Options are ‘q’, ‘th’ or ‘tth’.
- property default_nxdata: ndarray¶
Returns the default NXdata.
- property default_nxdata_name¶
Returns the name of the default nxdata.
- property default_signal: ndarray¶
The numpy array of intensities pointed to by the signal attribute in the nexus file.
- property default_signal_name¶
Returns the name of the default signal.
- property detector¶
Returns the NXdetector instance stored in this NexusFile.
- Raises
ValueError if more than one NXdetector is found. –
- property entry: NXentry¶
Returns this nexusfile’s entry.
- Raises
ValueError if more than one entry is found. –
- property instrument¶
Returns the NXinstrument instanced stored in this NexusFile.
- Raises
ValueError if more than one NXinstrument is found. –
- property src_path¶
The name of this nexus file, as it was recorded when the nexus file was written.
- islatu.io.i07_dat_to_dict_dataframe(file_path)[source]¶
Parses a .dat file recorded by I07, returning a [now mostly obsolete] tuple containing a metadata dictionary and a pandas dataframe of the data.
Though outdated, this is still a handy way to parse the DCD normalization .dat file.
:param (
str
): The.dat
file to be read.- Returns
- Containing:
dict
: The metadata from the.dat
file.pandas.DataFrame
: The data from the.dat
file.
- Return type
tuple
- islatu.io.i07_nxs_parser(file_path: str)[source]¶
Parses a .nxs file acquired from the I07 beamline at diamond, returning an instance of Scan2D. This process involves loading the images contained in the .h5 file pointed at by the .nxs file, as well as retrieving the metadata from the .nxs file that is relevant for XRR reduction.
- Parameters
file_path – Path to the .nxs file.
- Returns
An initialized Scan2D object containing all loaded detector frames, as well as the relevant metadata from the .nxs file.