firecrown.fctools.sacc_convert
Convert SACC files between FITS and HDF5 formats.
This tool reads a SACC file in either FITS or HDF5 format and writes it in the opposite format. Format detection is automatic based on file extension, but can be overridden with the –input-format option.
Attributes
Classes
Enum for SACC file formats. |
Functions
|
Detect file format from extension. |
|
Determine the output file path. |
|
Convert SACC files between FITS and HDF5 formats. |
Module Contents
- firecrown.fctools.sacc_convert.console
- class firecrown.fctools.sacc_convert.SaccFormat[source]
Bases:
str,enum.Enum
Enum for SACC file formats.
- FITS = 'fits'
- HDF5 = 'hdf5'
- firecrown.fctools.sacc_convert.detect_format(filepath)[source]
Detect file format from extension.
- Args:
filepath: Path to the file
- Returns:
‘fits’ or ‘hdf5’
- Raises:
ValueError: If format cannot be detected
- Parameters:
filepath (pathlib.Path)
- Return type:
str
- firecrown.fctools.sacc_convert.determine_output_path(input_path, output, target_format)[source]
Determine the output file path.
- Args:
input_path: Input file path output: User-specified output path (optional) target_format: Target format (‘fits’ or ‘hdf5’)
- Returns:
Output file path
- Parameters:
input_path (pathlib.Path)
output (pathlib.Path | None)
target_format (str)
- Return type:
pathlib.Path
- firecrown.fctools.sacc_convert.app
- firecrown.fctools.sacc_convert.main(input_file=typer.Argument(..., exists=True, dir_okay=False, readable=True, resolve_path=True, help='Input SACC file path'), output=typer.Option(None, '--output', '-o', writable=True, resolve_path=True, help='Output file path. If not specified, uses input filename with new extension.'), input_format=typer.Option(None, '--input-format', '-f', case_sensitive=False, help='Force input format (overrides automatic detection).'), overwrite=typer.Option(False, '--overwrite', help='Overwrite output file if it exists.'))[source]
Convert SACC files between FITS and HDF5 formats.
This tool reads a SACC file and converts it to the opposite format. Format detection is automatic based on file extension (.fits, .hdf5, .h5), but can be overridden with –input-format.
Examples:
# Convert FITS to HDF5 (auto-detect input, auto-generate output name) python fctools/sacc_convert.py data.fits
Convert HDF5 to FITS with specific output name:
python fctools/sacc_convert.py data.hdf5 --output converted.fits
Force input format when the extension is ambiguous:
python fctools/sacc_convert.py mydata.dat --input-format fits \ --output mydata.hdf5
Overwrite existing output file:
python fctools/sacc_convert.py data.fits --overwrite
- Parameters:
input_file (pathlib.Path)
output (pathlib.Path)
input_format (SaccFormat)
overwrite (bool)
- Return type:
None