lib.backend package¶
Submodules¶
lib.backend.PyNexus module¶
- class lib.backend.PyNexus.PyNexusFile(filename, aliases=None, **keywords)¶
Bases:
objectClass for a SOLEIL Nexus file
- close()¶
Close the Nexus File
- extractAndSave2DData()¶
extract and save the 2D data from scan_data output:
nb_data_saved : numer of data point saved
- extractData(which='all')¶
extract the the data from scan_data Input :
which : value = ‘all’, ‘0D’, ‘1D’, ‘2D’ SPECIFY IF ALL data, or only respectively point (0D), spectrum (1D) or images (2D) have to be extracted.
- output:
- tuple with 2 elements :
stamps : longname of the data data : data itself
- extractDataStamp(which=None)¶
extract the the data from scan_data Input :
which : the stamp of the data to extract
- output:
data : data itself
- extractStamps()¶
extract only the stamps from scan_data Input : output:
stamps : list of the longname of the data
- extract_one_data_point(dataset, num, verbose=True)¶
extract one data point from scan_data input : number of the point output:
the stamp the data point (could be an array)
- extract_scan_data()¶
return all the scan data extracted from the nexus file Input : None Output : a tuple with 2 elements
stamps : the name of the registered quantities
the data itself as a numpy array
- get_nbpts()¶
return the number of points recorded in the nexus file
- saveExtractedData(result)¶
Save all the previously extracted data to files Input : result : a tuple with stamp (name) and data coming from the extract functions Output : the file on the disk, .dat for 0D point data, .mat for spectrum data, and .imag for image data
- saveOneDExtractedData(result)¶
Save only the 1D spectrum previously extracted data to a .mat file Input : result : a tuple with stamp (name) and data coming from the extract functions Output : the file on the disk
- savePointExtractedData(result)¶
Save only the 0D, point, scalar, previously extracted data to a .dat file Input : result : a tuple with stamp (name) and data coming from the extract functions Output : the file on the disk
- saveTwoDExtractedData(result)¶
Save only the 2D Image previously extracted data to a .imag file Input : result : a tuple with stamp (name) and data coming from the extract functions Output : the file on the disk
- lib.backend.PyNexus.get_aliases(filename)¶
build a dictionnary of the aliases and tango adresses from the elements in file filename Input :
filename : the config file
- Output:
a dictionnary which keywords are the aliases
lib.backend.area_detector module¶
Library for area detector.
- lib.backend.area_detector.extract_area_detector_scan(nxs_name, path_to_nxs_dir, is_print_stamps, is_print_info)¶
Extract the nexus file and return useful quantities.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_print_info (bool, optional) – Verbose mode.
- Returns:
images (array) – Array of individual detector images.
images_sum (array) – Detector images integrated over the scan.
integ_x (array) – Profile integrated along the horizontal axis.
integ_y (array) – Profile integrated along the vertical axis.
alias_detector (str) – The alias of the 2D detector, e.g. ‘pilatus’ or ‘ufxc’.
time_str (str) – Starting/ending dates of the scan.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
- lib.backend.area_detector.plot_area_detector_scan(images_sum, roi_2d, nxs_name, absorbers, is_area_detector_logz, map_area_detector, time_str)¶
Plot area detector data.
- Parameters:
images_sum (array) – Detector images integrated over the scan.
roi_2d (list of int) – ROI for the integrated spectra [x0, y0, size_x, size_y].
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
absorbers (str, optional) – Text to display which absorber was used.
is_area_detector_logz (bool, optional) – Log scale on the color scale of the image.
map_area_detector (str, optional) – Colormap of the image.
time_str (str) – Starting/ending dates of the scan.
- Returns:
fig – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.area_detector.process_area_detector_scan(nxs_name, path_to_nxs_dir, roi_2d=[- 1, - 1, - 1, - 1], absorbers='', is_area_detector_logz=True, map_area_detector='viridis', path_to_save_dir='', is_print_stamps=False, is_plot=False, is_save_sum=False, is_save_each=False, is_print_info=False)¶
Call functions for extracting, plotting, and saving an output of a scan on an area detector.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
roi_2d (list of int) – ROI for the integrated spectra [x0, y0, size_x, size_y].
absorbers (str, optional) – Text to display which absorber was used.
is_area_detector_logz (bool, optional) – Log scale on the color scale of the image.
map_area_detector (str, optional) – Colormap of the image.
path_to_save_dir (str, optional) – Path to the directory where the treated files will be saved.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot (bool, optional) – Plot the 2D image and the integrated profiles.
is_save_sum (bool, optional) – Save the sum of the images.
is_save_each (bool, optional) – Save each individual image and the sum.
is_print_info (bool, optional) – Verbose mode.
- Returns:
images_sum (array) – Detector images integrated over the scan.
integ_x (array) – Profile integrated along the horizontal axis.
integ_y (array) – Profile integrated along the vertical axis.
- lib.backend.area_detector.save_area_detector_scan(images, images_sum, integ_x, integ_y, alias_detector, nxs_name, stamps_0d, data_0d, fig, path_to_save_dir, is_print_info)¶
Save area detector data.
XXX_DETECTOR_sum.mat: the matrix corresponding to the image displayed, in ascii. XXX_DETECTOR_sum.tiff: the matrix corresponding to the image displayed, in tiff. XXX_integrated_x.dat: the horizontal integration of the whole detector as a function of y. XXX_integrated_y.dat: the vertical integration of the whole detector as a function of x. XXX_images/XXX_DETECTOR_N.tiff : each image of the scan, in tiff. XXX.dat : the value of each sensor at each point of the scan. XXX.pdf : the figure in pdf.
- Parameters:
images (array) – Array of individual detector images.
images_sum (array) – Detector images integrated over the scan.
integ_x (array) – Profile integrated along the horizontal axis.
integ_y (array) – Profile integrated along the vertical axis.
alias_detector (str) – The alias of the 2D detector, e.g. ‘pilatus’ or ‘ufxc’.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
fig (None or matplotlib figure) – The figure to be saved in pdf. Pass None if not wanted.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_info (bool) – Verbose mode.
lib.backend.data_1d module¶
Library for data 1D.
- lib.backend.data_1d.compute_bragg_new(stamps_0d, data_0d, xas_energy_shift, xas_signal_label, xas_norm_label, xas_standard_name, energy_current, bragg_current, path_to_xas_dir)¶
Compute the new bragg value based on the energy shift with the standard.
- Parameters:
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
xas_energy_shift (float) – Energy shift between the measurement and the standard in keV.
xas_signal_label (str) – Exact name of the sensor used for signal, as it appears in the stamps.
xas_norm_label (str) – Exact name of the sensor used for normalization, as it appears in the stamps.
xas_standard_name (str) – Chosen xas standard file, e.g. ‘XAS_ref_Ni.txt’.
energy_current (float) – Current value of the DCM energy in keV.
bragg_current (float) – Current value of the bragg angle in deg.
path_to_xas_dir (str) – Path to the folder containing the standards.
- Returns:
bragg_new (float) – Value of the new bragg in deg.
xas_energy_standard (array) – List of energies from the standard in keV.
xas_transmission_standard (array) – List of transmissions from the standard.
xas_energy_meas (array) – List of energies measured in keV.
xas_transmission_meas (array) – List of transmissions measured in keV.
str_to_display (str or None) – String to display after the plot.
- lib.backend.data_1d.erf_function(x, mu, sigma, amplitude, cst, sign)¶
Return an error function with a constant background.
- lib.backend.data_1d.extract_data_1d(nxs_name, path_to_nxs_dir, x_label, y_label, is_print_stamps, is_print_info)¶
Extract the nexus file and return useful quantities.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_print_info (bool, optional) – Verbose mode.
- Returns:
x (array) – List of x values.
y (array) – List of y values.
time_str (str) – Starting/ending dates of the scan.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
- Raises:
FileNotFoundError – If a file or a folder is missing.
Exception('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
Exception('Sensor not found.') – If the sensor is not found in the sensor list.
- lib.backend.data_1d.fit_with_erf(x, y, params_init, is_print_info)¶
Fit with an error function using LMFIT.
- Parameters:
x (array) – List of x values.
y (array) – List of y values.
params_init (dict or None) – Dictionnary of parameters for initial guesses and limits. All the parameters should be given. For example: params_init = {‘cst’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘mu’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘sigma’:{‘init’:0.2, ‘min’:0., ‘max’:1}, ‘amplitude’:{‘init’:10., ‘min’:-10, ‘max’:20}, ‘sign’:{‘value’:-1}}
is_print_info (bool) – Verbose mode.
- Returns:
y_fit (array) – List of y values from the fit.
lm_result (object MinimizerResult) – Results of lm minimization. Includes data such as status and error messages, fit statistics, and the updated (i.e., best-fit) parameters themselves in the params attribute.
- lib.backend.data_1d.fit_with_gaussian(x, y, params_init, is_print_info)¶
Fit with a gaussian using LMFIT.
- Parameters:
x (array) – List of x values.
y (array) – List of y values.
params_init (dict or None) – Dictionnary of parameters for initial guesses and limits. All the parameters should be given. For example: params_init = {‘cst’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘linear_coeff’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘mu’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘sigma’:{‘init’:0.2, ‘min’:0., ‘max’:1}, ‘amplitude’:{‘init’:10., ‘min’:-10, ‘max’:20}}
is_print_info (bool) – Verbose mode.
- Returns:
y_fit (array) – List of y values from the fit.
lm_result (object MinimizerResult) – Results of lm minimization. Includes data such as status and error messages, fit statistics, and the updated (i.e., best-fit) parameters themselves in the params attribute.
- lib.backend.data_1d.gaussian_function(x, mu, sigma, cst, linear_coeff, amplitude)¶
Return a gaussian with a linear background.
- lib.backend.data_1d.plot_data_1d(x, y, x_label, y_label, time_str, nxs_name, absorbers, is_logx, is_logy)¶
Plot 1d data.
- Parameters:
x (array) – List of x values.
y (array) – List of y values.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
time_str (str) – Starting/ending dates of the scan.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
absorbers (str, optional) – Text to display which absorber was used.
is_logx (bool, optional) – Log scale on the x axis.
is_logy (bool, optional) – Log scale on the y axis.
- Returns:
fig – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.data_1d.plot_energy_calib(xas_standard_name, xas_energy_min, xas_energy_max, xas_energy_shift, xas_energy_meas, xas_transmission_meas, xas_energy_standard, xas_transmission_standard, str_to_display)¶
Plot the comparison with the xas standard and print the new bragg.
- Parameters:
xas_standard_name (str) – Chosen xas standard file, e.g. ‘XAS_ref_Ni.txt’.
xas_energy_min (float) – Energy minimum for the plot in keV.
xas_energy_max (float) – Energy maximum for the plot in keV.
xas_energy_shift (float) – Energy shift between the measurement and the standard in keV.
xas_energy_meas (array) – List of energies measured in keV.
xas_transmission_meas (array) – List of transmissions measured in keV.
xas_energy_standard (array) – List of energies from the standard in keV.
xas_transmission_standard (array) – List of transmissions from the standard.
str_to_display (str or None) – String to display after the plot.
- Returns:
fig – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.data_1d.plot_erf_fit(x, y, y_fit, lm_result, x_label, y_label, time_str, nxs_name, absorbers, is_print_info)¶
Plot fit of 1d data.
- Parameters:
x (array) – List of x values.
y (array) – List of y values.
y_fit (array) – List of y values from the fit.
lm_result (object MinimizerResult) – Results of lm minimization. Includes data such as status and error messages, fit statistics, and the updated (i.e., best-fit) parameters themselves in the params attribute.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
time_str (str) – Starting/ending dates of the scan.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
absorbers (str) – Text to display which absorber was used.
is_print_info (bool) – Verbose mode.
- Returns:
fig – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.data_1d.plot_gaussian_fit(x, y, y_fit, lm_result, x_label, y_label, time_str, nxs_name, absorbers, is_print_info)¶
Plot fit of 1d data.
- Parameters:
x (array) – List of x values.
y (array) – List of y values.
y_fit (array) – List of y values from the fit.
lm_result (object MinimizerResult) – Results of lm minimization. Includes data such as status and error messages, fit statistics, and the updated (i.e., best-fit) parameters themselves in the params attribute.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
time_str (str) – Starting/ending dates of the scan.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
absorbers (str) – Text to display which absorber was used.
is_print_info (bool) – Verbose mode.
- Returns:
fig – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.data_1d.process_data_1d(nxs_name, path_to_nxs_dir, x_label, y_label, is_logx=False, is_logy=False, absorbers='', path_to_save_dir='', is_print_stamps=False, is_plot=False, is_save=False, is_print_info=False)¶
Call functions for extracting, plotting, and saving 1d data.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
is_logx (bool, optional) – Log scale on the x axis.
is_logy (bool, optional) – Log scale on the y axis.
absorbers (str, optional) – Text to display which absorber was used.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot (bool, optional) – Plot the data.
is_save (bool, optional) – Save the results.
is_print_info (bool, optional) – Verbose mode.
- Returns:
x (array) – List of x values.
y (array) – List of y values.
- lib.backend.data_1d.process_energy_calib(nxs_name, path_to_nxs_dir, xas_energy_min, xas_energy_max, xas_energy_shift, xas_signal_label, xas_norm_label, xas_standard_name, energy_current, bragg_current, path_to_xas_dir, path_to_save_dir='', is_save=False)¶
Call functions for extracting, plotting, and saving energy calibration with XAS standards.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
xas_energy_min (float) – Energy minimum for the plot in keV.
xas_energy_max (float) – Energy maximum for the plot in keV.
xas_energy_shift (float) – Energy shift between the measurement and the standard in keV.
xas_signal_label (str) – Exact name of the sensor used for signal, as it appears in the stamps.
xas_norm_label (str) – Exact name of the sensor used for normalization, as it appears in the stamps.
xas_standard_name (str) – Chosen xas standard file, e.g. ‘XAS_ref_Ni.txt’.
energy_current (float) – Current value of the DCM energy in keV.
bragg_current (float) – Current value of the bragg angle in deg.
path_to_xas_dir (str) – Path to the folder containing the standards.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_save (bool, optional) – Save the results.
- lib.backend.data_1d.process_erf_fit(nxs_name, path_to_nxs_dir, x_label, y_label, params_init=None, absorbers='', path_to_save_dir='', is_print_stamps=False, is_plot=False, is_save=False, is_print_info=False)¶
Call functions for extracting, fitting with an error function, plotting, and saving 1d data.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
params_init (dict or None, optional) – Dictionnary of parameters for initial guesses and limits. All the parameters should be given. For example: params_init = {‘cst’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘mu’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘sigma’:{‘init’:0.2, ‘min’:0., ‘max’:1}, ‘amplitude’:{‘init’:10., ‘min’:-10, ‘max’:20}, ‘sign’:{‘value’:-1}}
absorbers (str, optional) – Text to display which absorber was used.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot (bool, optional) – Plot the data.
is_save (bool, optional) – Save the results.
is_print_info (bool, optional) – Verbose mode.
- Returns:
x (array) – List of x values.
y (array) – List of y values.
y_fit (array) – List of y values from the fit.
lm_result (object MinimizerResult) – Results of lm minimization. Includes data such as status and error messages, fit statistics, and the updated (i.e., best-fit) parameters themselves in the params attribute.
- lib.backend.data_1d.process_gaussian_fit(nxs_name, path_to_nxs_dir, x_label, y_label, params_init=None, absorbers='', path_to_save_dir='', is_print_stamps=False, is_plot=False, is_save=False, is_print_info=False)¶
Call functions for extracting, fitting with a gaussian, plotting, and saving 1d data.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
params_init (dict or None, optional) – Dictionnary of parameters for initial guesses and limits. All the parameters should be given. For example: params_init = {‘cst’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘linear_coeff’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘mu’:{‘init’:0, ‘min’:-1, ‘max’:1}, ‘sigma’:{‘init’:0.2, ‘min’:0., ‘max’:1}, ‘amplitude’:{‘init’:10., ‘min’:-10, ‘max’:20}}
absorbers (str, optional) – Text to display which absorber was used.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot (bool, optional) – Plot the data.
is_save (bool, optional) – Save the results.
is_print_info (bool, optional) – Verbose mode.
- Returns:
x (array) – List of x values.
y (array) – List of y values.
y_fit (array) – List of y values from the fit.
lm_result (object MinimizerResult) – Results of lm minimization. Includes data such as status and error messages, fit statistics, and the updated (i.e., best-fit) parameters themselves in the params attribute.
- lib.backend.data_1d.residuals_erf_function(params, x, y)¶
Return the residuals of the error function.
- lib.backend.data_1d.residuals_gaussian_function(params, x, y)¶
Return the residuals of the gaussian function.
- lib.backend.data_1d.save_data_1d(nxs_name, stamps_0d, data_0d, fig, path_to_save_dir, is_print_info)¶
Save 1D data.
XXX.dat : the value of each sensor at each point of the scan. XXX.pdf : the figure in pdf.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
fig (None or matplotlib figure) – The figure to be saved in pdf. Pass None if not wanted.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_info (bool) – Verbose mode.
- lib.backend.data_1d.save_fit_result(nxs_name, x, y, y_fit, lm_result, x_label, y_label, fig, path_to_save_dir, is_print_info)¶
Save 1D data and fit results.
XXX.dat : the value of each sensor at each point of the scan. XXX.pdf : the figure in pdf. XXX_fit_FUNCTION_report.dat : the lmfit report. XXX_fit_FUNCTION_result.dat : the fitted data x, y, y_fit.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
x (array) – List of x values.
y (array) – List of y values.
y_fit (array) – List of y values from the fit.
lm_result (object MinimizerResult) – Results of lm minimization. Includes data such as status and error messages, fit statistics, and the updated (i.e., best-fit) parameters themselves in the params attribute.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
fig (None or matplotlib figure) – The figure to be saved in pdf. Pass None if not wanted.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_info (bool) – Verbose mode.
lib.backend.data_1d_twinx module¶
Library for data 1D. With two y axis on the same x axis.
- lib.backend.data_1d_twinx.extract_data_1d(nxs_name, path_to_nxs_dir, x_label, y_label, y2_label, is_print_stamps, is_print_info)¶
Extract the nexus file and return useful quantities.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
y2_label (str) – Exact name of the y2 sensor, as it appears in the stamps.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_print_info (bool, optional) – Verbose mode.
- Returns:
x (array) – List of x values.
y (array) – List of y values.
y2 (array) – List of y2 values.
time_str (str) – Starting/ending dates of the scan.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
- Raises:
FileNotFoundError – If a file or a folder is missing.
Exception('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
Exception('Sensor not found.') – If the sensor is not found in the sensor list.
- lib.backend.data_1d_twinx.plot_data_1d(x, y, y2, x_label, y_label, y2_label, time_str, nxs_name, absorbers, is_logx, is_logy, is_logy2)¶
Plot 1d data.
- Parameters:
x (array) – List of x values.
y (array) – List of y values.
y2 (array) – List of y2 values.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
y2_label (str) – Exact name of the y2 sensor, as it appears in the stamps.
time_str (str) – Starting/ending dates of the scan.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
absorbers (str, optional) – Text to display which absorber was used.
is_logx (bool, optional) – Log scale on the x axis.
is_logy (bool, optional) – Log scale on the y axis.
is_logy2 (bool, optional) – Log scale on the y2 axis.
- Returns:
fig – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.data_1d_twinx.process_data_1d(nxs_name, path_to_nxs_dir, x_label, y_label, y2_label, is_logx=False, is_logy=False, is_logy2=False, absorbers='', path_to_save_dir='', is_print_stamps=False, is_plot=False, is_save=False, is_print_info=False)¶
Call functions for extracting, plotting, and saving 1d data.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
x_label (str) – Exact name of the x sensor, as it appears in the stamps.
y_label (str) – Exact name of the y sensor, as it appears in the stamps.
y2_label (str) – Exact name of the y2 sensor, as it appears in the stamps.
is_logx (bool, optional) – Log scale on the x axis.
is_logy (bool, optional) – Log scale on the y axis.
is_logy2 (bool, optional) – Log scale on the y2 axis.
absorbers (str, optional) – Text to display which absorber was used.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot (bool, optional) – Plot the data.
is_save (bool, optional) – Save the results.
is_print_info (bool, optional) – Verbose mode.
- Returns:
x (array) – List of x values.
y (array) – List of y values.
y2 (array) – List of y2 values.
- lib.backend.data_1d_twinx.save_data_1d(nxs_name, stamps_0d, data_0d, fig, path_to_save_dir, is_print_info)¶
Save 1D data.
XXX.dat : the value of each sensor at each point of the scan. XXX.pdf : the figure in pdf.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
fig (None or matplotlib figure) – The figure to be saved in pdf. Pass None if not wanted.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_info (bool) – Verbose mode.
lib.backend.gixd module¶
Library for GIXD.
- lib.backend.gixd.bin_matrix_vertical(mat, bin_size=10)¶
Bin a matrix along the vertical axis.
- Parameters:
mat (array) – Numpy array with the matrix to bin.
bin_size (int, optional) – Size in pixels of the vertical binning.
- Returns:
(channels_binned, mat_binned) – Channels and matrix after binning.
- Return type:
tupple of arrays
- lib.backend.gixd.calib_thetaz(gamma_channel, is_plot=True)¶
Fit and plot gamma vs channel for the calibration of thetaz.
- Parameters:
gamma_channel (array) – Numpy array containing the values of each gamma and corresponding channel. For example : np.array([ [0, 970], [-1, 899], [-2, 827]])
is_plot (bool, optional) – Plot the fit.
- Returns:
thetaz_factor – Factor for conversion from channel to radian in the vertical direction (rad/channel).
- Return type:
float
- lib.backend.gixd.extract_gixd_scan(nxs_name, path_to_nxs_dir, channel0, thetaz_factor, wavelength, thetac, bin_size, is_compute_qz, is_force_gamma, fgamma, roi_soller, is_print_stamps, is_print_info)¶
Extract the nexus file and return useful quantities for GIXD.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
channel0 (int) – Vertical channel corresponding to the Vineyard’s peak.
thetaz_factor (float) – Factor for conversion from channel to radian in the vertical direction (rad/channel).
wavelength (float) – Wavelength in nm.
thetac (float) – Critical angle in rad.
bin_size (int) – Size in pixels of the vertical binning (along qz).
is_compute_qz (bool) – Convert pixels to qz in the vertical direction.
is_force_gamma (bool) – Force gamma to be equal to the value of fgamma.
fgamma (float) – Value of gamma (deg) to be used if is_force_gamma is set to True or if gamma is absent from the sensor list.
roi_soller (list of int) – ROI of the Soller’s slits.
is_print_stamps (bool) – Print the list of sensors contained in the nexus file.
is_print_info (bool) – Verbose mode.
- Returns:
x (array) – Either qxy (nm^-1) values, if qxy is available in the list of sensors, or delta (deg) if not.
y (array) – Either qz (nm^-1) values, if is_compute_qz is True, or vertical channels if not.
x_label (str) – ‘qxy’ or ‘delta’ (useful for plot).
y_label (str) – ‘qz’ or ‘channels’ (useful for plot).
time_str (str) – Starting/ending dates of the scan.
column_x – Column corresponding to the x values in stamps_0d (useful for save).
integ_rod (array) – Rods integrated over the whole vertical axis of the detector.
integ_rod_top (array) – Rods integrated over the top half vertical axis of the detector.
integ_rod_bottom (array) – Rods integrated over the bottom half vertical axis of the detector.
integ_rod_first_quarter (array) – Rods integrated over the bottom quarter vertical axis of the detector.
mat (array) – Matrix with each line corresponding to a position of delta.
mat_binned (array) – Matrix after vertical binning.
channels_binned (array) – Channels after vertical binning.
mean_pi (float or None) – Average of the surface pressure (mN/m) over the scan (None if pressure not found).
mean_area (float or None) – Average of the area per molecule (nm^2) over the scan (None if area not found).
mean_gamma (float or None) – Average of gamma (deg) over the scan (None if gamma not found).
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
SystemExit('delta or qxy not found.') – If delta and qxy are not found in the sensor list.
SystemExit('gamma not found.') – If gamma is not found in the sensor list and is_compute_qz is True.
- lib.backend.gixd.plot_gixd_scan(x, y, x_label, y_label, time_str, integ_rod, integ_rod_top, integ_rod_bottom, integ_rod_first_quarter, mat_binned, mean_pi, mean_gamma, nxs_name, absorbers, is_gixd_logx, is_gixd_logy, is_gixd_logz, nb_levels, map_gixd, is_raster)¶
Plot GIXD data.
- Parameters:
x (array) – Either qxy (nm^-1) values, if qxy is available in the list of sensors, or delta (deg) if not.
y (array) – Either qz (nm^-1) values, if is_compute_qz is True, or vertical channels if not.
x_label (str) – ‘qxy’ or ‘delta’ (useful for plot).
y_label (str) – ‘qz’ or ‘channels’ (useful for plot).
time_str (str) – Starting/ending dates of the scan.
column_x – Column corresponding to the x values in stamps_0d (useful for save).
integ_rod (array) – Rods integrated over the whole vertical axis of the detector.
integ_rod_top (array) – Rods integrated over the top half vertical axis of the detector.
integ_rod_bottom (array) – Rods integrated over the bottom half vertical axis of the detector.
integ_rod_first_quarter (array) – Rods integrated over the bottom quarter vertical axis of the detector.
mat_binned (array) – Matrix after vertical binning.
mean_pi (float or None) – Average of the surface pressure (mN/m) over the scan (None if pressure not found).
mean_gamma (float or None) – Average of gamma (deg) over the scan (None if gamma not found).
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
absorbers (str) – Text to display which absorber was used.
is_gixd_logx (bool) – Log scale on the x axis of the integrated profile.
is_gixd_logy (bool) – Log scale on the y axis of the integrated profile.
is_gixd_logz (bool) – Log scale on the color scale of the image.
nb_levels (int) – Number of color levels for the image display.
map_gixd (str) – Colormap of the image.
is_raster (bool) – Rasterization of the image.
- Returns:
fig – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.gixd.plot_vineyard(integ_over_qxy, channel0)¶
Plot the profile integrated over qxy that was used to find the Vineyard’s peak.
- Parameters:
integ_over_qxy (array) – GIXD image integrated over the qxy axis.
channel0 (int) – Vertical channel corresponding to the Vineyard’s peak.
- lib.backend.gixd.process_gixd_scan(nxs_name, path_to_nxs_dir, channel0, thetaz_factor, wavelength, thetac, bin_size, is_compute_qz, is_force_gamma=False, fgamma=0.0, absorbers='', is_gixd_logx=False, is_gixd_logy=False, is_gixd_logz=False, nb_levels=50, map_gixd='jet', path_to_save_dir='', list_moy_to_create=[10, 20, 40], roi_soller=[510, 350, 130, 692], is_print_stamps=False, is_plot=False, is_save=False, is_print_info=False, is_raster=False)¶
Call functions for extracting, plotting, and saving a GIXD scan.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
channel0 (int) – Vertical channel corresponding to the Vineyard’s peak.
thetaz_factor (float) – Factor for conversion from channel to radian in the vertical direction (rad/channel).
wavelength (float) – Wavelength in nm.
thetac (float) – Critical angle in rad.
bin_size (int) – Size in pixels of the vertical binning (along qz).
is_compute_qz (bool) – Convert pixels to qz in the vertical direction.
is_force_gamma (bool, optional) – Force gamma to be equal to the value of fgamma.
fgamma (float, optional) – Value of gamma (deg) to be used if is_force_gamma is set to True or if gamma is absent from the sensor list.
absorbers (str, optional) – Text to display which absorber was used.
is_gixd_logx (bool, optional) – Log scale on the x axis of the integrated profile.
is_gixd_logy (bool, optional) – Log scale on the y axis of the integrated profile.
is_gixd_logz (bool, optional) – Log scale on the color scale of the image.
nb_levels (int, optional) – Number of color levels for the image display.
map_gixd (str, optional) – Colormap of the image.
path_to_save_dir (str, optional) – Path to the directory where the treated files will be saved.
list_moy_to_create (list of int, optional) – Bin sizes to be used, e.g. [10, 20, 40].
roi_soller (list of int, optional) – ROI of the Soller’s slits.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot (bool, optional) – Plot the 2D GIXD image and the integrated profiles.
is_save (bool, optional) – Save the results.
is_print_info (bool, optional) – Verbose mode.
is_raster (bool) – Rasterization of the image.
- Returns:
x (array) – Either qxy (nm^-1) values, if qxy is available in the list of sensors, or delta (deg) if not.
y (array) – Either qz (nm^-1) values, if is_compute_qz is True, or vertical channels if not.
integ_rod (array) – Rods integrated over the whole vertical axis of the detector.
integ_rod_top (array) – Rods integrated over the top half vertical axis of the detector.
integ_rod_bottom (array) – Rods integrated over the bottom half vertical axis of the detector.
integ_rod_first_quarter (array) – Rods integrated over the bottom quarter vertical axis of the detector.
mat (array) – Each line corresponds to a position of delta. It is the matrix corresponding to the image displayed in plot.
mat_binned (array) – Matrix after vertical binning.
channels_binned (array) – Channels after vertical binning.
mean_pi (float or None) – Average of the surface pressure (mN/m) over the scan (None if pressure not found).
mean_area (float or None) – Average of the area per molecule (nm^2) over the scan (None if area not found).
mean_gamma (float or None) – Average of gamma (deg) over the scan (None if gamma not found).
- lib.backend.gixd.process_vineyard(nxs_name, path_to_nxs_dir, bin_size=10, is_force_gamma=False, fgamma=0.0, is_gixd_logx=False, is_gixd_logy=False, is_gixd_logz=False, nb_levels=50, map_gixd='jet', roi_soller=[510, 350, 130, 692], is_print_stamps=False, is_plot=False, is_print_info=False, is_raster=False)¶
Extract the nexus file, plot and return the channel of the Vineyard’s peak.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
bin_size (int, optional) – Size in pixels of the vertical binning (along qz).
is_force_gamma (bool, optional) – Force gamma to be equal to the value of fgamma.
fgamma (float, optional) – Value of gamma (deg) to be used if is_force_gamma is set to True or if gamma is absent from the sensor list.
is_gixd_logx (bool, optional) – Log scale on the x axis of the integrated profile.
is_gixd_logy (bool, optional) – Log scale on the y axis of the integrated profile.
is_gixd_logz (bool, optional) – Log scale on the color scale of the image.
nb_levels (int, optional) – Number of color levels for the image display.
map_gixd (str, optional) – Colormap of the image.
roi_soller (list of int, optional) – ROI of the Soller’s slits.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot (bool, optional) – Plot the 2D GIXD image and the integrated profiles.
is_print_info (bool, optional) – Verbose mode.
- Returns:
channel0 – Vertical channel corresponding to the Vineyard’s peak.
- Return type:
int
- lib.backend.gixd.save_gixd_scan(x, integ_rod, integ_rod_top, integ_rod_bottom, integ_rod_first_quarter, mat, list_moy_to_create, mean_gamma, column_x, channel0, thetaz_factor, wavelength, thetac, nxs_name, stamps_0d, data_0d, fig, path_to_save_dir, is_compute_qz, is_print_info)¶
Save GIXD data.
XXX_1D.mat: the matrix corresponding to the image displayed. Each line corresponds to a position of delta.
XXX_1D.dat: the value of each sensor at each point of the scan. It contains also integration along qz:
QzIntegrated : over the whole detector,
QzIntegratedTop : over its top half,
QzIntegratedBottom : over its bottom half,
QzIntegratedBottomQuarter : over its bottom quarter.
XXX.pdf : the figure in pdf.
- Binned data:
XXX_1D.matNN : binning of the matrix, with NN the number of points per bin.
XXX_1D_qz.datNN : to convert bin number to qz in XXX_1D.matNN.
XXX_1D.moyNN : a more convenient way to represent the binned matrices with a 3 columns (qxy, qz, intensity) display.
- Parameters:
x (array) – Either qxy (nm^-1) values, if qxy is available in the list of sensors, or delta (deg) if not.
integ_rod (array) – Rods integrated over the whole vertical axis of the detector.
integ_rod_top (array) – Rods integrated over the top half vertical axis of the detector.
integ_rod_bottom (array) – Rods integrated over the bottom half vertical axis of the detector.
integ_rod_first_quarter (array) – Rods integrated over the bottom quarter vertical axis of the detector.
mat (array) – Matrix with each line corresponding to a position of delta.
list_moy_to_create (list of int, optional) – Bin sizes to be used, e.g. [10, 20, 40].
mean_gamma (float or None) – Average of gamma (deg) over the scan (None if gamma not found).
column_x (int) – Column corresponding to the x values in stamps_0d (useful for save).
channel0 (int) – Vertical channel corresponding to the Vineyard’s peak.
thetaz_factor (float) – Factor for conversion from channel to radian in the vertical direction (rad/channel).
wavelength (float) – Wavelength in nm.
thetac (float) – Critical angle in rad.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
fig (None or matplotlib figure) – The figure to be saved in pdf. Pass None if not wanted.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_compute_qz (bool) – Convert pixels to qz in the vertical direction.
is_print_info (bool) – Verbose mode.
lib.backend.gixs module¶
Library for GIXS.
- lib.backend.gixs.extract_gixs_scan(nxs_name, path_to_nxs_dir, wavelength, distance_detec, pixel_poni_x, pixel_poni_y, pixel_size, is_force_gamma, is_force_delta, is_force_thetai, fgamma, fdelta, fthetai, roi_2d, is_print_stamps, is_print_info)¶
Extract the nexus file and return useful quantities for GIXS.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
wavelength (float) – Wavelength in nm.
distance_detec (float) – Distance between the detector and the center of the sample in mm.
pixel_poni_x (float) – horizontal coordinate of the Point Of Normal Incidence in pixels. Measured on the direct beam at delta=0 and gamma=0.
pixel_poni_y (float) – vertical coordinate of the Point Of Normal Incidence in pixels. Measured on the direct beam at delta=0 and gamma=0.
pixel_size (float) – pixel size in mm.
is_force_gamma (bool) – Force gamma to be equal to the value of fgamma.
is_force_delta (bool) – Force delta to be equal to the value of fdelta.
is_force_thetai (bool) – Force thetai to be equal to the value of fthetai.
fgamma (float) – Value of gamma (deg) to be used if is_force_gamma is set to True or if gamma is absent from the sensor list.
fdelta (float) – Value of delta (deg) to be used if is_force_delta is set to True or if delta is absent from the sensor list.
fthetai (float) – Value of thetai (deg) to be used if is_force_thetai is set to True or if alphax is absent from the sensor list.
roi_2d (list of int) – ROI for the integrated spectra [x0, y0, size_x, size_y].
is_print_stamps (bool) – Print the list of sensors contained in the nexus file.
is_print_info (bool) – Verbose mode.
- Returns:
images (array) – Array of individual Pilatus images.
images_sum (array) – Pilatus images integrated over the scan.
qxy_grid (array) – 2D grid of qxy for 2D plots.
qz_grid (array) – 2D grid of qz for 2D plots.
integ_qxy (array) – Profile integrated along the horizontal axis.
integ_qz (array) – Profile integrated along the vertical axis.
qxy_list (array) – List of qxy in the profile.
qz_list (array) – List of qz in the profile.
gamma_str (str) – Label with value of gamma.
delta_str (str) – Label with value of delta.
thetai_str (str) – Label with value of thetai.
time_str (str) – Starting/ending dates of the scan.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
- lib.backend.gixs.plot_gixs_scan(images_sum, roi_2d, qxy_grid, qz_grid, qxy_list, qz_list, nxs_name, absorbers, is_gixs_logz, map_gixs, gamma_str, delta_str, thetai_str, time_str)¶
Plot GIXS data.
- Parameters:
images_sum (array) – Pilatus images integrated over the scan.
roi_2d (list of int) – ROI for the integrated spectra [x0, y0, size_x, size_y].
qxy_grid (array) – 2D grid of qxy for 2D plots.
qz_grid (array) – 2D grid of qz for 2D plots.
qxy_list (array) – List of qxy in the full profile.
qz_list (array) – List of qz in the full profile.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
absorbers (str) – Text to display which absorber was used.
is_gixs_logz (bool) – Log scale on the color scale of the image.
map_gixs (str) – Colormap of the image.
gamma_str (str) – Label with value of gamma.
delta_str (str) – Label with value of delta.
thetai_str (str) – Label with value of thetai.
time_str (str) – Starting/ending dates of the scan.
- Returns:
fig – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.gixs.process_gixs_scan(nxs_name, path_to_nxs_dir, wavelength, distance_detec, pixel_poni_x, pixel_poni_y, pixel_size, is_force_gamma=False, is_force_delta=False, is_force_thetai=False, fgamma=0.0, fdelta=0.0, fthetai=0.0, roi_2d=[- 1, - 1, - 1, - 1], absorbers='', is_gixs_logz=True, map_gixs='viridis', path_to_save_dir='', is_print_stamps=False, is_plot=False, is_save_sum=False, is_save_each=False, is_print_info=False)¶
Call functions for extracting, plotting, and saving a GIXS scan.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
wavelength (float) – Wavelength in nm.
distance_detec (float) – Distance between the detector and the center of the sample in mm.
pixel_poni_x (float) – horizontal coordinate of the Point Of Normal Incidence in pixels. Measured on the direct beam at delta=0 and gamma=0.
pixel_poni_y (float) – vertical coordinate of the Point Of Normal Incidence in pixels. Measured on the direct beam at delta=0 and gamma=0.
pixel_size (float) – pixel size in mm.
is_force_gamma (bool, optional) – Force gamma to be equal to the value of fgamma.
is_force_delta (bool, optional) – Force delta to be equal to the value of fdelta.
is_force_thetai (bool, optional) – Force thetai to be equal to the value of fthetai.
fgamma (float, optional) – Value of gamma (deg) to be used if is_force_gamma is set to True or if gamma is absent from the sensor list.
fdelta (float, optional) – Value of delta (deg) to be used if is_force_delta is set to True or if delta is absent from the sensor list.
fthetai (float, optional) – Value of thetai (deg) to be used if is_force_thetai is set to True or if alphax is absent from the sensor list.
roi_2d (list of int) – ROI for the integrated spectra [x0, y0, size_x, size_y].
absorbers (str, optional) – Text to display which absorber was used.
is_gixs_logz (bool, optional) – Log scale on the color scale of the image.
map_gixs (str, optional) – Colormap of the image.
path_to_save_dir (str, optional) – Path to the directory where the treated files will be saved.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot (bool, optional) – Plot the 2D GIXS image and the integrated profiles.
is_save_sum (bool, optional) – Save the sum of the images.
is_save_each (bool, optional) – Save each individual image and the sum.
is_print_info (bool, optional) – Verbose mode.
- Returns:
images_sum (array) – Pilatus images integrated over the scan.
integ_qxy (array) – Profile integrated along the horizontal axis.
integ_qz (array) – Profile integrated along the vertical axis.
qxy_list (array) – List of qxy in the profile.
qz_list (array) – List of qz in the profile.
- lib.backend.gixs.save_gixs_scan(images, images_sum, integ_qxy, integ_qz, qxy_list, qz_list, nxs_name, stamps_0d, data_0d, fig, path_to_save_dir, is_print_info)¶
Save GIXS data.
XXX_pilatus_sum.mat: the matrix corresponding to the image displayed, in ascii. XXX_pilatus_sum.tiff: the matrix corresponding to the image displayed, in tiff. XXX_integrated_qxy.dat: the horizontal integration of the whole detector as a function of qz (nm-1). XXX_integrated_qz.dat: the vertical integration of the whole detector as a function of qxy (nm-1). XXX_images/XXX_pliatus_N.tiff : each image of the scan, in tiff. XXX.dat : the value of each sensor at each point of the scan. XXX.pdf : the figure in pdf.
- Parameters:
images (array) – Array of individual Pilatus images.
images_sum (array) – Pilatus images integrated over the scan.
integ_qxy (array) – Profile integrated along the horizontal axis.
integ_qz (array) – Profile integrated along the vertical axis.
qxy_list (array) – List of qxy in the profile.
qz_list (array) – List of qz in the profile.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
fig (None or matplotlib figure) – The figure to be saved in pdf. Pass None if not wanted.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_info (bool) – Verbose mode.
lib.backend.isotherm module¶
Library for isotherms.
- lib.backend.isotherm.extract_isotherm_scan(nxs_name, path_to_nxs_dir, is_print_stamps, is_print_info)¶
Extract the nexus file and return useful quantities.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
is_print_stamps (bool) – Print the list of sensors contained in the nexus file.
is_print_info (bool) – Verbose mode.
- Returns:
area (array) – List of area values.
pressure (array) – List of pressure values.
time (array) – List of time values.
time_str (str) – Starting/ending dates of the scan.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
SystemExit('Required sensor not found.') – If a required sensor is not found in the sensor list.
- lib.backend.isotherm.plot_isotherm_scan(area, pressure, time, first_point_plot, last_point_plot, nxs_name, time_str)¶
Plot the isotherm.
- Parameters:
area (array) – List of area values.
pressure (array) – List of pressure values.
time (array) – List of time values.
first_point_plot (int) – First point of the plots.
last_point_plot (int) – Last point of the plots.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
time_str (str) – Starting/ending dates of the scan.
- Returns:
fig – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.isotherm.process_isotherm_scan(nxs_name, path_to_nxs_dir, first_point_plot=0, last_point_plot=- 1, path_to_save_dir='', is_print_stamps=False, is_plot=False, is_save=False, is_print_info=False)¶
Call functions for extracting, plotting, and saving an isotherm.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
first_point_plot (int, optional) – First point of the plots.
last_point_plot (int, optional) – Last point of the plots.
path_to_save_dir (str, optional) – Path to the directory where the treated files will be saved.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot (bool, optional) – Plot the isotherm and the integrated profiles.
is_save (bool, optional) – Save the results.
is_print_info (bool, optional) – Verbose mode.
- Returns:
area (array) – List of area values.
pressure (array) – List of pressure values.
time (array) – List of time values.
- lib.backend.isotherm.save_isotherm_scan(nxs_name, stamps_0d, data_0d, fig, path_to_save_dir, is_print_info)¶
Save isotherm data.
XXX.dat : the value of each sensor at each point of the scan. XXX.pdf : the figure in pdf.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
fig (None or matplotlib figure) – The figure to be saved in pdf. Pass None if not wanted.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_info (bool) – Verbose mode.
lib.backend.xrf module¶
Library for XRF.
- lib.backend.xrf.check_sdd_elems(nxs_name, path_to_nxs_dir, list_sdd_elems)¶
Check is all the SDD elems are in the Nexus file (ICR, OCR, spectrum).
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
list_sdd_elems (list of int) – List of SDD elements, e.g. [0, 1, 2].
- Returns:
is_icr_found (bool) – True if all the required ICR are present in the Nexus file.
is_ocr_found (bool) – True if all the required OCR are present in the Nexus file.
is_spectrum_found (bool) – True if all the required spectrums are present in the Nexus file.
- Raises:
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
- lib.backend.xrf.extract_xrf_scan(nxs_name, path_to_nxs_dir, list_sdd_elems, channel_xrf_first, channel_xrf_last, sdd_gain, sdd_ev0, is_print_stamps, is_print_info)¶
Extract the nexus file and return useful quantities.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
list_sdd_elems (list of int) – List of SDD elements, e.g. [0, 1, 2].
channel_xrf_first (int) – Spectrums are extracted between channel_xrf_first and channel_xrf_last.
channel_xrf_last (int) – Spectrums are extracted between channel_xrf_first and channel_xrf_last.
sdd_gain (float) – Channels are converted to eVs following eVs = sdd_gain*channel+sdd_ev0
sdd_ev0 (float) – Channels are converted to eVs following eVs = sdd_gain*channel+sdd_ev0
is_print_stamps (bool) – Print the list of sensors contained in the nexus file.
is_print_info (bool) – Verbose mode.
- Returns:
channels (array) – The extracted channels.
energies (array) – The extracted channels converted to eVs.
spectrums (array) – The extracted spectrums (between point 0 and last point with signal).
first_non_zero_spectrum (int) – Argument of the first spectrum with signal.
last_non_zero_spectrum (int) – Argument of the last spectrum with signal.
time_str (str) – Starting/ending dates of the scan.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
SystemExit('Required sensor not found.') – If a required sensor is not found in the sensor list.
- lib.backend.xrf.plot_xrf_first_last(channels, energies, spectrums, arr_peaks, first_non_zero_spectrum, time_str, is_use_ev, is_first_plot, is_xrf_log, absorbers, nxs_name)¶
Plot first and last spectrums of a XRF scan.
- Parameters:
channels (array) – The extracted channels.
energies (array) – The extracted channels converted to eVs.
spectrums (array) – The extracted spectrums (between point 0 and last point with signal).
arr_peaks (array of tuples) – Peaks to display, for ex. arr_peaks = [(‘Elastic’, ‘12000.’), (‘Compton’, ‘11670.’)]
first_non_zero_spectrum (int) – Argument of the first spectrum with signal.
time_str (str) – Starting/ending dates of the scan.
is_use_ev (bool) – Convert the channels to eVs.
is_first_plot (bool) – True if this is the first plot of the series (to print title and text).
is_xrf_log (bool) – Log on the intensity in the plots.
absorbers (str) – Text to display which absorber was used.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
- Returns:
fig_first_last – The figure of the first and last spectrums to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.xrf.plot_xrf_spectrogram(channels, energies, spectrums, last_non_zero_spectrum, time_str, is_use_ev, is_first_plot, is_xrf_log, absorbers, nxs_name)¶
Plot spectrogram of a XRF scan.
- Parameters:
channels (array) – The extracted channels.
energies (array) – The extracted channels converted to eVs.
spectrums (array) – The extracted spectrums (between point 0 and last point with signal).
last_non_zero_spectrum (int) – Argument of the last spectrum with signal.
time_str (str) – Starting/ending dates of the scan.
is_use_ev (bool) – Convert the channels to eVs.
is_first_plot (bool) – True if this is the first plot of the series (to print title and text).
is_xrf_log (bool) – Log on the intensity in the plots.
absorbers (str) – Text to display which absorber was used.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
- Returns:
fig_spectrogram – The figure of the spectrogram to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.xrf.plot_xrf_sum(channels, energies, spectrums, arr_peaks, time_str, is_use_ev, is_first_plot, is_xrf_log, absorbers, nxs_name)¶
Plot sum over all the spectrums of a XRF scan.
- Parameters:
channels (array) – The extracted channels.
energies (array) – The extracted channels converted to eVs.
spectrums (array) – The extracted spectrums (between point 0 and last point with signal).
arr_peaks (array of tuples) – Peaks to display, for ex. arr_peaks = [(‘Elastic’, ‘12000.’), (‘Compton’, ‘11670.’)]
time_str (str) – Starting/ending dates of the scan.
is_use_ev (bool) – Convert the channels to eVs.
is_first_plot (bool) – True if this is the first plot of the series (to print title and text).
is_xrf_log (bool) – Log on the intensity in the plots.
absorbers (str) – Text to display which absorber was used.
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
- Returns:
fig_sum – The figure of the sum to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.xrf.process_xrf_scan(nxs_name, path_to_nxs_dir, list_sdd_elems, channel_xrf_first=0, channel_xrf_last=2048, sdd_gain=10.0, sdd_ev0=0.0, arr_peaks=[(None, None)], is_use_ev=False, is_xrf_log=True, absorbers='', path_to_save_dir='', is_print_stamps=False, is_plot_spectrogram=False, is_plot_sum=False, is_plot_first_last=False, is_save=False, is_print_info=False)¶
Call functions for extracting, plotting, and saving a XRF scan.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
list_sdd_elems (list of int) – List of SDD elements, e.g. [0, 1, 2]
channel_xrf_first (int, optional) – Spectrums are extracted between channel_xrf_first and channel_xrf_last.
channel_xrf_last (int, optional) – Spectrums are extracted between channel_xrf_first and channel_xrf_last.
sdd_gain (float, optional) – Channels are converted to eVs following eVs = sdd_gain*channel+sdd_ev0
sdd_ev0 (float, optional) – Channels are converted to eVs following eVs = sdd_gain*channel+sdd_ev0
arr_peaks (array of tuples, optional) – Peaks to display, for ex. arr_peaks = [(‘Elastic’, ‘12000.’), (‘Compton’, ‘11670.’)]
is_use_ev (bool, optional) – Convert the channels to eVs.
is_xrf_log (bool, optional) – Log on the intensity in the plots.
absorbers (str, optional) – Text to display which absorber was used.
path_to_save_dir (str, optional) – Path to the directory where the treated files will be saved.
is_print_stamps (bool, optional) – Print the list of sensors contained in the nexus file.
is_plot_spectrogram (bool, optional) – Plot the spectrogram.
is_plot_sum (bool, optional) – Plot the sum of all the spectrums present in the scan.
is_plot_first_last (bool, optional) – Plot the first and last spectrums.
is_save (bool, optional) – Save the results.
is_print_info (bool, optional) – Verbose mode.
- Returns:
channels (array) – The extracted channels.
energies (array) – The extracted channels converted to eVs.
spectrums (array) – The extracted spectrums (between point 0 and last point with signal).
- lib.backend.xrf.save_xrf_scan(nxs_name, path_to_nxs_dir, stamps_0d, data_0d, fig_spectrogram, fig_sum, fig_first_last, path_to_save_dir, is_print_info)¶
Save XRF data.
To avoid passing large variables such as each spectrum (not summed), we redo the extraction with PyNexus directly within this function.
XXX_fluospectrumNN.mat: the matrix corresponding to the spectrums of SDD elements NN, in ascii. XXX.dat : the value of each sensor at each point of the scan. XXX_spectrogram.pdf : the figure of the spectrogram in pdf. XXX_sum.pdf : the figure of the sum in pdf. XXX_first_last.pdf : the figure of the first and last spectrums in pdf.
- Parameters:
nxs_name (str) – Nexus name, e.g. SIRIUS_2020_03_12_0756.nxs.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
stamps_0d (array) – Aliases of each 0D sensor in the scan.
data_0d (array) – Values of each 0D sensor in the scan.
fig_spectrogram (matplotlib None or matplotlib figure) – The figure of the spectrogram to be saved in pdf.
fig_sum (matplotlib None or matplotlib figure) – The figure of the sum to be saved in pdf.
fig_first_last (matplotlib None or matplotlib figure) – The figure of the first and last spectrums to be saved in pdf.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_info (bool) – Verbose mode.
- Raises:
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
lib.backend.xrr module¶
Module for processing XRR (on solids and liquids).
- lib.backend.xrr.extract_direct_xrr_liquid(direct_scan_name, roi_x0, roi_size_x, roi_size_y, summation_roi_size_y, is_bckg_up, is_bckg_down, is_bckg_left, is_bckg_right, is_track_beam, path_to_nxs_dir, is_print_info)¶
Extract the value of the direct beam.
- Parameters:
direct_scan_name (str) – Nexus filename of the direct scan.
roi_x0 (int) – x0 of the full-scan ROI.
roi_size_x (int) – Size x of the full-scan ROI.
roi_size_y (int) – Size y of the full-scan ROI.
summation_roi_size_y (int) – Size y of the summation ROI (centered on the beam). It has to be an odd number.
is_bckg_up (bool) – Take into account the upper ROI for background subtraction.
is_bckg_down (bool) – Take into account the lower ROI for background subtraction.
is_bckg_left (bool) – Take into account the left ROI for background subtraction.
is_bckg_right (bool) – Take into account the right ROI for background subtraction.
is_track_beam (bool) – Track the vertical position of the reflected beam.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
is_print_info (bool) – Verbose mode.
- Returns:
direct_value – Direct after background subtraction and normalization.
- Return type:
float
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
SystemExit('Required sensor not found.') – If a required sensor is not found in the sensor list.
- lib.backend.xrr.extract_direct_xrr_solid(direct_scan_name, roi_x0, roi_size_x, roi_size_y, is_bckg_up, is_bckg_down, is_bckg_left, is_bckg_right, path_to_nxs_dir, is_print_info)¶
Extract the value of the direct beam.
- Parameters:
direct_scan_name (str) – Nexus filename of the direct scan.
roi_x0 (int) – x0 of the full-scan ROI.
roi_size_x (int) – Size x of the full-scan ROI.
roi_size_y (int) – Size y of the full-scan ROI. It has to be an odd number.
is_bckg_up (bool) – Take into account the upper ROI for background subtraction.
is_bckg_down (bool) – Take into account the lower ROI for background subtraction.
is_bckg_left (bool) – Take into account the left ROI for background subtraction.
is_bckg_right (bool) – Take into account the right ROI for background subtraction.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
is_print_info (bool) – Verbose mode.
- Returns:
direct_value – Direct after background subtraction and normalization.
- Return type:
float
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
SystemExit('Required sensor not found.') – If a required sensor is not found in the sensor list.
- lib.backend.xrr.extract_volt_ion_chamber_liquid(list_xrr_files, scan_type, path_to_nxs_dir)¶
Extract the voltages of the ionization chamber in the case of an XRR on a liquid.
- Parameters:
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
scan_type (str) – ‘refl’ or ‘direct’.
path_to_nxs_dir (str) – directory where the nexus file is stored.
- Returns:
voltages – List of voltages of the ionization chamber (normalized by its gain).
- Return type:
array
- lib.backend.xrr.extract_xrr_liquid_scan(list_xrr_files, path_to_nxs_dir, roi_x0, roi_y0, roi_size_x, roi_size_y, summation_roi_size_y, m4pitch0, wavelength, direct_value, is_bckg_up, is_bckg_down, is_bckg_left, is_bckg_right, is_track_beam, is_print_info)¶
Extract the XRR from a series of scans.
- Parameters:
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
roi_x0 (int) – x0 of the full-scan ROI.
roi_y0 (int) – y0 of the full-scan ROI.
roi_size_x (int) – Size x of the full-scan ROI.
roi_size_y (int) – Size y of the full-scan ROI.
summation_roi_size_y (int) – Size y of the summation ROI (centered on the beam). It has to be an odd number.
m4pitch0 (float) – Value of m4pitch0 (m4pitch aligned with the beam) in deg.
wavelength (float) – Wavelength in nm.
direct_value (float) – Direct after background subtraction and normalization.
is_bckg_up (bool) – Take into account the upper ROI for background subtraction.
is_bckg_down (bool) – Take into account the lower ROI for background subtraction.
is_bckg_left (bool) – Take into account the left ROI for background subtraction.
is_bckg_right (bool) – Take into account the right ROI for background subtraction.
is_track_beam (bool) – Track the vertical position of the reflected beam.
is_print_info (bool) – Verbose mode.
- Returns:
m4pitch (array) – List of m4pitch (deg).
theta (array) – List of theta (rad).
qz (array) – List of qz (nm-1).
pos_y_beam (array) – List of vertical positions of the reflected beam (pix).
bckg_refl_up (array) – List of integrated intensities of the bckg up.
bckg_refl_down (array) – List of integrated intensities of the bckg down.
bckg_refl_left (array) – List of integrated intensities of the bckg left.
bckg_refl_right (array) – List of integrated intensities of the bckg right.
bckg_refl (array) – List of averaged chosen backgrounds.
err_refl (array) – List of error bars of the XRR.
refl (array) – List of values of the normalized XRR.
time_str (str) – Starting/ending dates of the whole XRR scan.
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
SystemExit('Required sensor not found.') – If a required sensor is not found in the sensor list.
- lib.backend.xrr.extract_xrr_solid_scan(list_xrr_files, path_to_nxs_dir, roi_x0, roi_y0, roi_size_x, roi_size_y, wavelength, direct_value, is_bckg_up, is_bckg_down, is_bckg_left, is_bckg_right, is_print_info)¶
Extract the XRR from a series of scans.
- Parameters:
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
roi_x0 (int) – x0 of the full-scan ROI.
roi_y0 (int) – y0 of the full-scan ROI.
roi_size_x (int) – Size x of the full-scan ROI.
roi_size_y (int) – Size y of the full-scan ROI. It has to be an odd number.
wavelength (float) – Wavelength in nm.
direct_value (float) – Direct after background subtraction and normalization.
is_bckg_up (bool) – Take into account the upper ROI for background subtraction.
is_bckg_down (bool) – Take into account the lower ROI for background subtraction.
is_bckg_left (bool) – Take into account the left ROI for background subtraction.
is_bckg_right (bool) – Take into account the right ROI for background subtraction.
is_print_info (bool) – Verbose mode.
- Returns:
theta (array) – List of theta (rad).
qz (array) – List of qz (nm-1).
bckg_refl_up (array) – List of integrated intensities of the bckg up.
bckg_refl_down (array) – List of integrated intensities of the bckg down.
bckg_refl_left (array) – List of integrated intensities of the bckg left.
bckg_refl_right (array) – List of integrated intensities of the bckg right.
bckg_refl (array) – List of averaged chosen backgrounds.
err_refl (array) – List of error bars of the XRR.
refl (array) – List of values of the normalized XRR.
time_str (str) – Starting/ending dates of the whole XRR scan.
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
SystemExit('Required sensor not found.') – If a required sensor is not found in the sensor list.
- lib.backend.xrr.plot_calib_xrr_liquid(calib_xrr_data, distance_detec)¶
Fit and plot the values from the calibration, to give the user the coefficient to be used in the XRR scripts (on liquids).
- Parameters:
calib_xrr_data (array) – Numpy array containing the values of m4pitch, c10tablepitch, gamma and zs for the calibration.
distance_detec (float) – Distance between the detector and the center of the sample in mm.
- lib.backend.xrr.plot_xrr_m4pitch(m4pitch, bckg_refl, err_refl, refl, list_xrr_files, is_first_plot, time_str)¶
Plot XRR as a function of m4pitch.
- Parameters:
m4pitch (array) – List of m4pitch (deg).
bckg_refl (array) – List of averaged chosen backgrounds.
err_refl (array) – List of error bars of the XRR.
refl (array) – List of values of the normalized XRR.
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
is_first_plot (bool) – True if this is the first plot of the series (to print title and text).
time_str (str) – Starting/ending dates of the whole XRR scan.
- Returns:
fig_m4pitch – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.xrr.plot_xrr_pos_y_beam(m4pitch, pos_y_beam, list_xrr_files, is_first_plot, time_str)¶
Plot the vertical position of the reflected beam as a function of m4pitch.
- Parameters:
m4pitch (array) – List of m4pitch (deg).
pos_y_beam (array) – List of vertical positions of the reflected beam (pix).
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
is_first_plot (bool) – True if this is the first plot of the series (to print title and text).
time_str (str) – Starting/ending dates of the whole XRR scan.
- Returns:
fig_pos_y_beam – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.xrr.plot_xrr_qz(qz, bckg_refl, err_refl, refl, list_xrr_files, is_first_plot, time_str)¶
Plot XRR as a function of qz.
- Parameters:
qz (array) – List of qz (nm-1).
bckg_refl (array) – List of averaged chosen backgrounds.
err_refl (array) – List of error bars of the XRR.
refl (array) – List of values of the normalized XRR.
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
is_first_plot (bool) – True if this is the first plot of the series (to print title and text).
time_str (str) – Starting/ending dates of the whole XRR scan.
- Returns:
fig_qz – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.xrr.plot_xrr_twotheta(theta, bckg_refl, err_refl, refl, list_xrr_files, is_first_plot, time_str)¶
Plot XRR as a function of 2*theta.
- Parameters:
theta (array) – List of theta (rad).
bckg_refl (array) – List of averaged chosen backgrounds.
err_refl (array) – List of error bars of the XRR.
refl (array) – List of values of the normalized XRR.
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
is_first_plot (bool) – True if this is the first plot of the series (to print title and text).
time_str (str) – Starting/ending dates of the whole XRR scan.
- Returns:
fig_twotheta – The figure to be saved in pdf.
- Return type:
matplotlib figure
- lib.backend.xrr.process_xrr_liquid_scan(list_xrr_files, path_to_nxs_dir, direct_scan_name, roi_x0, roi_y0, roi_size_x, roi_size_y, summation_roi_size_y, m4pitch0, wavelength, fdirect=1.0, is_bckg_up=True, is_bckg_down=True, is_bckg_left=False, is_bckg_right=False, is_force_direct=True, is_track_beam=True, path_to_save_dir='', is_plot_m4pitch=False, is_plot_twotheta=False, is_plot_qz=False, is_plot_pos_y_beam=False, is_save=False, is_print_info=False)¶
Call functions for extracting, plotting, and saving a XRR scan on a liquid.
- Parameters:
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
direct_scan_name (str) – Nexus filename of the direct scan.
roi_x0 (int) – x0 of the full-scan ROI.
roi_y0 (int) – y0 of the full-scan ROI.
roi_size_x (int) – Size x of the full-scan ROI.
roi_size_y (int) – Size y of the full-scan ROI.
summation_roi_size_y (int) – Size y of the summation ROI (centered on the beam). It has to be an odd number.
m4pitch0 (float) – Value of m4pitch0 (m4pitch aligned with the beam) in deg.
wavelength (float) – Wavelength in nm.
fdirect (float, optional) – Value of the normalisation to be used if is_force_direct is True
is_bckg_up (bool, optional) – Take into account the upper ROI for background subtraction.
is_bckg_down (bool, optional) – Take into account the lower ROI for background subtraction.
is_bckg_left (bool, optional) – Take into account the left ROI for background subtraction.
is_bckg_right (bool, optional) – Take into account the right ROI for background subtraction.
is_force_direct (bool, optional) – Force the normalization to be equal to the value of fdirect.
is_track_beam (bool, optional) – Track the vertical position of the reflected beam.
path_to_save_dir (str, optional) – Path to the directory where the treated files will be saved.
is_plot_m4pitch (bool, optional) – Plot the XRR as a function of m4pitch.
is_plot_twotheta (bool, optional) – Plot the XRR as a function of 2*theta.
is_plot_qz (bool, optional) – Plot the XRR as a function of qz.
is_plot_pos_y_beam (bool, optional) – Plot the vertical position of the reflected beam as a function of m4pitch.
is_save (bool, optional) – Save the results.
is_print_info (bool, optional) – Verbose mode.
- Returns:
m4pitch (array) – List of m4pitch (deg).
theta (array) – List of theta (rad).
qz (array) – List of qz (nm-1).
bckg_refl_up (array) – List of integrated intensities of the bckg up.
bckg_refl_down (array) – List of integrated intensities of the bckg down.
bckg_refl_left (array) – List of integrated intensities of the bckg left.
bckg_refl_right (array) – List of integrated intensities of the bckg right.
bckg_refl (array) – List of averaged chosen backgrounds.
err_refl (array) – List of error bars of the XRR.
refl (array) – List of values of the normalized XRR.
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
SystemExit('Required sensor not found.') – If a required sensor is not found in the sensor list.
- lib.backend.xrr.process_xrr_solid_scan(list_xrr_files, path_to_nxs_dir, direct_scan_name, roi_x0, roi_y0, roi_size_x, roi_size_y, wavelength, fdirect=1.0, is_bckg_up=True, is_bckg_down=True, is_bckg_left=False, is_bckg_right=False, is_force_direct=True, path_to_save_dir='', is_plot_twotheta=False, is_plot_qz=False, is_save=False, is_print_info=False)¶
Call functions for extracting, plotting, and saving a XRR scan on a solid.
- Parameters:
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
direct_scan_name (str) – Nexus filename of the direct scan.
roi_x0 (int) – x0 of the full-scan ROI.
roi_y0 (int) – y0 of the full-scan ROI.
roi_size_x (int) – Size x of the full-scan ROI.
roi_size_y (int) – Size y of the full-scan ROI. It has to be an odd number.
wavelength (float) – Wavelength in nm.
fdirect (float, optional) – Value of the normalisation to be used if is_force_direct is True
is_bckg_up (bool, optional) – Take into account the upper ROI for background subtraction.
is_bckg_down (bool, optional) – Take into account the lower ROI for background subtraction.
is_bckg_left (bool, optional) – Take into account the left ROI for background subtraction.
is_bckg_right (bool, optional) – Take into account the right ROI for background subtraction.
is_force_direct (bool, optional) – Force the normalization to be equal to the value of fdirect.
path_to_save_dir (str, optional) – Path to the directory where the treated files will be saved.
is_plot_twotheta (bool, optional) – Plot the XRR as a function of 2*theta.
is_plot_qz (bool, optional) – Plot the XRR as a function of qz.
is_save (bool, optional) – Save the results.
is_print_info (bool, optional) – Verbose mode.
- Returns:
theta (array) – List of theta (rad).
qz (array) – List of qz (nm-1).
bckg_refl_up (array) – List of integrated intensities of the bckg up.
bckg_refl_down (array) – List of integrated intensities of the bckg down.
bckg_refl_left (array) – List of integrated intensities of the bckg left.
bckg_refl_right (array) – List of integrated intensities of the bckg right.
bckg_refl (array) – List of averaged chosen backgrounds.
err_refl (array) – List of error bars of the XRR.
refl (array) – List of values of the normalized XRR.
- Raises:
FileNotFoundError – If a file or a folder is missing.
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
SystemExit('Required sensor not found.') – If a required sensor is not found in the sensor list.
- lib.backend.xrr.save_xrr_liquid_scan(m4pitch, theta, qz, pos_y_beam, bckg_refl_up, bckg_refl_down, bckg_refl_left, bckg_refl_right, bckg_refl, err_refl, refl, list_xrr_files, fig_m4pitch, fig_twotheta, fig_qz, fig_pos_y_beam, path_to_nxs_dir, path_to_save_dir, is_print_info)¶
Save data of a XRR scan on a liquid.
To save the .dat of each individual file, we redo the extraction with PyNexus directly within this function.
XXX_XRR.dat: different parameters relevant for XRR for each point of m4pitch taken. XXX.dat: the value of each sensor at each point of each scan in the list of XRR files. XXX_XRR_m4pitch.pdf, XXX_XRR_qz.pdf, XXX_XRR_twotheta.pdf, XXX_XRR_pos_y_beam.pdf: the figures in pdf.
- Parameters:
m4pitch (array) – List of m4pitch (deg).
theta (array) – List of theta (rad).
qz (array) – List of qz (nm-1).
pos_y_beam (array) – List of vertical positions of the reflected beam (pix).
bckg_refl_up (array) – List of integrated intensities of the bckg up.
bckg_refl_down (array) – List of integrated intensities of the bckg down.
bckg_refl_left (array) – List of integrated intensities of the bckg left.
bckg_refl_right (array) – List of integrated intensities of the bckg right.
bckg_refl (array) – List of averaged chosen backgrounds.
err_refl (array) – List of error bars of the XRR.
refl (array) – List of values of the normalized XRR.
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
fig_m4pitch (matplotlib figure) – The figure to be saved in pdf.
fig_twotheta (matplotlib figure) – The figure to be saved in pdf.
fig_qz (matplotlib figure) – The figure to be saved in pdf.
fig_pos_y_beam (matplotlib figure) – The figure to be saved in pdf.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_info (bool) – Verbose mode.
- Raises:
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.
- lib.backend.xrr.save_xrr_solid_scan(theta, qz, bckg_refl_up, bckg_refl_down, bckg_refl_left, bckg_refl_right, bckg_refl, err_refl, refl, list_xrr_files, fig_twotheta, fig_qz, path_to_nxs_dir, path_to_save_dir, is_print_info)¶
Save data of a XRR scan on a solid.
To save the .dat of each individual file, we redo the extraction with PyNexus directly within this function.
XXX_XRR.dat: different parameters relevant for XRR for each point of theta taken. XXX.dat: the value of each sensor at each point of each scan in the list of XRR files. XXX_XRR_qz.pdf, XXX_XRR_twotheta.pdf: the figures in pdf.
- Parameters:
theta (array) – List of theta (rad).
qz (array) – List of qz (nm-1).
bckg_refl_up (array) – List of integrated intensities of the bckg up.
bckg_refl_down (array) – List of integrated intensities of the bckg down.
bckg_refl_left (array) – List of integrated intensities of the bckg left.
bckg_refl_right (array) – List of integrated intensities of the bckg right.
bckg_refl (array) – List of averaged chosen backgrounds.
err_refl (array) – List of error bars of the XRR.
refl (array) – List of values of the normalized XRR.
list_xrr_files (list of str) – List of XRR file names without the ‘.nxs’, e.g. [‘SIRIUS_2021_06_18_0568’].
fig_twotheta (matplotlib figure) – The figure to be saved in pdf.
fig_qz (matplotlib figure) – The figure to be saved in pdf.
path_to_nxs_dir (str) – Path to the nexus files directory, e.g. user/.
path_to_save_dir (str) – Path to the directory where the treated files will be saved.
is_print_info (bool) – Verbose mode.
- Raises:
SystemExit('Could not open Nexus file.')) – If the Nexus file cannot be accessed.