epyr.fair module

The epyr.fair module provides functionality for converting proprietary Bruker EPR data into FAIR (Findable, Accessible, Interoperable, and Reusable) formats.

Overview

FAIR data principles ensure that scientific data is:

  • Findable: Data has metadata and identifiers

  • Accessible: Data can be retrieved with standard protocols

  • Interoperable: Data uses standard vocabularies and formats

  • Reusable: Data has clear licenses and provenance

This module converts Bruker EPR files to open formats: CSV, JSON, and HDF5.

Main Functions

Conversion Functions

Main conversion functions and workflows for Bruker EPR to FAIR format conversion.

This module provides the high-level interface for converting Bruker EPR data to FAIR-compliant formats using the EPyR Tools package.

epyr.fair.conversion.convert_bruker_to_fair(input_file, output_dir=None, formats=None, include_metadata=True, scaling='')[source]

Load a Bruker file and convert it to FAIR-compliant formats.

End-to-end pipeline: epyr.eprload() -> parameter normalization -> writing one or more output files next to the input.

Parameters:
  • input_file (str or pathlib.Path) – Path to a Bruker data file (.dta, .dsc, .spc, .par).

  • output_dir (str or pathlib.Path, optional) – Where to write the converted files. Defaults to the input file’s directory. Created if missing.

  • formats (list of str, optional) –

    Subset of ['csv', 'json', 'hdf5', 'jpg']. Default ['csv', 'json'].

    • csv : data array

    • json : metadata only

    • hdf5 : data + metadata in one file

    • jpg : preview figure (1D plot or 2D map + waterfall)

  • include_metadata (bool, optional) – Whether CSV files should carry the parameter dictionary as commented header lines. Default True.

  • scaling (str, optional) – Scaling code passed through to epyr.eprload(). Default "".

Returns:

True on success, False if loading or writing failed (errors are logged, not raised).

Return type:

bool

Examples

>>> from epyr.fair import convert_bruker_to_fair
>>> ok = convert_bruker_to_fair(
...     "examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC",
...     output_dir="/tmp/epyr_out",
...     formats=["json", "hdf5"],
... )
>>> ok
True
epyr.fair.conversion.save_fair(output_basename, x, y, params, original_file_path, output_formats=None)[source]

Write already-loaded EPR data to one or more FAIR formats.

Use this when data is already in memory (e.g., after processing) and you want to write outputs without re-reading the Bruker file.

Parameters:
  • output_basename (str or pathlib.Path) – Base path (no extension); each format appends its own.

  • x (np.ndarray, list of np.ndarray, or None) – Abscissa as returned by epyr.eprload().

  • y (np.ndarray) – Signal data.

  • params (dict) – Parameter dictionary from the original file.

  • original_file_path (str) – Full path of the source file, kept as provenance in the outputs.

  • output_formats (list of str, optional) – Subset of ['csv', 'json', 'hdf5', 'jpg', 'csv_json']. Default ['csv', 'json'].

Returns:

Outputs are written to disk under output_basename.

Return type:

None

Examples

>>> import numpy as np
>>> from epyr.fair import save_fair
>>> x = np.linspace(3300, 3400, 100)
>>> y = np.random.randn(100)
>>> save_fair("/tmp/demo", x, y, {"MWFQ": 9.4e9},
...           "demo.dsc", ["json"])
epyr.fair.conversion.batch_convert_directory(input_directory, output_directory=None, file_extensions=None, scaling='', output_formats=None, recursive=False)[source]

Convert every Bruker file in a directory to FAIR formats.

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

  • output_directory (str or pathlib.Path, optional) – Where to write the converted files. Defaults to alongside each input file. Created if missing.

  • file_extensions (list of str, optional) – Which extensions count as Bruker files. Default ['.dsc', '.spc', '.par'].

  • scaling (str, optional) – Scaling code passed through to epyr.eprload().

  • output_formats (list of str, optional) – Subset of ['csv', 'json', 'hdf5', 'jpg']. Default ['csv', 'json'].

  • recursive (bool, optional) – Also descend into subdirectories. Default False.

Returns:

Progress and a final per-file summary are logged.

Return type:

None

Examples

>>> from epyr.fair import batch_convert_directory
>>> batch_convert_directory(
...     "examples/data",
...     output_directory="/tmp/epyr_batch",
...     output_formats=["json"],
... )
epyr.fair.conversion.validate_conversion(fair_json_file, original_data_file=None)[source]

