mlreflect.xrrloader package
Subpackages
Module contents
- class mlreflect.xrrloader.FioLoader(file_stem: str, beam_width: float, sample_length: float, two_theta_counter='tt', default_roi_name='p100k_roi1', beam_shape='gauss', normalize_to='max', attenuator_counter='atten_position', division_counter=None)[source]
Bases:
mlreflect.xrrloader.dataloader.reflectivity_loader.ReflectivityLoader
Read .fio files and associated detector images and extract reflectivity scans.
- Parameters
file_stem – The name of the experiment including the preceding folder structure. E.g. if you’re experiment name is
'my_data'
and in the folder'user/data/'
, the file stem would be'user/data/my_data'
. This will look for all scans in the folder'user/data/'
that begin with'my_data'
.two_theta_counter – Name of the counter that contains the full scattering angle (default:
'tt'
).default_roi_name – Counter name of the default region of interest that is extracted as reflectivity (default:
'p100k'). –
beam_width – Beam width for a rectangular approximation or FWHM of a Gaussian approximation in units of mm.
sample_length – Sample length in beam direction in units of mm.
beam_shape – Beam shape approximation. Either
'box'
or'gauss'
(default).normalize_to – To what intensity value the curve is normalized to after footprint correction. Either
'first'
or'max'
(default).attenuator_counter – Optional column name of the attenuator values for intensity correction.
division_counter – Optional name of a column that the intensity is divided by after attenuator correction.
- load_scan(scan_number: int, trim_front: Optional[int] = None, trim_back: Optional[int] = None, roi: Optional[list] = None, detector_name='p100k') mlreflect.xrrloader.dataloader.scans.ReflectivityScan [source]
Read .fio files and associated detector images, trim it and return it in a
ReflectivityScan
object.- Parameters
scan_number – Number of the scan to extract.
trim_front – Number of measurement points that are cut off at the beginning of the scan (e.g. to remove the direct beam).
trim_back – Number of measurement points that are cut off at the end of the scan.
roi – Alternative region of interest in the raw detector image that will be converted to a reflectivity curve. The roi specifications must be a list of integers that specify the pixel boundaries in the format
[left, bottom, right, top]
, e.g.roi=[241, 106, 247, 109]
. This will override the default roi counter.detector_name – Name of the detector from which the roi is extracted.
Returns:
ReflectivityScan
- load_scans(scan_numbers: Iterator, trim_front: Optional[int] = None, trim_back: Optional[int] = None, roi: Optional[list] = None) mlreflect.xrrloader.dataloader.scans.ScanSeries [source]
Read several reflectivity scans and return them in a
ScanSeries
object.
- class mlreflect.xrrloader.FioParser(file_stem: str, theta_name: str = 'om', two_theta_name: str = 'tt')[source]
Bases:
object
Parse data from .fio files and their corresponding detector image files within a folder
- Parameters
file_stem – The name of the experiment including the preceding folder structure. E.g. if you’re experiment name is
'my_data'
and in the folder'user/data/'
, the file stem would be'user/data/my_data'
. This will look for all scans in the folder'user/data/'
that begin with'my_data'
.theta_name – Name of the counter that contains half the scattering angle (default:
'om'
).two_theta_name – Name of the counter that contains the full scattering angle (default:
'tt'
).
- extract_scan(scan_number: int) mlreflect.xrrloader.p08tools.P08ScanTools.Scan [source]
Extract the data of the entire image stack for the given scan into a
Scan
object.
- property fio_path_list
- property number_of_scans
- parse_fio(scan_number: int) dict [source]
Extract the data of a given scan (including header) into a dictionary.
- property scan_info
- property scan_numbers
- exception mlreflect.xrrloader.NotReflectivityScanError[source]
Bases:
Exception
Exception if a scan is not a theta2theta or reflectivity scan.
- class mlreflect.xrrloader.ReflectivityScan(scan_number: int, scattering_angle: numpy.ndarray, intensity: numpy.ndarray, wavelength: float, beam_width: float, sample_length: float, beam_shape: str = 'gauss', normalize_to: str = 'max', timestamp: Optional[str] = None)[source]
Bases:
object
Store information about a loaded scan and perform a basic footprint correction.
- Parameters
scan_number – Scan number for identification (usually derived from SPEC scan number).
scattering_angle – Full scattering angle (2theta) in degrees for each intensity value.
intensity – Continuous raw intensity values (including attenuator correction).
wavelength – Wavelength in units of angstroms.
beam_width – Beam width for a rectangular approximation or FWHM of a Gaussian approximation in units of mm.
sample_length – Sample length in beam direction in units of mm.
beam_shape – Beam shape approximation. Either ‘box’ or ‘gauss’ (default).
normalize_to – To what intensity value the curve is normalized to after footprint correction. Either
‘first’ or ‘max’ (default). :param timestamp: Timestamp of when the scan was taken in the SPEC format (e.g. “Wed Apr 28 09:32:45 2010”).
- property corrected_intensity
- get_corrected_intensity_range(q_min: Optional[float] = None, q_max: Optional[float] = None)[source]
Get corrected intensity between q_min and q_max.
- get_interpolated_intensity(new_q: numpy.ndarray)[source]
Interpolate log10 values of the corrected intensity to new values new_q.
- get_q_range(q_min: Optional[float] = None, q_max: Optional[float] = None)[source]
Get q values between q_min and q_max.
- get_raw_intensity_range(q_min: Optional[float] = None, q_max: Optional[float] = None)[source]
Get raw intensity between q_min and q_max.
- plot_corrected_intensity(q_min: Optional[float] = None, q_max: Optional[float] = None)[source]
Plot corrected intensity within given q range.
- plot_raw_intensity(q_min: Optional[float] = None, q_max: Optional[float] = None)[source]
Plot raw intensity within given q range.
- property q
- class mlreflect.xrrloader.ScanSeries(iterable=(), /)[source]
Bases:
list
Store a series of Scan objects in a list-like object.
- append(scan: mlreflect.xrrloader.dataloader.scans.ReflectivityScan)[source]
Append object to the end of the list.
- plot_series(scan_range: Optional[Iterable] = None, q_min: Optional[float] = None, q_max: Optional[float] = None, legend: bool = True)[source]
Plot all or a subset of scans of the series within the given q range.
- property stats
- class mlreflect.xrrloader.SpecLoader(file_path: str, angle_columns: list, intensity_column: str, wavelength: float, beam_width: float, sample_length: float, beam_shape='gauss', normalize_to='max', attenuator_column=None, division_column=None)[source]
Bases:
mlreflect.xrrloader.dataloader.reflectivity_loader.ReflectivityLoader
Read SPEC file and extract reflectivity scans.
- Parameters
file_path – Full file path of the SPEC file.
angle_columns – List of column names of the angles in the SPEC file. If multiple are given, their absolute values are summed up to form the full scattering angle 2theta.
intensity_column – Column name of the reflected intensity. Attenuator and monitor correction must already be performed.
wavelength – Photon wavelength in units of angstroms.
beam_width – Beam width for a rectangular approximation or FWHM of a Gaussian approximation in units of mm.
sample_length – Sample length in beam direction in units of mm.
beam_shape – Beam shape approximation. Either
'box'
or'gauss'
(default).normalize_to – To what intensity value the curve is normalized to after footprint correction. Either
'first'
or'max'
(default).attenuator_column – Optional column name of the attenuator values for intensity correction.
division_column – Optional name of a column that the intensity is divided by after attenuator correction.
- load_scan(scan_number: int, trim_front: Optional[int] = None, trim_back: Optional[int] = None) mlreflect.xrrloader.dataloader.scans.ReflectivityScan [source]
Read reflectivity scan from SPEC file, trim it and return it in a
ReflectivityScan
object.
- load_scans(scan_numbers: Iterator, trim_front: Optional[int] = None, trim_back: Optional[int] = None) mlreflect.xrrloader.dataloader.scans.ScanSeries [source]
Read several reflectivity scans from SPEC file, trim them and return them in a
ScanSeries
object.
- class mlreflect.xrrloader.SpecParser(file_path: str)[source]
Bases:
object
Parse individual SPEC file scans on to Pandas DataFrames.
Args: file_path: File path of the SPEC file.
- extract_scan(scan_number)[source]
Extract scan of a given number into a table in the form of a Pandas
DataFrame
.
- property number_of_scans
- property scan_info