firecrown.fctools.sacc_convert ============================== .. py:module:: firecrown.fctools.sacc_convert .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: firecrown.fctools.sacc_convert.console firecrown.fctools.sacc_convert.app Classes ------- .. autoapisummary:: firecrown.fctools.sacc_convert.SaccFormat Functions --------- .. autoapisummary:: firecrown.fctools.sacc_convert.detect_format firecrown.fctools.sacc_convert.determine_output_path firecrown.fctools.sacc_convert.main Module Contents --------------- .. py:data:: console .. py:class:: SaccFormat Bases: :py:obj:`str`, :py:obj:`enum.Enum` .. autoapi-inheritance-diagram:: firecrown.fctools.sacc_convert.SaccFormat :parts: 1 Enum for SACC file formats. .. py:attribute:: FITS :value: 'fits' .. py:attribute:: HDF5 :value: 'hdf5' .. py:function:: detect_format(filepath) Detect file format from extension. Args: filepath: Path to the file Returns: 'fits' or 'hdf5' Raises: ValueError: If format cannot be detected .. py:function:: determine_output_path(input_path, output, target_format) 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 .. py:data:: app .. py:function:: 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.')) 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