easistrain.id15_NXstress.NXstress_conv.NXstressFromRaw

class easistrain.id15_NXstress.NXstress_conv.NXstressFromRaw(file_path, det_calib_file_energy, det_calib_file_angle, lattice, phase_name, experimental_identifier, collection_identifier, with_cradle=False, scanNbForRotation=None, test_script=False)[source]

Bases: object

check_detector(raw_file, raw_file_entry, idx, detector_index)[source]

Checks if the detector data at a specified index passes a certain threshold criterion. This method is used to verify if the maximum value in a diffractogram is above a defined limit (1000), indicating that the data is significant enough for further processing.

Args: - raw_file: The HDF5 file handle containing the measurement data. - raw_file_entry: The specific entry in the HDF5 file to be processed. - idx: The index within the entry indicating the specific dataset to check. - detector_index: The index of the detector being checked.

Returns: - passes_check: A boolean value indicating whether the data passes the threshold check.

create_beam_intensity_profile(output_file, entry_name)[source]

Creates a ‘beam_intensity_profile’ subgroup within a specified entry in an HDF5 file. This subgroup is designed to store detailed settings and parameters that define the beam intensity profile used during the experiment.

Parameters: - output_file: The HDF5 file object open for writing. - entry_name: The name of the entry under which the beam intensity profile group is created.

The method organizes the subgroup according to the NeXus NXcollection class, documenting various parameters related to primary and secondary beam shaping elements such as slits. Attributes such as type, full width, width, and distance for both primary and secondary vertical and horizontal beam components are defined, ensuring precise documentation of the experimental setup. This structured data supports reproducibility and detailed analysis of experimental conditions.

create_entry_datasets(output_file, raw_file_entry, entry_name)[source]

Creates and populates datasets within a new entry in the output HDF5 file. This method sets various attributes and datasets to comply with the NeXus NXstress standard for data representation, including time stamps, experiment identifiers, and data types.

Args: - output_file: The HDF5 file object where data should be written. - raw_file_entry: The entry from the raw data file used as a source for some datasets. - entry_name: The name of the new entry being created in the output file.

The method initializes an entry group and populates it with metadata and data relevant to the stress analysis experiments conducted.

create_fit_subgroup(output_file, entry_name)[source]

Creates a ‘fit’ subgroup within a specified entry in an HDF5 file, organizing and storing various fit-related data and parameters processed during a diffraction analysis. This subgroup includes detailed datasets for fit parameters, background parameters, and a comprehensive description of the fitting process.

Parameters: - output_file: The HDF5 file object open for writing. - entry_name: The name of the entry under which the fit group is created.

The method structures the subgroup according to the NeXus NXprocess class, defining data for each fit parameter along with its uncertainty. It captures the diffractogram, associated fitted data, and background data, along with residual calculations. It also manages data on peak analysis parameters, such as area, center, and full width at half maximum (FWHM), ensuring that all parameters and their errors are accurately documented. The organization and labeling of the data adhere to standards that facilitate subsequent data retrieval and analysis.

create_instrument_subgroup(output_file, entry_name)[source]

Constructs an instrument subgroup in the HDF5 output file under a specified entry. This subgroup contains detailed descriptions and settings for the instrument components, including detectors, slits, and the source, all formatted according to NeXus standards.

Parameters: - output_file: The HDF5 file object open for writing. - entry_name: The name of the entry under which the instrument group is created.

This method sets up the structure and populates it with information regarding the instrument configuration used during the experiment, ensuring that all components like detectors, slits, and source are accurately represented.

create_peaks_subgroup(output_file, entry_name, sx_value, sy_value, sz_value, detector_index)[source]

Creates and populates a ‘peaks’ subgroup within a given entry in an HDF5 file. This subgroup stores detailed diffraction and position data for one or more peaks, formatted according to the NeXus NXdata standard. This method supports analyses that involve multiple peaks, dynamically adapting to the number of peaks specified.

Parameters: - output_file: The HDF5 file object open for writing. - entry_name: The name of the entry under which the peaks group is created. - sx_value: The sx position value for the peak(s). Supports both single and multiple values. - sy_value: The sy position value for the peak(s). Supports both single and multiple values. - sz_value: The sz position value for the peak(s). Supports both single and multiple values. - detector_index: Index specifying which detector’s settings to use for azimuth and polar angles.

This method ensures that each peak’s spatial and diffraction data are correctly recorded, including auxiliary signals and transformation metadata, while accommodating setups with multiple peak analyses.

create_sample_subgroup(output_file, raw_file_entry, entry_name, sx_value, sy_value, sz_value)[source]

Creates a sample subgroup within the given entry in the HDF5 output file, defining the sample’s position and orientation transformations.

Args: - output_file: The HDF5 file handle where the subgroup is to be created. - raw_file_entry: The entry from the raw data file used as a source for sample information. - entry_name: The name of the entry under which the subgroup is created. - sx_value: The x-coordinate value of the sample’s position. - sy_value: The y-coordinate value of the sample’s position. - sz_value: The z-coordinate value of the sample’s position.

This method sets up a structured way of storing transformation data for the sample related to its position and orientation, following the NXsample and NXtransformations classes.

extract_angle_calib(file_path)[source]
extract_energy_calib(file_path)[source]
find_dataset(group, dataset_name)[source]

Recursively searches all subgroups of the given group for the dataset. Returns the dataset if found, or None if not found.

get_positioners(raw_file, raw_file_entry)[source]

Extracts the positioner values from a specific entry in the provided HDF5 file. Assumes raw_file is an open HDF5 file.

Args:

raw_file: Opened HDF5 file object. raw_file_entry (str): The entry key within the HDF5 file.

Returns:

tuple: Contains the positioner values (sx, sy, sz, phi, chi & omega).

initial_prompts(raw_file, raw_file_entry, idx)[source]

Handles initial data prompting for peak and hkl value selection based on detector data. Launches GUI prompts to set peak fitting ranges and hkl values if needed.

Args: - raw_file: The HDF5 file handle containing the measurement data. - raw_file_entry: The specific entry in the HDF5 file to be processed. - idx: The index representing the specific dataset within the entry to process.

main()[source]

Main processing method for handling NX stress analysis on translation, radial, and potentially horizontal datasets based on the specified scan number for rotation. The method prepares output files, processes entries from the raw file, and handles different data processing modes based on the presence of rotational data.

This method organizes data processing into translational and radial outputs by default, and includes horizontal outputs if a rotation scan number is specified.

perform_fit()[source]

Performs fitting operations on selected ranges of the diffractogram. Each range is analyzed to extract peak parameters and background based on predefined settings and the number of peaks to be fitted within each segment.

Returns: - results: A dictionary containing arrays of fit parameters, uncertainties, background data,

and the actual fitted data for each processed range.

This method leverages the fit_detector_data function to apply fitting procedures to the segments of the diffractogram specified by rangeFit.

process_scan(output_file_name, raw_file_entry, detector_index)[source]

Processes the specified HDF5 file to evaluate and record diffractogram data for given positioners and detectors. This method also initiates data processing such as peak fitting and intensity profile creation if certain conditions are met.

Args: - output_file_name: Name of the output HDF5 file where results are stored. - raw_file_entry: The entry in the HDF5 file corresponding to the dataset being processed. - detector_index: Index of the detector used to fetch the diffractogram data.

The method checks if the diffractogram passes a specified value check, prompts for additional input if necessary, and creates structured entries in an output file based on the processed data.