XSpect package
+Submodules
+XSpect.XSpect_Analysis module
+-
+
- +class XSpect.XSpect_Analysis.SpectroscopyAnalysis[source] +
Bases:
+objectA class to perform analysis on spectroscopy data.
+-
+
- +bin_uniques(run, key)[source] +
Bins unique values for a given key within a run.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- keystr
The key for which unique values are to be binned.
+
+
-
+
- +filter_detector_adu(run, detector, adu_threshold=3.0)[source] +
Filters is a misnomer compared to the other filter functions. +This sets detector pixel values below a threshold to 0. +Specifically, to remove 0-photon noise from detectors.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- detectorstr
The key corresponding to the detector data.
+
+- adu_thresholdfloat or list of float, optional
The ADU threshold for filtering. Can be a single value or a range (default is 3.0).
+
+
+ +Returns
+-
+
- np.ndarray
The filtered detector data.
+
+
-
+
- +filter_nan(run, shot_mask_key, filter_key='ipm')[source] +
A specific filtering implementation for Nans due to various DAQ issues. +Filters out shots with NaN values in the specified filter.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- shot_mask_keystr
The key corresponding to the shot mask.
+
+- filter_keystr, optional
The key corresponding to the filter data (default is ‘ipm’).
+
+
-
+
- +filter_shots(run, shot_mask_key, filter_key='ipm', threshold=10000.0)[source] +
Filters shots based on a given threshold.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- shot_mask_keystr
The key corresponding to the shot mask. An example being [xray,simultaneous,laser] for all x-ray shots
+
+- filter_keystr, optional
The key corresponding to the filter data (default is ‘ipm’).
+
+- thresholdfloat, optional
The threshold value for filtering (default is 1.0E4).
+
+
So if we filter: xray,ipm,1E4 then X-ray shots will be filtered out if the ipm is below 1E4.
+
-
+
- +patch_pixel(run, detector_key, pixel, mode='average', patch_range=4, deg=1, poly_range=6, axis=1)[source] +
EPIX detector pixel patching. +TODO: extend to patch regions instead of per pixel. +Parameters +———- +data : array_like
++
+Array of shots
+-
+
- pixelinteger
Pixel point to be patched
+
+- modestring
Determined which mode to use for patching the pixel. Averaging works well.
+
+- patch_rangeinteger
pixels away from the pixel to be patched to be used for patching. Needed if multiple pixels in a row are an issue.
+
+- deginteger
Degree of polynomial if polynomial patching is used.
+
+- poly_rangeinteger
Number of pixels to include in the polynomial or interpolation fitting
+
+
+ +Returns
+-
+
- float
The original data with the new patch values.
+
+
-
+
- +patch_pixel_1d(run, detector_key, pixel, mode='average', patch_range=4, deg=1, poly_range=6)[source] +
EPIX detector pixel patching. +TODO: extend to patch regions instead of per pixel. +Parameters +———- +data : array_like
++
+Array of shots
+-
+
- pixelinteger
Pixel point to be patched
+
+- modestring
Determined which mode to use for patching the pixel. Averaging works well.
+
+- patch_rangeinteger
pixels away from the pixel to be patched to be used for patching. Needed if multiple pixels in a row are an issue.
+
+- deginteger
Degree of polynomial if polynomial patching is used.
+
+- poly_rangeinteger
Number of pixels to include in the polynomial or interpolation fitting
+
+
+ +Returns
+-
+
- float
The original data with the new patch values.
+
+
-
+
- +patch_pixels(run, detector_key, mode='average', patch_range=4, deg=1, poly_range=6, axis=1)[source] +
Patches multiple pixels in detector data.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- modestr, optional
The mode of patching (‘average’, ‘polynomial’, or ‘interpolate’).
+
+- patch_rangeint, optional
The range around the pixel to use for patching (default is 4).
+
+- degint, optional
The degree of the polynomial for polynomial patching (default is 1).
+
+- poly_rangeint, optional
The range of pixels to use for polynomial or interpolation patching (default is 6).
+
+- axisint, optional
The axis along which to apply the patching (default is 1).
+
+
-
+
- +patch_pixels_1d(run, detector_key, mode='average', patch_range=4, deg=1, poly_range=6)[source] +
Patches multiple pixels in 1D detector data.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- modestr, optional
The mode of patching (‘average’, ‘polynomial’, or ‘interpolate’).
+
+- patch_rangeint, optional
The range around the pixel to use for patching (default is 4).
+
+- degint, optional
The degree of the polynomial for polynomial patching (default is 1).
+
+- poly_rangeint, optional
The range of pixels to use for polynomial or interpolation patching (default is 6).
+
+
-
+
- +purge_keys(run, keys)[source] +
Purges specific keys from the run to save memory. +This is specifically to remove the epix key immediately after processing it from the hdf5 file. +To avoid OOM. This is different than the purge all keys method which is used to purge many of the larger analysis steps.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- keyslist of str
The list of keys to purge.
+
+
-
+
- +reduce_detector_shots(run, detector_key, reduction_function=<function sum>, purge=True)[source] +
-
+
- +reduce_detector_spatial(run, detector_key, shot_range=[0, None], rois=[[0, None]], reduction_function=<function sum>, purge=True, combine=True)[source] +
Reduces the spatial dimension of detector data based on specified ROIs.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- shot_rangelist, optional
The range of shots to consider (default is [0, None]).
+
+- roislist of lists, optional
The list of ROIs (regions of interest) as pixel ranges (default is [[0, None]]).
+
+- reduction_functionfunction, optional
The function to apply for reduction (default is np.sum).
+
+- purgebool, optional
Whether to purge the original detector data after reduction (default is True).
+
+- combinebool, optional
Whether to combine ROIs (default is True).
+
+
-
+
- +reduce_detector_temporal(run, detector_key, timing_bin_key_indices, average=False)[source] +
Reduces the temporal dimension of detector data based on timing bins.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- timing_bin_key_indicesstr
The key corresponding to the timing bin indices.
+
+- averagebool, optional
Whether to average the data within each bin (default is False).
+
+
-
+
- +separate_shots(run, detector_key, filter_keys)[source] +
Separates shots into different datasets based on filters. +separate_shots(f,’epix_ROI_1’,[‘xray’,’laser’]) means find me the epix_ROI_1 images in shots that were X-ray but NOT laser. +If you wanted the inverse you would switch the order of the filter_keys.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- filter_keyslist of str
The list of filter keys to separate.
+
+
-
+
- +time_binning(run, bins, lxt_key='lxt_ttc', fast_delay_key='encoder', tt_correction_key='time_tool_correction')[source] +
Bins data in time based on specified bins.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- binsarray-like
The bins to use for time binning.
+
+- lxt_keystr, optional
The key for the laser time delay data (default is ‘lxt_ttc’).
+
+- fast_delay_keystr, optional
The key for the fast delay data (default is ‘encoder’).
+
+- tt_correction_keystr, optional
The key for the time tool correction data (default is ‘time_tool_correction’).
+
+
-
+
- +union_shots(run, detector_key, filter_keys)[source] +
Combines shots across multiple filters into a single array. +So union_shots(f,’timing_bin_indices’,[‘simultaneous’,’laser’]) +means go through the timing_bin_indices and find the ones that correspond to X-rays and laser shots.
++ +Parameters
+-
+
- runspectroscopy_run
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- filter_keyslist of str
The list of filter keys to combine.
+
+
-
+
- +class XSpect.XSpect_Analysis.XASAnalysis[source] +
Bases:
+SpectroscopyAnalysis-
+
- +ccm_binning(run, ccm_bins_key, ccm_key='ccm')[source] +
Generate CCM bin indices from CCM data and bins.
++ +Parameters
+-
+
- runobject
The spectroscopy run instance.
+
+- ccm_bins_keystr
The key corresponding to the CCM bins.
+
+- ccm_keystr, optional
The key corresponding to the CCM data (default is ‘ccm’).
+
+
-
+
- +make_ccm_axis(run, energies)[source] +
Generate CCM bins and centers from given energy values.
++ +Parameters
+-
+
- runobject
The spectroscopy run instance.
+
+- energiesarray-like
Array of energy values to be used for creating CCM bins.
+
+
-
+
- +reduce_detector_ccm(run, detector_key, ccm_bin_key_indices, average=False, not_ccm=False)[source] +
Reduce detector data by CCM bins.
++ +Parameters
+-
+
- runobject
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- ccm_bin_key_indicesstr
The key corresponding to the CCM bin indices.
+
+- averagebool, optional
Whether to average the reduced data (default is False).
+
+- not_ccmbool, optional
Whether to indicate that CCM is not being used (default is False).
+
+
-
+
- +reduce_detector_ccm_temporal(run, detector_key, timing_bin_key_indices, ccm_bin_key_indices, average=True)[source] +
Reduce detector data temporally and by CCM bins.
++ +Parameters
+-
+
- runobject
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- timing_bin_key_indicesstr
The key corresponding to the timing bin indices.
+
+- ccm_bin_key_indicesstr
The key corresponding to the CCM bin indices.
+
+- averagebool, optional
Whether to average the reduced data (default is True).
+
+
-
+
- +reduce_detector_temporal(run, detector_key, timing_bin_key_indices, average=False)[source] +
Reduce detector data temporally. Specifically the 1d detector output for XAS data.
++ +Parameters
+-
+
- runobject
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- timing_bin_key_indicesstr
The key corresponding to the timing bin indices.
+
+- averagebool, optional
Whether to average the reduced data (default is False).
+
+
-
+
- +class XSpect.XSpect_Analysis.XESAnalysis(xes_line='kbeta')[source] +
Bases:
+SpectroscopyAnalysis-
+
- +make_energy_axis(run, energy_axis_length, A, R, mm_per_pixel=0.05, d=0.895)[source] +
Determination of energy axis by pixels and crystal configuration
++ +Parameters
+-
+
- Afloat
The detector to vH distance (mm) and can roughly float. This will affect the spectral offset.
+
+- Rfloat
The vH crystal radii (mm) and should not float. This will affect the spectral stretch.
+
+- pixel_arrayarray-like
Array of pixels to determine the energy of.
+
+- dfloat
Crystal d-spacing. To calculate, visit: spectra.tools/bin/controller.pl?body=Bragg_Angle_Calculator
+
+
-
+
- +normalize_xes(run, detector_key, pixel_range=[300, 550])[source] +
Normalize XES data by summing the signal over a specified pixel range.
++ +Parameters
+-
+
- runobject
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- pixel_rangelist of int, optional
The pixel range to sum over for normalization (default is [300, 550]).
+
+
-
+
- +reduce_det_scanvar(run, detector_key, scanvar_key, scanvar_bins_key)[source] +
Reduce detector data by binning according to an arbitrary scan variable.
+This method bins the detector data based on a specified scan variable and its corresponding bins. +The result is stored in the run object under a new attribute.
++ +Parameters
+-
+
- runobject
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data within the run object.
+
+- scanvar_keystr
The key corresponding to the scan variable indices.
+
+- scanvar_bins_keystr
The key corresponding to the scan variable bins.
+
+
+ +Returns
+-
+
- None
The reduced data is stored in the run object with the key formatted as {detector_key}_scanvar_reduced.
+
+
-
+
- +reduce_detector_spatial(run, detector_key, shot_range=[0, None], rois=[[0, None]], reduction_function=<function sum>, purge=True, combine=True, adu_cutoff=3.0)[source] +
Reduce spatial dimensions of detector data by combining or applying reduction functions over regions of interest (ROIs).
++ +Parameters
+-
+
- runobject
The spectroscopy run instance.
+
+- detector_keystr
The key corresponding to the detector data.
+
+- shot_rangelist of int, optional
The range of shots to consider for reduction (default is [0, None]).
+
+- roislist of lists of int, optional
The regions of interest for spatial reduction (default is [[0, None]]).
+
+- reduction_functionfunction, optional
The function to use for reduction (default is np.sum).
+
+- purgebool, optional
Whether to purge the original detector data after reduction (default is True).
+
+- combinebool, optional
Whether to combine ROIs into a single reduced dataset (default is True).
+
+- adu_cutofffloat, optional
The ADU cutoff value for filtering (default is 3.0).
+
+
-
+
- +class XSpect.XSpect_Analysis.experiment(lcls_run, hutch, experiment_id)[source] +
Bases:
+object-
+
- +get_experiment_directory()[source] +
Determines and returns the directory of the experiment based on the hutch and experiment ID. +It attempts the various paths LCLS has had over the years with recent S3DF paths being the first attempt.
++ +Returns
+-
+
- str
The directory of the experiment.
+
+
+ +Raises
+-
+
- Exception
If the directory cannot be found.
+
+
-
+
- +class XSpect.XSpect_Analysis.spectroscopy_experiment(*args, **kwargs)[source] +
Bases:
+experimentA class to represent a spectroscopy experiment. +Trying to integrate methods that incorporate meta parameters of the experiment but did not follow through.
+ + +
-
+
- +class XSpect.XSpect_Analysis.spectroscopy_run(spec_experiment, run, verbose=False, end_index=-1, start_index=0)[source] +
Bases:
+objectA class to represent a run within a spectroscopy experiment. Not and LCLS run.
+ + +-
+
- +get_run_shot_properties()[source] +
Retrieves shot properties from the run file, including total shots and simultaneous laser and X-ray shots.
+
-
+
- +get_scan_val()[source] +
Retrieves the scan variable from the HDF5 file of the run. +This is specifically for runengine scans that tag the variable in the hdf5 file. E.g. useful for processing alignment scans
+
-
+
- +load_run_key_delayed(keys, friendly_names, transpose=False, rois=None, combine=True)[source] +
Loads specified keys from the run file into memory without immediate conversion to numpy arrays. +Supports applying multiple ROIs in one dimension that can be combined into a single mask or handled separately.
++ +Parameters
+-
+
- keyslist
List of keys to load.
+
+- friendly_nameslist
Corresponding list of friendly names for the keys.
+
+- transposebool, optional
Flag to transpose the loaded data. Defaults to False.
+
+- roislist of lists, optional
List of ROIs (regions of interest) as pixel ranges along one dimension (default is None). +Each ROI should be in the form [start_col, end_col].
+
+- combinebool, optional
Whether to combine ROIs into a single mask. Defaults to True.
+
+
-
+
- +load_run_keys(keys, friendly_names)[source] +
Loads specified keys from the run file into memory.
++ +Parameters
+-
+
- keyslist
List of keys to load from the hdf5 file
+
+- friendly_nameslist
Corresponding list of friendly names for the keys. Some keys are special to the subsequent analyis e.g. epix and ipm.
+
+
-
+
- +load_sum_run_scattering(key, low=20, high=80)[source] +
Sums the scattering data across the specified range.
++ +Parameters
+-
+
- keystr
The key to sum the scattering data from.
+
+- lowint
Low index for summing
+
+- high: int
high index for summing +These indices should be chosen over the water ring or some scattering of interest.
+
+
XSpect.XSpect_Controller module
+-
+
- +class XSpect.XSpect_Controller.BatchAnalysis(verbose=False)[source] +
Bases:
+ + + + + + + + + + + + +object-
+
- +primary_analysis_parallel_range(cores, experiment, increment, start_index=None, end_index=None, verbose=False, method=None)[source] +
-
+
- +class XSpect.XSpect_Controller.ScanAnalysis_1D(*args, **kwargs)[source] +
Bases:
+ + +BatchAnalysis
-
+
- +class XSpect.XSpect_Controller.ScanAnalysis_1D_XES(*args, **kwargs)[source] +
Bases:
+ + +BatchAnalysis
-
+
- +class XSpect.XSpect_Controller.XASBatchAnalysis(*args, **kwargs)[source] +
Bases:
+ + +BatchAnalysis
-
+
- +class XSpect.XSpect_Controller.XASBatchAnalysis_1D_ccm(*args, **kwargs)[source] +
Bases:
+ + +BatchAnalysis
-
+
- +class XSpect.XSpect_Controller.XASBatchAnalysis_1D_time(*args, **kwargs)[source] +
Bases:
+ + +BatchAnalysis
-
+
- +class XSpect.XSpect_Controller.XESBatchAnalysis[source] +
Bases:
+ + +BatchAnalysis
-
+
- +class XSpect.XSpect_Controller.XESBatchAnalysisRotation[source] +
Bases:
+ + + + + + + + + + +XESBatchAnalysis
XSpect.XSpect_Diagnostics module
+ + + + +XSpect.XSpect_PostProcessing module
+-
+
- +class XSpect.XSpect_PostProcessing.analysis_functions[source] +
Bases:
+ + + + + + + + + + + + + + +object
-
+
- +class XSpect.XSpect_PostProcessing.post_analysis[source] +
Bases:
+ + + + + + + + + + + + + + + + +analysis_functions
XSpect.XSpect_Visualization module
+ + +-
+
- +class XSpect.XSpect_Visualization.XASVisualization[source] +
Bases:
+ + + + + + + + + + +SpectroscopyVisualization
-
+
- +class XSpect.XSpect_Visualization.XESVisualization[source] +
Bases:
+ + + + + + + + +SpectroscopyVisualization
