Skip to content

Commit

Permalink
Fixes for images times and a workaroudn for panoptes/POCS#586
Browse files Browse the repository at this point in the history
  • Loading branch information
wtgee committed Sep 9, 2018
1 parent 89953f3 commit c6243a1
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions piaa/utils/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
import shutil
import subprocess

Expand Down Expand Up @@ -98,6 +99,7 @@ def get_catalog_match(point_sources, wcs, table='full_catalog', **kwargs):
wcs.calc_footprint(),
cursor_only=False,
table=table,
**kwargs
)

# Get coords for catalog stars
Expand Down Expand Up @@ -263,7 +265,9 @@ def create_stamp_slices(
errors = dict()

num_frames = len(fits_files)
sequence = fits.getval(fits_files[0], 'SEQID')
unit_id, cam_id, seq_time = fits.getval(fits_files[0], 'SEQID').split('_')
unit_id = re.match(r'.*(PAN\d\d\d).*', unit_id)[1]
sequence = '_'.join([unit_id, cam_id, seq_time])

logging.info("{} files found for {}".format(num_frames, sequence))

Expand All @@ -285,8 +289,22 @@ def create_stamp_slices(

stamps = h5py.File(stamps_fn, 'a')

image_times = np.array(
[Time(date_parse(fits.getval(fn, 'DATE-OBS'))).mjd for fn in fits_files])
# Currently a bug with DATE-OBS so use time from filename.
try:
image_times = np.array([Time(
date_parse(os.path.splitext(fn.split('/')[-1])[0]) # .split('_')[4]
).mjd
for fn in fits_files if 'pointing' not in fn])
except ValueError:
image_times = np.array([Time(
date_parse(os.path.splitext(fn.split('/')[-1])[0].split('_')[4])
).mjd
for fn in fits_files if 'pointing' not in fn])


#image_times = np.array(
# [Time(date_parse(fits.getval(fn, 'DATE-OBS'))).mjd for fn in fits_files])

airmass = np.array([fits.getval(fn, 'AIRMASS') for fn in fits_files])

stamps.attrs['image_times'] = image_times
Expand Down

0 comments on commit c6243a1

Please sign in to comment.