Skip to content

Commit

Permalink
fixed comove time offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mommert committed Dec 15, 2017
1 parent eecbb3c commit 03e8005
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 deletions.
8 changes: 8 additions & 0 deletions pp_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ def combine(filenames, obsparam, comoving, targetname,
# modify individual frames if comoving == True
if comoving:
movingfilenames = []

# sort filenames by MIDTIMJD
mjds = []
for filename in filenames:
hdulist = fits.open(filename)
mjds.append(float(hdulist[0].header['MIDTIMJD']))
filenames = [filenames[i] for i in numpy.argsort(mjds)]

for filename in filenames:
movingfilename = filename[:filename.find('.fits')]+'_moving.fits'
print('shifting %s -> %s' % (filename, movingfilename))
Expand Down
27 changes: 14 additions & 13 deletions pp_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,20 @@ def prepare(filenames, obsparam, header_update, keep_wcs=False,
header['SECPIXY'] = (obsparam['secpix'][1]*binning[1],
'PP: y pixscale after binning')

# create observation midtime jd
if obsparam['date_keyword'].find('|') == -1:
header['MIDTIMJD'] = \
(toolbox.dateobs_to_jd(header[obsparam['date_keyword']]) +
float(header[obsparam['exptime']])/2./86400.,
'PP: obs midtime')
else:
datetime = header[obsparam['date_keyword'].split('|')[0]] + 'T' + \
header[obsparam['date_keyword'].split('|')[1]]
datetime = datetime.replace('/', '-')
header['MIDTIMJD'] = (toolbox.dateobs_to_jd(datetime) +
float(header[obsparam['exptime']])/2./86400.,
'PP: obs midtime')
# create observation midtime jd
if not keep_wcs or 'MIDTIMJD' not in header:
if obsparam['date_keyword'].find('|') == -1:
header['MIDTIMJD'] = \
(toolbox.dateobs_to_jd(header[obsparam['date_keyword']]) +
float(header[obsparam['exptime']])/2./86400.,
'PP: obs midtime')
else:
datetime = (header[obsparam['date_keyword'].split('|')[0]] +
'T' + header[obsparam['date_keyword'].split('|')[1]])
datetime = datetime.replace('/', '-')
header['MIDTIMJD'] = (toolbox.dateobs_to_jd(datetime) +
float(header[obsparam['exptime']])/2./86400.,
'PP: obs midtime')

# other keywords
header['TELINSTR'] = (obsparam['telescope_instrument'],
Expand Down
16 changes: 8 additions & 8 deletions pp_stackedphotometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,14 @@

os.chdir(rootdir)

logging.info('move comove/photometry*.dat to root directory')
targets = numpy.array(list(distillate['targetnames'].keys()))
target = targets[targets != 'control_star'][0]
shutil.copyfile(('comove/photometry_%s.dat' %
target.translate(_pp_conf.target2filename)),
('photometry_%s.dat' %
target.translate(_pp_conf.target2filename)))
logging.info('move skycoadd.fits into skycoadd/ directory')
# logging.info('move comove/photometry*.dat to root directory')
# targets = numpy.array(list(distillate['targetnames'].keys()))
# target = targets[targets != 'control_star'][0]
# shutil.copyfile(('comove/photometry_%s.dat' %
# target.translate(_pp_conf.target2filename)),
# ('photometry_%s.dat' %
# target.translate(_pp_conf.target2filename)))
# logging.info('move skycoadd.fits into skycoadd/ directory')

print('\nDone!\n')
logging.info('----- successfully done with this process ----')
Expand Down

0 comments on commit 03e8005

Please sign in to comment.