{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Modify an existing FITS header" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "\n", "from astropy.io.fits import getheader\n", "\n", "sys.path.append('..')\n", "from astrodb_utils.fits import check_header\n", "\n", "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get the header from 2MASS+J21442847+1446077.fits and look at it." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "SIMPLE = T / conforms to FITS standard \n", "BITPIX = 8 / array data type \n", "NAXIS = 0 / number of array dimensions \n", "EXTEND = T \n", "EXTNAME = 'PRIMARY ' / name of this extension \n", "VOCLASS = 'Spectrum-1.0' / VO Data Model \n", "VOPUB = 'SIMPLE Archive' / VO Publisher ID URI \n", "TITLE = 'IRS Spectra of Brown Dwarfs from Suarez & Metchev 2022' / data set ti\n", "OBJECT = '2MASS J21442847+1446077' / name of observed object \n", "RA = 326.1186316666667 / [deg] Pointing position \n", "DEC = 14.76883277777778 / [deg] Pointing position \n", "TMID = 2454669.5 / [d] MJD mid expsoure \n", "TSTART = 2454680.5 / [d] MJD start time \n", "TSTOP = 2454658.5 / [d] MJD stop time \n", "TELAPSE = 42240 / [s] Total elapsed time \n", "SPEC_VAL= 'Mid-Infared' / [angstrom] Characteristic spec coord \n", "SPEC_BW = 8.951589999999999 / [[um]] Width of spectrum \n", "TDMIN1 = 5.21725 / [[um]] starting wavelength \n", "TDMAX1 = 14.16884 / [[um]] ending wavelength \n", "AUTHOR = 'Suarez, Genaro; Metchev, Stanimir' / author of the data \n", "VOREF = '2022MNRAS.513.5701S' / bibcode \n", "DATE = '2022-08-25' / date of file creation \n", "INSTRUME= 'IRS ' / name of instrument \n", "DATE-OBS= '2008-08-02' / date of the observation \n", "REFERENC= ' 10.1093/mnras/stac1205' / bibliographic reference \n", "TELESCOP= 'Spitzer ' / name of telescope \n", "HISTORY 'Original file: 2144%2B1446_IRS_spectrum.dat', This file generated by SI\n", "HISTORY MPLE-db/scripts/ingests/rewrite_spectra.py " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "header_2144 = getheader('../../../astrodb_utils/tests/data/2MASS+J21442847+1446077.fits')\n", "header_2144" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## See if any keywords are missing" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The following keywords are not set in the header:\n", "RA_TARG : [deg] target position\n", "DEC_TARG : [deg] target position\n", "OBSERVAT : \n", "CONTRIB1 : Contributor who generated this file\n", "SPECBAND : SED.bandpass\n", "APERTURE : [arcsec] slit width\n", "coordinates converted to sexagesimal: 21h44m28.4716s +14d46m07.798s\n", "SIMBAD results for object name 2MASS J21442847+1446077: main_id ra ... coo_bibcode matched_id \n", " deg ... \n", "----------- ------------------ ... ------------------- -----------------------\n", "V* HN Peg B 326.11863200000005 ... 2003yCat.2246....0C 2MASS J21442847+1446077\n", "coordinates converted to sexagesimal: 21h44m28.4716s +14d46m07.798s\n", "Object name 2MASS J21442847+1446077 found in SIMBAD\n", " main_id ra ... coo_bibcode matched_id \n", " deg ... \n", "----------- ------------------ ... ------------------- -----------------------\n", "V* HN Peg B 326.11863200000005 ... 2003yCat.2246....0C 2MASS J21442847+1446077\n", "make sure SIMBAD coords match header coords\n", "DATE-OBS set to : 2008-08-02.\n", "Date of observation: Aug 02, 2008\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "check_header(header_2144)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## RA_Targ and Dec_targ are required so let's add them using the RA/Dec in the header" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "header_2144.set('RA_TARG', header_2144['RA'] )\n", "header_2144.set('DEC_TARG', header_2144['DEC'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Run `check_header` on the header to double check everything is as you expect it to be.\n" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "The following keywords are not set in the header:\n", "OBSERVAT : \n", "CONTRIB1 : Contributor who generated this file\n", "SPECBAND : SED.bandpass\n", "APERTURE : [arcsec] slit width\n", "coordinates converted to sexagesimal: 21h44m28.4716s +14d46m07.798s\n", "SIMBAD results for object name 2MASS J21442847+1446077: main_id ra ... coo_bibcode matched_id \n", " deg ... \n", "----------- ------------------ ... ------------------- -----------------------\n", "V* HN Peg B 326.11863200000005 ... 2003yCat.2246....0C 2MASS J21442847+1446077\n", "coordinates converted to sexagesimal: 21h44m28.4716s +14d46m07.798s\n", "Object name 2MASS J21442847+1446077 found in SIMBAD\n", " main_id ra ... coo_bibcode matched_id \n", " deg ... \n", "----------- ------------------ ... ------------------- -----------------------\n", "V* HN Peg B 326.11863200000005 ... 2003yCat.2246....0C 2MASS J21442847+1446077\n", "make sure SIMBAD coords match header coords\n", "DATE-OBS set to : 2008-08-02.\n", "Date of observation: Aug 02, 2008\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "check_header(header_2144)" ] } ], "metadata": { "kernelspec": { "display_name": "template-dev", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 2 }