epyr.eprload module
The epyr.eprload module provides the main interface for loading EPR data files from Bruker spectrometers.
Main Function
Unified entry point for loading Bruker EPR data files.
Exposes eprload(), which auto-detects BES3T (.dta/.dsc) or ESP/WinEPR
(.spc/.par) format and dispatches to the appropriate loader in
epyr.sub. Tkinter is imported for the optional file-picker dialog.
- epyr.eprload.eprload(file_name=None, scaling='', plot_if_possible=False, save_if_possible=False, return_type='default')[source]
Load experimental EPR data from Bruker BES3T or ESP formats.
- Parameters:
file_name (str or Path, optional) – Path to the data file (.dta, .dsc, .spc, .par) or a directory. If None or a directory, a file browser is shown. Default is None (opens browser in the current working directory).
scaling (str, optional) –
String of characters specifying scaling operations (Bruker files only). Each character enables one operation:
'n': divide by number of scans (AVGS/JSD)'P': divide by sqrt of microwave power in mW (MWPW/MP)'G': divide by receiver gain (RCAG/RRG)'T': multiply by temperature in Kelvin (STMP/TE)'c': divide by conversion/sampling time in ms (SPTP/RCT)
Default is “” (no scaling).
plot_if_possible (bool, optional) – If True and data loads successfully, generate a matplotlib plot. Default is False.
save_if_possible (bool, optional) – Reserved for future use. Default is False.
return_type ({'default', 'real', 'imag'}, optional) –
Component of the signal to return:
'default': return y as-is (real + imaginary if complex)'real': return onlynp.real(y)'imag': return onlynp.imag(y)
Default is “default”.
- Returns:
x (np.ndarray or list of np.ndarray or None) – Abscissa data; list of axes for 2D datasets. None on failure.
y (np.ndarray or None) – Ordinate data (signal). None on failure.
pars (dict or None) – Parameters extracted from the descriptor/parameter file. None on failure.
file_path (str or None) – Resolved absolute path of the loaded file. None on failure.
- Raises:
FileNotFoundError – If the specified file or directory does not exist.
ValueError – If the file format is unsupported, scaling is invalid, or parameter inconsistencies are found.
IOError – If reading files fails.
- Return type:
Tuple[ndarray | List[ndarray] | None, ndarray | None, Dict[str, Any] | None, str | None]
Examples
Load a CW EPR file and inspect its shape:
>>> from epyr import eprload >>> x, y, params, path = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC") >>> y.shape (1024,) >>> params["MWFQ"] # microwave frequency, Hz 9387600000.0
Apply gain + averages scaling and keep only the real part:
>>> x, y, _, _ = eprload("file.DSC", scaling="nG", return_type="real")
Load a 2D dataset (returns a list of axes for x):
>>> x, y, _, _ = eprload("examples/data/Rabi2D_GdCaWO4_13dB_3057G.DSC") >>> y.shape, len(x) ((500, 1024), 2)
The eprload() function is the primary entry point for loading EPR data. It automatically detects the file format and calls the appropriate loader function.
Usage Examples
Basic Usage
import epyr.eprload as eprload
# Open file dialog to select EPR data
x, y, params, filepath = eprload.eprload()
# Or specify file directly
x, y, params, filepath = eprload.eprload('spectrum.dsc')
With Parameters
# Disable plotting
x, y, params, filepath = eprload.eprload('data.dsc', plot_if_possible=False)
# Apply scaling during load
x, y, params, filepath = eprload.eprload('data.dsc', scaling='nPGT')
# Save processed data
x, y, params, filepath = eprload.eprload('data.dsc', save_if_possible=True)
Supported File Formats
BES3T Format
.dsc files: Descriptor files containing measurement parameters
.dta files: Binary data files containing spectral data
ESP/WinEPR Format
.par files: Parameter files with measurement settings
.spc files: Binary spectrum data files
Return Values
The eprload() function returns a tuple containing:
x (numpy.ndarray): X-axis data (typically magnetic field in Gauss)
y (numpy.ndarray): Y-axis data (EPR signal intensity)
params (dict): Dictionary of measurement parameters from the file
filepath (str): Path to the loaded data file
All Functions
Unified entry point for loading Bruker EPR data files.
Exposes eprload(), which auto-detects BES3T (.dta/.dsc) or ESP/WinEPR
(.spc/.par) format and dispatches to the appropriate loader in
epyr.sub. Tkinter is imported for the optional file-picker dialog.
- epyr.eprload.eprload(file_name=None, scaling='', plot_if_possible=False, save_if_possible=False, return_type='default')[source]
Load experimental EPR data from Bruker BES3T or ESP formats.
- Parameters:
file_name (str or Path, optional) – Path to the data file (.dta, .dsc, .spc, .par) or a directory. If None or a directory, a file browser is shown. Default is None (opens browser in the current working directory).
scaling (str, optional) –
String of characters specifying scaling operations (Bruker files only). Each character enables one operation:
'n': divide by number of scans (AVGS/JSD)'P': divide by sqrt of microwave power in mW (MWPW/MP)'G': divide by receiver gain (RCAG/RRG)'T': multiply by temperature in Kelvin (STMP/TE)'c': divide by conversion/sampling time in ms (SPTP/RCT)
Default is “” (no scaling).
plot_if_possible (bool, optional) – If True and data loads successfully, generate a matplotlib plot. Default is False.
save_if_possible (bool, optional) – Reserved for future use. Default is False.
return_type ({'default', 'real', 'imag'}, optional) –
Component of the signal to return:
'default': return y as-is (real + imaginary if complex)'real': return onlynp.real(y)'imag': return onlynp.imag(y)
Default is “default”.
- Returns:
x (np.ndarray or list of np.ndarray or None) – Abscissa data; list of axes for 2D datasets. None on failure.
y (np.ndarray or None) – Ordinate data (signal). None on failure.
pars (dict or None) – Parameters extracted from the descriptor/parameter file. None on failure.
file_path (str or None) – Resolved absolute path of the loaded file. None on failure.
- Raises:
FileNotFoundError – If the specified file or directory does not exist.
ValueError – If the file format is unsupported, scaling is invalid, or parameter inconsistencies are found.
IOError – If reading files fails.
- Return type:
Tuple[ndarray | List[ndarray] | None, ndarray | None, Dict[str, Any] | None, str | None]
Examples
Load a CW EPR file and inspect its shape:
>>> from epyr import eprload >>> x, y, params, path = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC") >>> y.shape (1024,) >>> params["MWFQ"] # microwave frequency, Hz 9387600000.0
Apply gain + averages scaling and keep only the real part:
>>> x, y, _, _ = eprload("file.DSC", scaling="nG", return_type="real")
Load a 2D dataset (returns a list of axes for x):
>>> x, y, _, _ = eprload("examples/data/Rabi2D_GdCaWO4_13dB_3057G.DSC") >>> y.shape, len(x) ((500, 1024), 2)