This notebook is available at astrodbtoolkit/astrodb_utils

Modify an existing FITS header#

[1]:
import sys

from astropy.io.fits import getheader

sys.path.append('..')
from astrodb_utils.fits import check_header

%load_ext autoreload
%autoreload 2

Get the header from 2MASS+J21442847+1446077.fits and look at it.#

[4]:
header_2144 = getheader('../../../astrodb_utils/tests/data/2MASS+J21442847+1446077.fits')
header_2144
[4]:
SIMPLE  =                    T / conforms to FITS standard
BITPIX  =                    8 / array data type
NAXIS   =                    0 / number of array dimensions
EXTEND  =                    T
EXTNAME = 'PRIMARY '           / name of this extension
VOCLASS = 'Spectrum-1.0'       / VO Data Model
VOPUB   = 'SIMPLE Archive'     / VO Publisher ID URI
TITLE   = 'IRS Spectra of Brown Dwarfs from Suarez & Metchev 2022' / data set ti
OBJECT  = '2MASS J21442847+1446077' / name of observed object
RA      =    326.1186316666667 / [deg] Pointing position
DEC     =    14.76883277777778 / [deg] Pointing position
TMID    =            2454669.5 / [d] MJD mid expsoure
TSTART  =            2454680.5 / [d] MJD start time
TSTOP   =            2454658.5 / [d] MJD stop time
TELAPSE =                42240 / [s] Total elapsed time
SPEC_VAL= 'Mid-Infared'        / [angstrom] Characteristic spec coord
SPEC_BW =    8.951589999999999 / [[um]] Width of spectrum
TDMIN1  =              5.21725 / [[um]] starting wavelength
TDMAX1  =             14.16884 / [[um]] ending wavelength
AUTHOR  = 'Suarez, Genaro; Metchev, Stanimir' / author of the data
VOREF   = '2022MNRAS.513.5701S' / bibcode
DATE    = '2022-08-25'         / date of file creation
INSTRUME= 'IRS     '           / name of instrument
DATE-OBS= '2008-08-02'         / date of the observation
REFERENC= ' 10.1093/mnras/stac1205' / bibliographic reference
TELESCOP= 'Spitzer '           / name of telescope
HISTORY 'Original file: 2144%2B1446_IRS_spectrum.dat', This file generated by SI
HISTORY MPLE-db/scripts/ingests/rewrite_spectra.py

See if any keywords are missing#

[6]:
check_header(header_2144)
The following keywords are not set in the header:
RA_TARG : [deg] target position
DEC_TARG : [deg] target position
OBSERVAT :
CONTRIB1 : Contributor who generated this file
SPECBAND : SED.bandpass
APERTURE : [arcsec] slit width
coordinates converted to sexagesimal: 21h44m28.4716s +14d46m07.798s
SIMBAD results for object name 2MASS J21442847+1446077:   main_id           ra         ...     coo_bibcode            matched_id
                   deg         ...
----------- ------------------ ... ------------------- -----------------------
V* HN Peg B 326.11863200000005 ... 2003yCat.2246....0C 2MASS J21442847+1446077
coordinates converted to sexagesimal: 21h44m28.4716s +14d46m07.798s
Object name 2MASS J21442847+1446077 found in SIMBAD
  main_id           ra         ...     coo_bibcode            matched_id
                   deg         ...
----------- ------------------ ... ------------------- -----------------------
V* HN Peg B 326.11863200000005 ... 2003yCat.2246....0C 2MASS J21442847+1446077
make sure SIMBAD coords match header coords
DATE-OBS set to : 2008-08-02.
Date of observation: Aug 02, 2008
[6]:
True

RA_Targ and Dec_targ are required so let’s add them using the RA/Dec in the header#

[7]:
header_2144.set('RA_TARG', header_2144['RA'] )
header_2144.set('DEC_TARG', header_2144['DEC'])

Run check_header on the header to double check everything is as you expect it to be.#

[8]:
check_header(header_2144)
The following keywords are not set in the header:
OBSERVAT :
CONTRIB1 : Contributor who generated this file
SPECBAND : SED.bandpass
APERTURE : [arcsec] slit width
coordinates converted to sexagesimal: 21h44m28.4716s +14d46m07.798s
SIMBAD results for object name 2MASS J21442847+1446077:   main_id           ra         ...     coo_bibcode            matched_id
                   deg         ...
----------- ------------------ ... ------------------- -----------------------
V* HN Peg B 326.11863200000005 ... 2003yCat.2246....0C 2MASS J21442847+1446077
coordinates converted to sexagesimal: 21h44m28.4716s +14d46m07.798s
Object name 2MASS J21442847+1446077 found in SIMBAD
  main_id           ra         ...     coo_bibcode            matched_id
                   deg         ...
----------- ------------------ ... ------------------- -----------------------
V* HN Peg B 326.11863200000005 ... 2003yCat.2246....0C 2MASS J21442847+1446077
make sure SIMBAD coords match header coords
DATE-OBS set to : 2008-08-02.
Date of observation: Aug 02, 2008
[8]:
True