Skip to content

Commit

Permalink
improves the Gemini adclass layer to better handle tags and descripto…
Browse files Browse the repository at this point in the history
…rs for visitor instruments.
  • Loading branch information
KathleenLabrie committed May 20, 2019
1 parent ab26b75 commit 0d5dfd1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
39 changes: 28 additions & 11 deletions gemini_instruments/gemini/adclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
detector_roi_setting = 'DROISET',
detector_rois_requested = 'DROIREQ',
detector_section = 'DETSEC',
detector_x_bin = 'XCCDBIN',
detector_y_bin = 'YCCDBIN',
detector_x_bin = 'XBIN',
detector_y_bin = 'YBIN',
disperser = 'DISPERSR',
dispersion = 'WDELTA',
dispersion_axis = 'DISPAXIS',
elevation = 'ELEVATIO',
exposure_time = 'EXPTIME',
filter_name = 'FILTNAME',
filter_name = 'FILTER1',
focal_plane_mask = 'FPMASK',
gain = 'GAIN',
gain_setting = 'GAINSET',
Expand All @@ -81,8 +81,9 @@
nominal_photometric_zeropoint = 'NOMPHOTZ',
non_linear_level = 'NONLINEA',
observation_epoch = 'OBSEPOCH',
observation_mode = 'OBSMODE',
oiwfs = 'OIWFS_ST',
overscan_section = 'OVERSSEC',
overscan_section = 'OVERSEC',
pixel_scale = 'PIXSCALE',
prism = 'PRISM',
pupil_mask = 'PUPILMSK',
Expand Down Expand Up @@ -169,6 +170,18 @@ def _type_site(self):
elif site == 'GEMINI-SOUTH':
return TagSet(['SOUTH'])

@astro_data_tag
def _type_mode(self):
mode = self.phu.get(self._keyword_for('observation_mode'), '').upper()
print(type(mode))

if mode:
tags = [mode]
if mode != 'IMAGE':
# assume SPECT
tags.append('SPECT')
return TagSet(tags)

@astro_data_tag
def _type_nodandchop(self):
if self.phu.get('DATATYPE') == "marked-nodandchop":
Expand Down Expand Up @@ -228,12 +241,10 @@ def _status_processed_cals(self):

@astro_data_tag
def _status_processed_science(self):
for pattern in ('GMOSAIC', 'PREPAR'):
if not any((pattern in kw) for kw in self.phu):
return
kwords = {'GMOSAIC', 'PROCSCI'}

if self.phu['OBSTYPE'] == 'OBJECT':
return TagSet(['PROCESSED_SCIENCE'])
if self.phu['OBSTYPE'] == 'OBJECT' and set(self.phu.keys()) & kwords:
return TagSet(['PROCESSED_SCIENCE', 'PROCESSED'], blocks=['RAW'])

def _parse_section(self, keyword, pretty):
try:
Expand Down Expand Up @@ -538,7 +549,10 @@ def dec(self):
float
declination in degrees
"""
return self.wcs_dec()
dec = self.wcs_dec()
if dec is None:
dec = self.phu.get('DEC', None)
return dec

@astro_data_descriptor
def decker(self, stripID=False, pretty=False):
Expand Down Expand Up @@ -1303,7 +1317,10 @@ def ra(self):
float
right ascension in degrees
"""
return self.wcs_ra()
ra = self.wcs_ra()
if ra is None:
ra = self.phu.get('RA', None)
return ra

@astro_data_descriptor
def raw_bg(self):
Expand Down
4 changes: 3 additions & 1 deletion gemini_instruments/trecs/adclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ def _matches_data(source):
def _tag_instrument(self):
return TagSet(['TRECS'])

# override gemini-level "type_mode" because OBSMODE is used for something
# else in TReCS.
@astro_data_tag
def _tag_image_spect(self):
def _type_mode(self):
if 'MIRROR' in self.phu.get('GRATING', '').upper():
return TagSet(['IMAGE'])
else:
Expand Down

0 comments on commit 0d5dfd1

Please sign in to comment.