Validate a FAIR conversion by checking the JSON metadata file.

Parameters:
  • fair_json_file (str | Path) – Path to the JSON metadata file from FAIR conversion.

  • original_data_file (str | Path | None) – Path to original data file for comparison (optional).

Returns:

Dictionary with validation results including warnings and statistics.

Return type:

Dict[str, Any]

Data Processing

Core data processing and metadata handling for FAIR format conversion.

This module contains functions for processing Bruker EPR parameters and preparing metadata for FAIR format export.

epyr.fair.data_processing.process_parameters(pars)[source]

Split raw Bruker parameters into FAIR-mapped and unmapped buckets.

Uses epyr.fair.BRUKER_PARAM_MAP to translate Bruker keys (DSC / SPL / DSL sections) into FAIR field names with explicit units and descriptions. Unit references ('refer to XUNI') are resolved against the source dictionary.

Parameters:

pars (dict) – Raw parameters from epyr.eprload().

Returns:

  • fair_metadata (dict) – {fair_name: {'value', 'unit', 'description'}, ...}, including a conversion_info entry with timestamp and EPyR version.

  • unmapped_parameters (dict) – Pass-through of keys not present in BRUKER_PARAM_MAP.

Return type:

Tuple[Dict[str, Any], Dict[str, Any]]

Examples

>>> from epyr import eprload
>>> from epyr.fair import process_parameters
>>> x, y, params, _ = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC")
>>> fair, unmapped = process_parameters(params)
>>> "microwave_frequency" in fair
True
epyr.fair.data_processing.append_fair_metadata(data_dict, pars, original_file='')[source]

Append FAIR metadata to existing data dictionary.

Parameters:
  • data_dict (Dict[str, Any]) – Existing data dictionary to append to

  • pars (Dict[str, Any]) – Raw parameters from Bruker file

  • original_file (str) – Original file path

Returns:

Updated data dictionary with FAIR metadata

Return type:

Dict[str, Any]

epyr.fair.data_processing.extract_axis_info(pars)[source]

Extract axis information from parameters.

Parameters:

pars (Dict[str, Any]) – Raw parameters dictionary

Returns:

Dictionary with x, y, z axis information

Return type:

Dict[str, Dict[str, Any]]

epyr.fair.data_processing.validate_fair_metadata(metadata)[source]

Validate FAIR metadata for completeness and correctness.

Parameters:

metadata (Dict[str, Any]) – FAIR metadata dictionary

Returns:

List of validation warnings/errors

Return type:

List[str]

epyr.fair.data_processing.get_experiment_summary(metadata)[source]

Extract key experimental parameters for quick overview.

Parameters:

metadata (Dict[str, Any]) – FAIR metadata dictionary

Returns:

Dictionary with experiment summary

Return type:

Dict[str, Any]

Export Functions

Format-specific export functions for FAIR data conversion.

This module contains functions to export EPR data and metadata to various FAIR-compliant formats including CSV/JSON and HDF5.

epyr.fair.exporters.save_to_json(output_basename, pars, original_file_path)[source]

Write parameter metadata to <basename>.json.

The output contains the source-file path, the FAIR-normalized metadata, and any unmapped Bruker keys preserved verbatim.

Parameters:
  • output_basename (pathlib.Path) – Base path; .json is appended.

  • pars (dict) – Raw Bruker parameters as returned by epyr.eprload().

  • original_file_path (str) – Source-file path kept as provenance.

Return type:

None

Examples

>>> from pathlib import Path
>>> from epyr import eprload
>>> from epyr.fair import save_to_json
>>> x, y, params, fp = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC")
>>> save_to_json(Path("/tmp/demo"), params, fp)
epyr.fair.exporters.save_to_csv(output_basename, x, y, pars, original_file_path)[source]

Write EPR data and a metadata header to <basename>.csv.

