Skip to content

Instantly share code, notes, and snippets.

@dokeeffe
Created February 11, 2018 14:57
Show Gist options
  • Save dokeeffe/4845198796de9d6d07278106fe44c237 to your computer and use it in GitHub Desktop.
Save dokeeffe/4845198796de9d6d07278106fe44c237 to your computer and use it in GitHub Desktop.
from astropy.io import fits
import glob
import numpy as np
from astropy import units as u
from astropy.time import Time
from astropy.coordinates import SkyCoord, EarthLocation, AltAz
data_files = glob.glob('/home/dokeeffe/Pictures/xo-2b/*.fits')
for file in data_files:
data, header = fits.getdata(file, header=True)
ra_dec = '{} {}'.format(header['OBJCTRA'],header['OBJCTDEC'])
coord = SkyCoord(ra_dec, unit=(u.hourangle, u.deg))
bobs_location = EarthLocation(lat=52.253494*u.deg, lon=-8.360614*u.deg, height=75*u.m)
time = Time(header['DATE-OBS'])
altaz = coord.transform_to(AltAz(obstime=time,location=bobs_location))
print(altaz.secz)
header['AIRMASS'] = float(altaz.secz)
header['GAIN'] = 0.4
fits.writeto(file, data, header, clobber=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment