fitsmgmt.table.fits_summary
fitsmgmt.table.fits_summary(
inputs=None,
extension=None,
verify_fix=False,
fname_option='relative',
output=None,
keywords=None,
example_header=None,
sort_by='file',
sort_map=None,
fullmatch=None,
flags=0,
querystr=None,
negate_fullmatch=False,
nonunique_keys=False,
header_backend='auto',
*,
output_format=None,
**kwargs,
)Extract summary rows from FITS headers.
Parameters
inputs : glob pattern,list-like of path-like,list-like of~astropy.nddata.CCDData,~pandas.DataFrameconvertible, optional. = None-
The
~globpattern for files (e.g.,"2020*[012].fits") orlistof files (each element must be path-like or~astropy.nddata.CCDData). Although it is not a good idea, a mixedlistof~astropy.nddata.CCDDataand paths to the files is also acceptable. If a~pandas.DataFrameor convertible (especially~astropy.table.Table) is given, it finds the"file"column and use it as the input files, make a summary table from the headers of those files. IfinputsisNone, anyoutputis ignored andNoneis returned. Default:None. extension :int,str, (str,int), optional. = None-
The extension of FITS to be used. It can be given as integer (0-indexing) of the extension,
EXTNAME(singlestr), or atupleofstrandint:(EXTNAME, EXTVER). IfNone(default), the first extension with data will be used. Default:None. verify_fix :bool, optional. = False-
Whether to do
.verify('fix')to all FITS files to avoid VerifyError. It may take some time if turned on. Default isFalse. fname_option :str{\'absolute\', \'relative\', \'name\'}= 'relative'-
Whether to save full absolute/relative path or only the filename. Default:
'relative'. output :stror path-like = None-
Output summary file; an existing file is replaced. With
output_format=None,.parqand.parquetuse Parquet; all other suffixes (including.fits) use CSV. Default:None. output_format : (csv, parquet) = "csv"-
Explicit pandas output format, overriding the suffix.
Nonekeeps suffix-based selection. keywords :listorstr(\"*\") = None-
The
listof the keywords to extract (keywords should be instr). Default:None. example_header :Noneor path-like = None-
The path including the filename of the output summary text file. If specified, the header of the 0-th element of
inputswill be extracted (if glob-pattern is given, the 0-th element is random, so be careful) and saved toexample_header. UseNone(default) to skip this. Default:None. sort_by :str= 'file'-
The column name to sort the results. It can be any element of
keywordsor'file', which sorts the table by the file name. Default:'file'. sort_map : dict | None = None-
A subset of
keyparameter inpandas.DataFrame.sort_values(). If adictis given, thenkey = lambda x: x.map(sort_map)is passed into.sort_values(). Default:None. fullmatch :dict= None-
The
{column: regex}styledictto be used for selecting rows bysummarytab[column].str.fullmatch(regex, case=True). Default:None negate_fullmatch : bool = False-
Whether to negate the mask by
fullmatch, in case the user does not want to think much about regex to negate it. Default:False. flags : int = 0-
Regex module flags, e.g. re.IGNORECASE. Default: 0
querystr :str= None-
The query string used for
summarytab.query(querystr). See~pandas.DataFrame.query. Default:None. nonunique_keys :bool= False-
Whether to remove the keys that have only one unique value throughout ALL input objects. Even if they are unique, keys specified in
keywordswill not be removed. Default isFalse. header_backend : (auto, astropy, fitsio) = "auto"-
Header reader used for path-like FITS inputs when it is safe to avoid opening full HDULists.
"auto"usesfitsiowhen installed and falls back to Astropy otherwise."fitsio"raises iffitsiois not installed. Default:"auto". ****kwargs** : object = {}-
The keyword arguments to be passed to
~astropy.io.fits.open.
Returns
summarytab :~pandas.DataFrame-
Summary table with one row per input FITS file.
Notes
I want to use ccdproc.ImageFileCollection instead of this, but it is about 4 times slower than my ~astroimred.fitsmgmt.table.fits_summary, so I cannot use it yet.
Examples
>>> from pathlib import Path
>>> import astroimred as air
>>> keys = ["OBS-TIME", "FILTER", "OBJECT"]
>>> # actually it is case-insensitive
>>> # The keywords you want to extract
>>> # (from the headers of FITS files)
>>> TOPPATH = Path(".", "observation_2018-01-01")
>>> # The toppath
>>> savepath = TOPPATH / "summary_20180101.csv"
>>> # list of all the fits files in TOPPATH/rawdata:
>>> summary = air.fits_summary(
>>> TOPPATH/"rawdata/*.fits",
>>> keywords=keys,
>>> fname_option='name',
>>> sort_by="DATE-OBS",
>>> output=savepath
>>> )Select all rows with OBJECT starts with “DA”:
>>> # fullmatch = {"OBJECT": "DA.*"}
Select all rows with ``OBJECT`` starts with "Ves", ``FILTER`` is "J", and
``EXPTIME`` is 2 or 3:>>> # fullmatch = {"OBJECT": "Ves.*", "FILTER": "J"},
>>> # querystr="EXPTIME in [2, 3]"Write a Parquet table explicitly:
>>> summary = air.fits_summary(
... "rawdata/*.fits", keywords=["OBJECT", "EXPTIME"],
... output="summary.parquet", output_format="parquet"
... )