Skip to content

Commit

Permalink
fix column names in zeropoint file, and update dump script to use ast…
Browse files Browse the repository at this point in the history
…ropy tables, avoiding python bytestring fuckery
  • Loading branch information
gnarayan committed Sep 5, 2017
1 parent 7551514 commit 1a724a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion data/photometry/20170731/Combined/ZP_all
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# l ZP_10_2017 ZP_10 eZP_10 ZP for infinite aperture (EE corr applied)
# l ZP_10_2017 ZP_10 eZP_10 ZP_for_infinite_aperture EE_corr_applied
0.275 22.574 22.585 0.005 22.723 0.006
0.336 23.42 23.426 0.005 23.543 0.006
0.475 25.696 25.693 0.006 25.795 0.005
Expand Down
27 changes: 12 additions & 15 deletions data/photometry/20170731/Combined/dump_apparent_mags.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,38 @@

import sys
import numpy as np
import astropy.table as at
from matplotlib.mlab import rec2txt
from uncertainties import ufloat

def main():
a = np.recfromtxt('WD_cycle22_cycle20new.phot', names=True)
a = at.Table.read('WD_cycle22_cycle20new.phot', format='ascii.commented_header')
pb = 'F275W,F336W,F475W,F625W,F775W,F160W'
pb = pb.split(',')

b = np.recfromtxt('ZP_all', names='l,ZP_10_2017,ZP_10,eZP_10,ZP_inf,eZP_inf')
b.l *= 1000
zppb = ['F{:.3}W'.format(str(x)) for x in b.l]
b = at.Table.read('ZP_all', format='ascii.commented_header')
b['l'] *= 1000
zppb = ['F{:.3}W'.format(str(x)) for x in b['l']]

zp = {x:y for x, y in zip(zppb, b.ZP_10)}
zp.update({'d'+x:y for x, y in zip(zppb, b.eZP_10)})
zp = {x:y for x, y in zip(zppb, b['ZP_10'])}
zp.update({'d'+x:y for x, y in zip(zppb, b['eZP_10'])})

map = None
with open('name_map.dat','r') as f:
lines = f.readlines()
map = {line.strip().split()[0]:line.strip().split()[1] for line in lines}

d = a[1:]
d = a[0:]
out = []
for i, x in enumerate(d):
this_out = []
objid = str(x.ID)
objid = str(x['ID'])
objid = objid.replace('-','',1).split('.')[0].split('+')[0].split('-')[0].replace('SDSS','sdss').lower()
objid = map.get(objid, objid)
this_out.append(objid)
for p in pb:
inst_mag = x[p]
if p == 'F160W':
dinst_mag = x['d'+p]
else:
dinst_mag = x['d'+p+'1']
dinst_mag = x['d'+p+'1']

z = zp[p]
dz = zp['d'+p]
Expand All @@ -55,9 +53,8 @@ def main():
for p in pb:
names.append(p)
names.append('d'+p)
out = np.rec.fromrecords(out, names=names)
with open('WDphot_C22_AC_AS_combined.dat','w') as f:
f.write(rec2txt(out, precision=5)+'\n')
out = at.Table(rows=out, names=names)
out.write('WDphot_C22_AC_AS_combined.dat',format='ascii.commented_header', overwrite=True)



Expand Down

0 comments on commit 1a724a7

Please sign in to comment.