epyr.eprload

epyr.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 only np.real(y)

    • 'imag' : return only np.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)