API Reference¶
This page provides an auto-generated API reference for the clfits package.
Main CLI for clfits.
- clfits.main.delete(fits_file: ~pathlib.Path = <typer.models.ArgumentInfo object>, keyword: str = <typer.models.ArgumentInfo object>, hdu: str = <typer.models.OptionInfo object>) None[source]¶
Delete a keyword from the header.
- clfits.main.export(fits_file: ~pathlib.Path = <typer.models.ArgumentInfo object>, format: ~clfits.export.Format | None = <typer.models.OptionInfo object>, output_file: ~pathlib.Path | None = <typer.models.OptionInfo object>, hdu: str = <typer.models.OptionInfo object>) None[source]¶
Export the FITS header to a specified format (JSON, YAML, or CSV).
- clfits.main.get(fits_file: ~pathlib.Path = <typer.models.ArgumentInfo object>, keyword: str = <typer.models.ArgumentInfo object>, hdu: str = <typer.models.OptionInfo object>) None[source]¶
Get the value of a specific header keyword.
- clfits.main.main(version: bool = <typer.models.OptionInfo object>) None[source]¶
Manage FITS headers from the command line.
- clfits.main.search(fits_file: ~pathlib.Path = <typer.models.ArgumentInfo object>, key_pattern: str | None = <typer.models.OptionInfo object>, value_pattern: str | None = <typer.models.OptionInfo object>, case_sensitive: bool = <typer.models.OptionInfo object>, hdu: str = <typer.models.OptionInfo object>) None[source]¶
Search for keywords in a FITS header by pattern.
- clfits.main.set(fits_file: ~pathlib.Path = <typer.models.ArgumentInfo object>, keyword: str = <typer.models.ArgumentInfo object>, value: str = <typer.models.ArgumentInfo object>, comment: str | None = <typer.models.OptionInfo object>, hdu: str = <typer.models.OptionInfo object>) None[source]¶
Set a keyword’s value, with an optional comment.
- clfits.main.view(fits_file: ~pathlib.Path = <typer.models.ArgumentInfo object>, hdu: str = <typer.models.OptionInfo object>) None[source]¶
View the header of a FITS file.
Functions for reading and writing FITS headers.
- clfits.io.read_header(fits_file: Path, hdu: int | str = 0) Header[source]¶
Read a header from a specific HDU in a FITS file.
- Parameters:
- fits_filePath
The path to the FITS file.
- hduint or str, optional
The HDU to read from, specified by its 0-based index or name, by default 0 (the primary HDU).
- Returns:
- Header
The header object from the specified HDU.
- Raises:
- FileNotFoundError
If the FITS file does not exist.
- IndexError
If the HDU index is out of range.
- KeyError
If the HDU name is not found.
- OSError
If the file is not a valid FITS file.
- clfits.io.write_header(fits_file: Path, header: Header, hdu: int | str = 0) None[source]¶
Write a header to a specific HDU of a FITS file.
This function opens the FITS file in update mode and replaces the header of the specified HDU with the new one.
- Parameters:
- fits_filePath
The path to the FITS file.
- headerHeader
The header object to write to the file.
- hduint or str, optional
The HDU to write to, specified by its 0-based index or name, by default 0 (the primary HDU).
- Raises:
- FileNotFoundError
If the FITS file does not exist.
- IndexError
If the HDU index is out of range.
- KeyError
If the HDU name is not found.
- OSError
If the file is not a valid FITS file or cannot be written to.