ioutils.headerdb.HeaderDBBase
ioutils.headerdb.HeaderDBBase(db, fpath=None, wcs_keys=None)Base class for FITS header databases stored in parquet or CSV.
Provides common functionality for loading and querying observation header databases. Subclass this for mission-specific implementations.
Parameters
db : pd.DataFrame-
Pre-loaded header database DataFrame.
fpath : str or Path, default = None-
Original file path(s) for reference.
wcs_keys : list of str, default = None-
WCS header keys to use for WCS object creation. Default uses
generate_sip_wcs_keys().
Examples
Direct initialization::
import pandas as pd
db = pd.read_parquet("headers.parq")
hdb = HeaderDBBase(db, wcs_keys=generate_sip_wcs_keys(sip=3))
Using from_file classmethod::
hdb = HeaderDBBase.from_file("headers.parq", drop_colna=True)
Methods
| Name | Description |
|---|---|
| from_file | Load header database from parquet or CSV file(s). |
| wcs | Create WCS objects from header rows. |
from_file
ioutils.headerdb.HeaderDBBase.from_file(
fpath,
fmt='auto',
drop_colna=True,
drop_cols=None,
**kwargs,
)Load header database from parquet or CSV file(s).
Parameters
fpath : str, Path, or list-
Path(s) to the header database file(s).
fmt : {\"auto\",\"parquet\",\"csv\"}, default = 'auto'-
File format.
"auto"detects from file extension. Default is"auto". drop_colna : bool, default = True-
If
True, drop columns that are completely NaN. Default isTrue. drop_cols : list of str, default = None-
Columns to drop from the DataFrame.
**kwargs :-
Additional keyword arguments passed to the constructor.
Returns
: HeaderDBBase-
Loaded header database instance.
wcs
ioutils.headerdb.HeaderDBBase.wcs(
wcs_class=None,
id_col=None,
group_col=None,
file_col='filename',
filter_ids=None,
drop_wcs_keys=False,
)Create WCS objects from header rows.
Parameters
wcs_class : class, default = None-
WCS class to instantiate from header dict. Default is
astropy.wcs.WCS. For TAN-SIP projections,skyloc.ioutils.FastTanSipWCSis significantly faster (~100x for initialization, ~10x for transformations). id_col : str or None, default = None-
Column name for observation/frame ID. If
None, usesfile_colas the ID. Default isNone. group_col : str or None, default = None-
Column name for grouping (e.g., detector number). If
None, no grouping is applied. Default isNone. file_col : str, default = 'filename'-
Column name for filename. Default is
"filename". filter_ids : array-like, default = None-
Subset of IDs to process. Only used when
id_colis set. IfNone, uses all rows. drop_wcs_keys : bool, default = False-
If
True, drop WCS columns fromself.dbafter processing. Default isFalse.
Returns
: dict-
Structure depends on parameters:
id_col=None, group_col=None:{filename: wcs_obj}id_col=None, group_col=set:{filename: {group: wcs_obj}}id_col=set, group_col=None:{id: wcs_obj}id_col=set, group_col=set:{id: {group: wcs_obj}}
Notes
When id_col is None, the filename column is used as the dictionary key, providing a simpler return structure without nested "wcs"/"file" dicts.