Skip to content

Commit

Permalink
Merge pull request #2 from lsst/tickets/DM-10225
Browse files Browse the repository at this point in the history
Tickets/dm 10225
  • Loading branch information
mfisherlevine committed Apr 18, 2017
2 parents cfa840d + ed42d0e commit 7ccb40d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
config.log
ups/*.cfgc
python/lsst/obs/ctio0m9/version.py
examples/.ipynb_checkpoints/*
5 changes: 5 additions & 0 deletions config/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
}
config.parse.translators = {
'visit': 'translate_visit',
'imgType': 'translate_imgType',
'wavelength': 'translate_wavelength',
}
config.parse.defaults = {
'object': "UNKNOWN",
Expand All @@ -23,7 +25,10 @@
'basename': 'text',
'filter': 'text',
'date': 'text',
'dateObs': 'text',
'expTime': 'double',
'object': 'text',
'imgType': 'text',
'wavelength': 'double',
}
config.register.visit = list(config.register.columns.keys())
37 changes: 37 additions & 0 deletions python/lsst/obs/ctio0m9/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,43 @@ def translate_visit(self, md):
"""
return mjdToVisit(md.get("DATE-OBS"))

def translate_imgType(self, md):
"""Determine the type of image being taken (bias, dark etc).
Get the image type (e.g. bias, dark, flat etc) from the metadata (md).
Translator function derived from a very small dataset from the observatory
i.e. may well need adding to when new string values are found
"""
val = md.get("IMAGETYP").rstrip().lstrip()
conversion = {'dflat': 'flat', 'DOME FLAT': 'flat',
'zero': 'bias',
'object': 'object'}
if val in conversion:
return conversion[val]
else:
self.log.warn('Unknown image type %s found in IMAGETYP key', val)
return None

def translate_wavelength(self, md):
"""Get the illumination wavelength.
Get the monochromator wavelength from the header, for flats only.
Method will need ammending if/when this value is written elsewhere
"""
val = md.get("OBJECT").rstrip().lstrip()
if self.translate_imgType(md) != 'flat':
return float('nan') # defaults to NaN if not a flat
if val[0:4].isdigit():
wavelength = float(val[0:4])
elif val[0:3].isdigit():
wavelength = float(val[0:3])
if wavelength<300 or wavelength>1150: #We don't know what might be stored here,
#so a little sanity checking is good
self.log.warn('Found a wavelength of %s, '
'which lies outside of the expected range.', wavelength)
return wavelength
return float('nan')

##############################################################################################################

class Ctio0m9CalibsParseTask(CalibsParseTask):
Expand Down

0 comments on commit 7ccb40d

Please sign in to comment.