epyr.sub.utils

Shared utilities for the Bruker BES3T and ESP loaders.

Implements parameter-file parsing (.DSC / .par), binary matrix reading from .DTA / .spc payloads, and directory listing for Bruker file sets.

Functions

BrukerListFiles(path[, recursive])

List Bruker EPR data files (.DTA, .dta, .SPC, .spc) in path.

get_matrix(data_file_path, dimensions, ...)

Read binary EPR data from disk into a NumPy array.

parse_field_params(parameters)

Attempts to convert string values in a dictionary to numbers (int or float).

read_dsc_file(dsc_file_path)

Reads a Bruker BES3T .DSC file (key-value pairs, handles line continuation).

read_par_file(par_file_path)

Reads a Bruker ESP/WinEPR .par file (key-value pairs).

epyr.sub.utils.read_par_file(par_file_path)[source]

Reads a Bruker ESP/WinEPR .par file (key-value pairs).

Parameters:

par_file_path (Path)

Return type:

dict

epyr.sub.utils.read_dsc_file(dsc_file_path)[source]

Reads a Bruker BES3T .DSC file (key-value pairs, handles line continuation).

Parameters:

dsc_file_path (Path)

Return type:

dict

epyr.sub.utils.parse_field_params(parameters)[source]

Attempts to convert string values in a dictionary to numbers (int or float).

Parameters:

parameters (dict)

Return type:

dict

epyr.sub.utils.get_matrix(data_file_path, dimensions, number_format_code, byte_order, is_complex)[source]

Read binary EPR data from disk into a NumPy array.

Parameters:
  • data_file_path (pathlib.Path) – Path to the binary data file (.DTA / .spc).

  • dimensions (list of int) – Three-element list [nx, ny, nz].

  • number_format_code (str) – NumPy short dtype code ('i1', 'i2', 'i4', 'f4', 'f8').

  • byte_order (str) – 'ieee-be' (big-endian) or 'ieee-le' (little-endian).

  • is_complex (bool or np.ndarray) – Whether the payload is complex. An array allows per-channel flags.

Returns:

Loaded data, reshaped to the requested dimensions.

Return type:

np.ndarray

epyr.sub.utils.BrukerListFiles(path, recursive=False)[source]

List Bruker EPR data files (.DTA, .dta, .SPC, .spc) in path.

Parameters:
  • path (str or pathlib.Path) – Directory to scan.

  • recursive (bool, optional) – If True, also descend into subdirectories. Default is False.

Returns:

Sorted list of matching files.

Return type:

list of pathlib.Path

Raises:

NotADirectoryError – If path is not an existing directory.

Examples

>>> from epyr import BrukerListFiles
>>> files = BrukerListFiles("examples/data")
>>> any(p.name.endswith(".DTA") for p in files)
True
>>> all_files = BrukerListFiles("examples/data", recursive=True)
>>> len(all_files) >= len(files)
True