The header carries microwave frequency, modulation amplitude, sample name, and the path to the source file, in commented (#) lines before the column data.

Parameters:
  • output_basename (pathlib.Path) – Base path; .csv is appended.

  • x (np.ndarray, list of np.ndarray, or None) – Abscissa from epyr.eprload(). Lists (2D) are written as long-format rows.

  • y (np.ndarray) – Signal array.

  • pars (dict) – Raw Bruker parameters.

  • original_file_path (str) – Source-file path kept as provenance in the CSV header.

Return type:

None

Examples

>>> from pathlib import Path
>>> from epyr import eprload
>>> from epyr.fair import save_to_csv
>>> x, y, params, fp = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC")
>>> save_to_csv(Path("/tmp/demo"), x, y, params, fp)
epyr.fair.exporters.save_to_csv_json(output_basename, x, y, pars, original_file_path)[source]

Save data to CSV and structured metadata to JSON.

This function is maintained for backward compatibility and calls save_to_csv() and save_to_json() separately.

Parameters:
  • output_basename (Path) – Base path for output files (without extension)

  • x (ndarray | List[ndarray] | None) – Abscissa data array(s) or None

  • y (ndarray) – Intensity data array

  • pars (Dict[str, Any]) – Raw parameters dictionary

  • original_file_path (str) – Path to original data file

Return type:

None

epyr.fair.exporters.save_to_hdf5(output_basename, x, y, pars, original_file_path)[source]

Write data and metadata to <basename>.h5.

Datasets:

/intensity : signal array (y) /abscissa : abscissa array (1D) or group /axis_0,

/axis_1 (2D)

Metadata is written as attributes on the root group: the FAIR-mapped parameters, unmapped raw parameters, and the source-file path.

Parameters:
  • output_basename (pathlib.Path) – Base path; .h5 is appended.

  • x (np.ndarray, list of np.ndarray, or None) – Abscissa from epyr.eprload().

  • y (np.ndarray) – Signal array. Complex data is stored as two real datasets, /intensity_real and /intensity_imag.

  • pars (dict) – Raw Bruker parameters.

  • original_file_path (str) – Source path kept as an HDF5 attribute.

Returns:

A UserWarning is emitted (no exception) if h5py is not installed; the file is then not written.

Return type:

None

Examples

>>> from pathlib import Path
>>> from epyr import eprload
>>> from epyr.fair import save_to_hdf5
>>> x, y, params, fp = eprload("examples/data/Rabi2D_GdCaWO4_13dB_3057G.DSC")
>>> save_to_hdf5(Path("/tmp/demo"), x, y, params, fp)
epyr.fair.exporters.save_to_jpg(output_basename, x, y, pars, original_file_path)[source]

Write a preview figure to <basename>.jpg.

For 1D data, a single plot_1d figure. For 2D data, two files: <basename>_map.jpg and <basename>_waterfall.jpg.

Parameters:
  • output_basename (pathlib.Path) – Base path; the JPG suffix is appended.

  • x (np.ndarray, list of np.ndarray, or None) – Abscissa from epyr.eprload().

  • y (np.ndarray) – Signal array (1D or 2D).

  • pars (dict) – Raw Bruker parameters, used for axis labels.

  • original_file_path (str) – Source path, used as the figure title.

Returns:

Uses the Agg non-interactive backend; safe in scripts.

Return type:

None

Examples

>>> from pathlib import Path
>>> from epyr import eprload
>>> from epyr.fair import save_to_jpg
>>> x, y, params, fp = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC")
>>> save_to_jpg(Path("/tmp/demo"), x, y, params, fp)
epyr.fair.exporters.save_fair(output_basename, x, y, pars, original_file_path, formats=None)[source]

Save EPR data in specified FAIR formats.

Parameters:
  • output_basename (Path) – Base path for output files (without extension)

  • x (ndarray | List[ndarray] | None) – Abscissa data array(s) or None

  • y (ndarray) – Intensity data array

  • pars (Dict[str, Any]) – Raw parameters dictionary

  • original_file_path (str) – Path to original data file

  • formats (List[str] | None) – List of output formats. Options: ‘csv’, ‘json’, ‘hdf5’, ‘jpg’, ‘csv_json’ - ‘csv’: Save data to CSV file only - ‘json’: Save metadata to JSON file only - ‘hdf5’: Save data and metadata to HDF5 file - ‘jpg’: Save visualization plots (1D: single plot, 2D: map + waterfall) - ‘csv_json’: Save both CSV and JSON (backward compatibility) Defaults to [‘csv’, ‘json’].

Return type:

None

Usage Examples

Basic Conversion

from epyr.fair import convert_bruker_to_fair

# Convert single file (creates CSV, JSON, HDF5)
convert_bruker_to_fair('spectrum.dsc')

# Specify output directory
convert_bruker_to_fair('spectrum.dsc', output_dir='./fair_data/')

# Batch conversion
convert_bruker_to_fair()  # Opens file dialog for selection

Output Formats

CSV Format

Simple comma-separated values for data:

# EPR Spectrum Data
# Original file: spectrum.dsc
# Converted: 2025-09-02
field_gauss,intensity_au
3200.0,0.123
3201.0,0.125
...

JSON Format

Structured metadata with human-readable parameter names:

{
  "original_file": "spectrum.dsc",
  "conversion_info": {
    "timestamp": "2025-09-02T10:30:00",
    "epyr_version": "0.1.6"
  },
  "measurement_parameters": {
    "microwave_frequency": {
      "value": 9.4e9,
      "unit": "Hz",
      "description": "Microwave frequency"
    },
    "magnetic_field_center": {
      "value": 3350.0,
      "unit": "G",
      "description": "Center magnetic field"
    }
  },
  "data": {
    "field_axis": [3200.0, 3201.0, ...],
    "intensity": [0.123, 0.125, ...]
  }
}

HDF5 Format

Self-contained hierarchical format with full metadata:

spectrum.h5
├── data/
│   ├── intensity          # EPR signal data
│   ├── field_axis        # Magnetic field axis
│   └── ...
├── metadata/
│   ├── parameters_fair/   # FAIR-mapped parameters
│   │   ├── microwave_frequency/
│   │   ├── magnetic_field_center/
│   │   └── ...
│   └── parameters_original/  # Unmapped original parameters
└── attributes             # Global metadata

Parameter Mapping

The FAIR converter maps Bruker parameter names to standardized, human-readable names:

Bruker EPR parameter mapping to FAIR format names and descriptions.

This module maps Bruker proprietary parameter names (DSC, SPL, DSL sections) to human-readable FAIR format names, units, and descriptions.

The mapping supports: - DSC Section (Data Set Codes): File format and axis information - SPL Section (Standard Parameter Layer): Basic measurement parameters - DSL Section (Device Specific Layer): Advanced instrument settings - ESP Parameters: Legacy ESP/WinEPR format parameters

Common Parameter Mappings:

  • MWFQmicrowave_frequency (Hz)

  • MWPWmicrowave_power (dB)

  • AVGSnumber_of_averages

  • RCAGreceiver_gain (dB)

  • STMPsample_temperature (K)

Complete API

FAIR data conversion package for EPyR Tools.

This package provides functionality to convert proprietary Bruker EPR data files into FAIR (Findable, Accessible, Interoperable, and Reusable) formats such as CSV, JSON, and HDF5.

The package is organized into focused modules: - parameter_mapping: Bruker parameter to FAIR format mappings - data_processing: Core data processing and metadata handling - exporters: Format-specific export functions (CSV, JSON, HDF5) - conversion: Main conversion functions and workflows

epyr.fair.convert_bruker_to_fair(input_file, output_dir=None, formats=None, include_metadata=True, scaling='')[source]

Load a Bruker file and convert it to FAIR-compliant formats.

End-to-end pipeline: epyr.eprload() -> parameter normalization -> writing one or more output files next to the input.

Parameters:
  • input_file (str or pathlib.Path) – Path to a Bruker data file (.dta, .dsc, .spc, .par).

  • output_dir (str or pathlib.Path, optional) – Where to write the converted files. Defaults to the input file’s directory. Created if missing.

  • formats (list of str, optional) –

    Subset of ['csv', 'json', 'hdf5', 'jpg']. Default ['csv', 'json'].

    • csv : data array

    • json : metadata only

    • hdf5 : data + metadata in one file

    • jpg : preview figure (1D plot or 2D map + waterfall)

  • include_metadata (bool, optional) – Whether CSV files should carry the parameter dictionary as commented header lines. Default True.

  • scaling (str, optional) – Scaling code passed through to epyr.eprload(). Default "".

Returns:

True on success, False if loading or writing failed (errors are logged, not raised).

Return type:

bool

Examples

>>> from epyr.fair import convert_bruker_to_fair
>>> ok = convert_bruker_to_fair(
...     "examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC",
...     output_dir="/tmp/epyr_out",
...     formats=["json", "hdf5"],
... )
>>> ok
True
epyr.fair.save_fair(output_basename, x, y, params, original_file_path, output_formats=None)[source]

Write already-loaded EPR data to one or more FAIR formats.

Use this when data is already in memory (e.g., after processing) and you want to write outputs without re-reading the Bruker file.

Parameters:
  • output_basename (str or pathlib.Path) – Base path (no extension); each format appends its own.

  • x (np.ndarray, list of np.ndarray, or None) – Abscissa as returned by epyr.eprload().

  • y (np.ndarray) – Signal data.

  • params (dict) – Parameter dictionary from the original file.

  • original_file_path (str) – Full path of the source file, kept as provenance in the outputs.

  • output_formats (list of str, optional) – Subset of ['csv', 'json', 'hdf5', 'jpg', 'csv_json']. Default ['csv', 'json'].

Returns:

Outputs are written to disk under output_basename.

Return type:

None

Examples

>>> import numpy as np
>>> from epyr.fair import save_fair
>>> x = np.linspace(3300, 3400, 100)
>>> y = np.random.randn(100)
>>> save_fair("/tmp/demo", x, y, {"MWFQ": 9.4e9},
...           "demo.dsc", ["json"])
epyr.fair.append_fair_metadata(data_dict, pars, original_file='')[source]

Append FAIR metadata to existing data dictionary.

Parameters:
  • data_dict (Dict[str, Any]) – Existing data dictionary to append to

  • pars (Dict[str, Any]) – Raw parameters from Bruker file

  • original_file (str) – Original file path

Returns:

Updated data dictionary with FAIR metadata

Return type:

Dict[str, Any]

epyr.fair.batch_convert_directory(input_directory, output_directory=None, file_extensions=None, scaling='', output_formats=None, recursive=False)[source]

Convert every Bruker file in a directory to FAIR formats.

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

  • output_directory (str or pathlib.Path, optional) – Where to write the converted files. Defaults to alongside each input file. Created if missing.

  • file_extensions (list of str, optional) – Which extensions count as Bruker files. Default ['.dsc', '.spc', '.par'].

  • scaling (str, optional) – Scaling code passed through to epyr.eprload().

  • output_formats (list of str, optional) – Subset of ['csv', 'json', 'hdf5', 'jpg']. Default ['csv', 'json'].

  • recursive (bool, optional) – Also descend into subdirectories. Default False.

Returns:

Progress and a final per-file summary are logged.

Return type:

None

Examples

>>> from epyr.fair import batch_convert_directory
>>> batch_convert_directory(
...     "examples/data",
...     output_directory="/tmp/epyr_batch",
...     output_formats=["json"],
... )
epyr.fair.process_parameters(pars)[source]

Split raw Bruker parameters into FAIR-mapped and unmapped buckets.

Uses epyr.fair.BRUKER_PARAM_MAP to translate Bruker keys (DSC / SPL / DSL sections) into FAIR field names with explicit units and descriptions. Unit references ('refer to XUNI') are resolved against the source dictionary.

Parameters:

pars (dict) – Raw parameters from epyr.eprload().

Returns:

  • fair_metadata (dict) – {fair_name: {'value', 'unit', 'description'}, ...}, including a conversion_info entry with timestamp and EPyR version.

  • unmapped_parameters (dict) – Pass-through of keys not present in BRUKER_PARAM_MAP.

Return type:

Tuple[Dict[str, Any], Dict[str, Any]]

Examples

>>> from epyr import eprload
>>> from epyr.fair import process_parameters
>>> x, y, params, _ = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC")
>>> fair, unmapped = process_parameters(params)
>>> "microwave_frequency" in fair
True
epyr.fair.extract_axis_info(pars)[source]

Extract axis information from parameters.

Parameters:

pars (Dict[str, Any]) – Raw parameters dictionary

Returns:

Dictionary with x, y, z axis information

Return type:

Dict[str, Dict[str, Any]]

epyr.fair.save_to_csv(output_basename, x, y, pars, original_file_path)[source]

Write EPR data and a metadata header to <basename>.csv.

The header carries microwave frequency, modulation amplitude, sample name, and the path to the source file, in commented (#) lines before the column data.

Parameters:
  • output_basename (pathlib.Path) – Base path; .csv is appended.

  • x (np.ndarray, list of np.ndarray, or None) – Abscissa from epyr.eprload(). Lists (2D) are written as long-format rows.

  • y (np.ndarray) – Signal array.

  • pars (dict) – Raw Bruker parameters.

  • original_file_path (str) – Source-file path kept as provenance in the CSV header.

Return type:

None

Examples

>>> from pathlib import Path
>>> from epyr import eprload
>>> from epyr.fair import save_to_csv
>>> x, y, params, fp = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC")
>>> save_to_csv(Path("/tmp/demo"), x, y, params, fp)
epyr.fair.save_to_json(output_basename, pars, original_file_path)[source]

Write parameter metadata to <basename>.json.

The output contains the source-file path, the FAIR-normalized metadata, and any unmapped Bruker keys preserved verbatim.

Parameters:
  • output_basename (pathlib.Path) – Base path; .json is appended.

  • pars (dict) – Raw Bruker parameters as returned by epyr.eprload().

  • original_file_path (str) – Source-file path kept as provenance.

Return type:

None

Examples

>>> from pathlib import Path
>>> from epyr import eprload
>>> from epyr.fair import save_to_json
>>> x, y, params, fp = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC")
>>> save_to_json(Path("/tmp/demo"), params, fp)
epyr.fair.save_to_csv_json(output_basename, x, y, pars, original_file_path)[source]

Save data to CSV and structured metadata to JSON.

This function is maintained for backward compatibility and calls save_to_csv() and save_to_json() separately.

Parameters:
  • output_basename (Path) – Base path for output files (without extension)

  • x (ndarray | List[ndarray] | None) – Abscissa data array(s) or None

  • y (ndarray) – Intensity data array

  • pars (Dict[str, Any]) – Raw parameters dictionary

  • original_file_path (str) – Path to original data file

Return type:

None

epyr.fair.save_to_hdf5(output_basename, x, y, pars, original_file_path)[source]

Write data and metadata to <basename>.h5.

Datasets:

/intensity : signal array (y) /abscissa : abscissa array (1D) or group /axis_0,

/axis_1 (2D)

Metadata is written as attributes on the root group: the FAIR-mapped parameters, unmapped raw parameters, and the source-file path.

Parameters:
  • output_basename (pathlib.Path) – Base path; .h5 is appended.

  • x (np.ndarray, list of np.ndarray, or None) – Abscissa from epyr.eprload().

  • y (np.ndarray) – Signal array. Complex data is stored as two real datasets, /intensity_real and /intensity_imag.

  • pars (dict) – Raw Bruker parameters.

  • original_file_path (str) – Source path kept as an HDF5 attribute.

Returns:

A UserWarning is emitted (no exception) if h5py is not installed; the file is then not written.

Return type:

None

Examples

>>> from pathlib import Path
>>> from epyr import eprload
>>> from epyr.fair import save_to_hdf5
>>> x, y, params, fp = eprload("examples/data/Rabi2D_GdCaWO4_13dB_3057G.DSC")
>>> save_to_hdf5(Path("/tmp/demo"), x, y, params, fp)
epyr.fair.save_to_jpg(output_basename, x, y, pars, original_file_path)[source]

Write a preview figure to <basename>.jpg.

For 1D data, a single plot_1d figure. For 2D data, two files: <basename>_map.jpg and <basename>_waterfall.jpg.

Parameters:
  • output_basename (pathlib.Path) – Base path; the JPG suffix is appended.

  • x (np.ndarray, list of np.ndarray, or None) – Abscissa from epyr.eprload().

  • y (np.ndarray) – Signal array (1D or 2D).

  • pars (dict) – Raw Bruker parameters, used for axis labels.

  • original_file_path (str) – Source path, used as the figure title.

Returns:

Uses the Agg non-interactive backend; safe in scripts.

Return type:

None

Examples

>>> from pathlib import Path
>>> from epyr import eprload
>>> from epyr.fair import save_to_jpg
>>> x, y, params, fp = eprload("examples/data/130406SB_CaWO4_Er_CW_5K_20.DSC")
>>> save_to_jpg(Path("/tmp/demo"), x, y, params, fp)
epyr.fair.validate_fair_dataset(data_dict, file_path=None)[source]

Comprehensive FAIR dataset validation.

Parameters:
  • data_dict (Dict[str, Any]) – Dictionary containing data and metadata

  • file_path (Path | None) – Optional file path for format validation

Returns:

Combined ValidationResult

Return type:

ValidationResult

class epyr.fair.ValidationResult[source]

Bases: object

Container for validation results.

__init__()[source]
add_error(message)[source]

Add an error message.

Parameters:

message (str)

add_warning(message)[source]

Add a warning message.

Parameters:

message (str)

add_info(message)[source]

Add an info message.

Parameters:

message (str)

get_summary()[source]

Get validation summary.

Return type:

Dict[str, Any]

epyr.fair.create_validation_report(result, output_path=None)[source]

Create a formatted validation report.

Parameters:
  • result (ValidationResult) – ValidationResult to format

  • output_path (Path | None) – Optional path to save report

Returns:

Formatted report string

Return type:

str