pleiades.sammy.io.data_manager module

SAMMY data format management utilities.

This module provides functions for converting between different data formats required by SAMMY, including the twenty-column fixed-width format used for experimental transmission data.

pleiades.sammy.io.data_manager.convert_csv_to_sammy_twenty(csv_file: str | Path, twenty_file: str | Path) None[source]

Convert transmission spectra from CSV to SAMMY twenty format.

This function supports tab-, comma-, and space-separated files, with either two columns (energy, transmission) or three columns (energy, transmission, uncertainty). If only two columns are present, the uncertainty column will be filled with 0.0.

Args:

csv_file: Path to input CSV file with columns: energy_eV, transmission, [uncertainty] twenty_file: Path to output SAMMY twenty format file

File Formats:
Input CSV (tab, comma, or space separated):

“energy_eV,transmission,uncertainty

6.673,0.932,0.272 “

or “energy_eV transmission uncertainty

6.673 0.932 0.272 “

or “# Energy(eV) Transmission Uncertainty

6.673240e+00 1.003460e+00 7.242967e-03 “

or “energy_eV,transmission

6.673,0.932 “

Output twenty:

“ 6.6732397079 0.9323834777 0.2727669477

Example:
>>> convert_csv_to_sammy_twenty(
...     "transmission.txt",
...     "transmission.twenty"
... )
>>> convert_csv_to_sammy_twenty(
...     "ineuit.csv",
...     "ineuit_transmission.twenty"
... )
pleiades.sammy.io.data_manager.validate_sammy_twenty_format(twenty_file: str | Path) bool[source]

Validate that a file follows SAMMY twenty format requirements.

Checks that each line has exactly 60 characters (3 columns × 20 chars each) and contains valid floating point data.

Parameters:

twenty_file – Path to file to validate

Returns:

True if file is valid twenty format

Return type:

bool

Example

>>> is_valid = validate_sammy_twenty_format("data.twenty")
>>> print(f"File is valid: {is_valid}")