-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathphotometry.py
43 lines (37 loc) · 1.5 KB
/
photometry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 28 23:19:28 2017
@author: iwong
"""
import pdb
import os
import time
import numpy as np
import auxiliary as aux
def do_photometry(files,stardir,sourcedir,astrometrydir,photometrydir,
oldphotometrydir=None,rephot=False,flipxy=False,
FILTlabel='FILTER',TIMElabel='JD',OBJlabel='OBJECT'):
'''
Calibrate photometry using solved astrometry OR rematch sources given
a different aperture extraction based on a previous do_photometry run
'''
nfiles = len(files)
files = sorted(files)
filters = np.array(["g","r","i","z","B","V","R","I"])
for i,file in enumerate(sorted(files)):
phot = aux.photometry(file,stardir,sourcedir,astrometrydir,photometrydir,flipxy=flipxy,
FILTlabel=FILTlabel,TIMElabel=TIMElabel,OBJlabel=OBJlabel)
done_phot = os.path.exists(phot.photometrydir+phot.shortname+'.phot')
if rephot is True or done_phot is False:
print "Working on "+phot.shortname
if oldphotometrydir is None:
phot.transform()
phot.matching()
phot.zeropoint(filters)
phot.autotarget()
else:
phot.rematching(oldphotometrydir,filters)
delattr(phot,"sources")
if phot.found:
aux.savepickle(phot,phot.photometrydir+phot.shortname+'.phot')
print "mag = "+str(round(phot.mag,3))+", magerr = "+str(round(phot.magerr,3))