Skip to content

Commit

Permalink
Add support for ObservationInfo.observation_reason
Browse files Browse the repository at this point in the history
This allows TESTTYPE handling to be unified.
  • Loading branch information
timj committed Sep 4, 2020
1 parent 119be5e commit 0b3b552
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
config.parse.retarget(LsstCamParseTask)

config.parse.translation = {
'testType': 'TESTTYPE',
}
config.parse.translators = {
'testType': 'translate_testType',
'expTime': 'translate_expTime',
'object': 'translate_object',
'imageType': 'translate_imageType',
Expand Down
3 changes: 1 addition & 2 deletions config/latiss/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

config.parse.retarget(LatissParseTask)

del config.parse.translation['testType']

del config.parse.translators['testType']
del config.parse.translators['run']
del config.parse.translators['raftName']
del config.parse.translators['lsstSerial']
Expand Down
4 changes: 4 additions & 0 deletions python/lsst/obs/lsst/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,10 @@ def translate_visit(self, md):
def translate_obsid(self, md):
return self.observationInfo.observation_id

def translate_testType(self, md):
# Gen2 prefers upper case
return self.observationInfo.observation_reason.upper()

def translate_expGroup(self, md):
return self.observationInfo.exposure_group

Expand Down
10 changes: 10 additions & 0 deletions python/lsst/obs/lsst/translators/lsst.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,16 @@ def to_observation_type(self):
obstype = "science"
return obstype

@cache_translation
def to_observation_reason(self):
# Docstring will be inherited. Property defined in properties.py
if self.is_key_ok("TESTTYPE"):
reason = self._header["TESTTYPE"]
self._used_these_cards("TESTTYPE")
return reason.lower()
# no specific header present so use the default translation
return super().to_observation_reason()

@cache_translation
def to_dark_time(self):
"""Calculate the dark time.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_parsetask.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ def test_parsetask_ucd_translator(self):
expTime=0.5,
object='UNKNOWN',
imageType='FLAT',
testType='flat',
testType='FLAT',
lsstSerial='E2V-CCD250-112-04',
date='2018-12-05T23:31:48.288',
dateObs='2018-12-05T23:31:48.288',
Expand All @@ -372,7 +372,7 @@ def test_parsetask_ucd_translator(self):
expTime=0.5,
object='UNKNOWN',
imageType='FLAT',
testType='flat',
testType='FLAT',
lsstSerial='ITL-3800C-002',
date='2018-05-30T15:03:55.872',
dateObs='2018-05-30T15:03:55.872',
Expand Down
29 changes: 29 additions & 0 deletions tests/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_lsstCam_translator(self):
object="UNKNOWN",
observation_id="MC_C_20190319_000001",
observation_type="bias",
observation_reason="bias",
physical_filter="NONE",
pressure=None,
relative_humidity=None,
Expand All @@ -77,6 +78,7 @@ def test_lsstCam_translator(self):
object="UNKNOWN",
observation_id="MC_C_20190319_000001",
observation_type="bias",
observation_reason="bias",
physical_filter="NONE",
pressure=None,
relative_humidity=None,
Expand All @@ -99,6 +101,7 @@ def test_lsstCam_translator(self):
object="UNKNOWN",
observation_id="MC_C_20190322_000002",
observation_type="flat",
observation_reason="flat",
physical_filter="SDSSi~ND_OD0.5",
pressure=None,
relative_humidity=None,
Expand All @@ -121,6 +124,7 @@ def test_lsstCam_translator(self):
object="UNKNOWN",
observation_id="MC_C_20190406_000643",
observation_type="flat",
observation_reason="lambda",
physical_filter="950nm~empty",
pressure=None,
relative_humidity=None,
Expand Down Expand Up @@ -149,6 +153,7 @@ def test_comCam_translator(self):
object="UNKNOWN",
observation_id="CC_C_20190530_000001",
observation_type="bias",
observation_reason="bias",
physical_filter="NONE",
pressure=None,
relative_humidity=None,
Expand All @@ -171,6 +176,7 @@ def test_comCam_translator(self):
object="UNKNOWN",
observation_id="CC_C_20190526_000223",
observation_type="bias",
observation_reason="dark",
physical_filter="NONE",
pressure=None,
relative_humidity=None,
Expand Down Expand Up @@ -199,6 +205,7 @@ def test_phosim_translator(self):
object="UNKNOWN",
observation_id="204595",
observation_type="science",
observation_reason="phosim",
physical_filter="i",
pressure=520.0*cds.mmHg,
relative_humidity=40.0,
Expand Down Expand Up @@ -231,6 +238,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_C_20180920_000065",
observation_type="unknown",
observation_reason="unknown",
physical_filter="????~????",
pressure=None,
relative_humidity=None,
Expand All @@ -254,6 +262,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_O_20190306_000014",
observation_type="unknown",
observation_reason="unknown",
physical_filter="????~????",
pressure=None,
relative_humidity=None,
Expand All @@ -277,6 +286,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_O_20190329_000022",
observation_type="bias",
observation_reason="unknown",
physical_filter="NONE~NONE",
pressure=None,
relative_humidity=None,
Expand All @@ -300,6 +310,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_X_20200329_000022",
observation_type="bias",
observation_reason="unknown",
physical_filter="NONE~NONE",
pressure=None,
relative_humidity=None,
Expand All @@ -323,6 +334,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_O_20190915_000037",
observation_type="bias",
observation_reason="unknown",
physical_filter="NONE~NONE",
pressure=None,
relative_humidity=None,
Expand All @@ -346,6 +358,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_O_20191031_000004",
observation_type="engtest",
observation_reason="unknown",
physical_filter="????~????",
pressure=None,
relative_humidity=None,
Expand All @@ -369,6 +382,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_O_20191104_000003",
observation_type="engtest",
observation_reason="unknown",
physical_filter="????~????",
pressure=None,
relative_humidity=None,
Expand All @@ -392,6 +406,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_O_20191113_000061",
observation_type="engtest",
observation_reason="unknown",
physical_filter="EMPTY~ronchi90lpmm",
pressure=None,
relative_humidity=None,
Expand All @@ -415,6 +430,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_O_20191118_000011",
observation_type="dark",
observation_reason="unknown",
physical_filter="diffuser~ronchi170lpmm",
pressure=None,
relative_humidity=None,
Expand All @@ -438,6 +454,7 @@ def test_latiss_translator(self):
object="UNKNOWN",
observation_id="AT_O_20200121_000045",
observation_type="engtest",
observation_reason="unknown",
physical_filter="blank_bk7_wg05~EMPTY",
pressure=None,
relative_humidity=None,
Expand All @@ -461,6 +478,7 @@ def test_latiss_translator(self):
object="HD107696",
observation_id="AT_O_20200128_000379",
observation_type="science",
observation_reason="science",
physical_filter="KPNO_406_828nm~EMPTY",
pressure=None,
relative_humidity=None,
Expand Down Expand Up @@ -499,6 +517,7 @@ def test_imsim_translator(self):
object="UNKNOWN",
observation_id="3010002",
observation_type="science", # The header is wrong
observation_reason="imsim",
physical_filter="i",
pressure=None,
relative_humidity=40.0,
Expand All @@ -523,6 +542,7 @@ def test_imsim_translator(self):
object="UNKNOWN",
observation_id="204595",
observation_type="science", # The header is wrong
observation_reason="imsim",
physical_filter="i_sim_1.4",
pressure=None,
relative_humidity=40.0,
Expand All @@ -547,6 +567,7 @@ def test_imsim_translator(self):
object="UNKNOWN",
observation_id="5000007",
observation_type="flat",
observation_reason="imsim",
physical_filter="i",
pressure=None,
relative_humidity=40.0,
Expand All @@ -571,6 +592,7 @@ def test_imsim_translator(self):
object="UNKNOWN",
observation_id="4010003",
observation_type="science", # The header is wrong
observation_reason="imsim",
physical_filter="i",
pressure=None,
relative_humidity=40.0,
Expand Down Expand Up @@ -605,6 +627,7 @@ def test_ts3_translator(self):
exposure_time=44.631*u.s,
observation_id="E2V-CCD250-411_lambda_flat_1000_025_20181115075559",
observation_type="flat",
observation_reason="lambda",
physical_filter="550CutOn",
science_program="2018-11-15",
visit_id=201811151255111)),
Expand All @@ -622,6 +645,7 @@ def test_ts3_translator(self):
exposure_time=30.611*u.s,
observation_id="ITL-3800C-098_lambda_flat_1000_067_20160722020740",
observation_type="flat",
observation_reason="lambda",
physical_filter="550CutOn",
science_program="2016-07-22",
visit_id=201607220607067)),
Expand All @@ -645,6 +669,7 @@ def test_ts8_translator(self):
exposure_time=0.0*u.s,
observation_id="E2V-CCD250-179_lambda_bias_024_6006D_20180724104156",
observation_type="bias",
observation_reason="lambda",
physical_filter="y",
science_program="6006D",
visit_id=201807241041568)),
Expand All @@ -662,6 +687,7 @@ def test_ts8_translator(self):
exposure_time=21.913*u.s,
observation_id="E2V-CCD250-200-Dev_lambda_flat_0700_6006D_20180724102845",
observation_type="flat",
observation_reason="lambda",
physical_filter="z",
science_program="6006D",
visit_id=201807241028453)),
Expand All @@ -679,6 +705,7 @@ def test_ts8_translator(self):
exposure_time=300.0*u.s,
observation_id="E2V-CCD250-220_fe55_fe55_094_6288_20171215114006",
observation_type="fe55",
observation_reason="fe55",
physical_filter="i",
science_program="6288",
visit_id=201712151140062)),
Expand All @@ -702,6 +729,7 @@ def test_ucdcam_translator(self):
exposure_time=0.5*u.s,
observation_id="E2V-CCD250-112-04_flat_flat_100_20181205153143",
observation_type="flat",
observation_reason="flat",
physical_filter="r",
science_program="2018-12-05",
visit_id=20181205233148)),
Expand All @@ -719,6 +747,7 @@ def test_ucdcam_translator(self):
exposure_time=0.5*u.s,
observation_id="ITL-3800C-002_flat_flat_100_20180530080354",
observation_type="flat",
observation_reason="flat",
physical_filter="r",
science_program="2018-05-30",
visit_id=20180530150355)),
Expand Down

0 comments on commit 0b3b552

Please sign in to comment.