Skip to content

Commit ffe7e49

Browse files
committed
Merge branch 'tickets/DM-44113'
2 parents 1a2d93e + 924916a commit ffe7e49

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

python/lsst/ip/isr/calibType.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import yaml
2929
import numpy as np
3030

31+
from astro_metadata_translator import merge_headers
3132
from astropy.table import Table
3233
from astropy.io import fits
3334

@@ -539,6 +540,13 @@ def readFits(cls, filename, **kwargs):
539540
table.meta[k] = None
540541

541542
calibClass = cls.determineCalibClass(tableList[0].meta, "readFits")
543+
if calibClass._OBSTYPE in ("PHOTODIODE", ):
544+
# Merge primary header, as these types store information
545+
# there.
546+
with fits.open(filename) as hdul:
547+
primaryHeader = hdul[0].header
548+
tableList[0].meta = merge_headers([tableList[0].meta, primaryHeader], mode="first")
549+
542550
return calibClass.fromTable(tableList, **kwargs)
543551

544552
def writeFits(self, filename):

python/lsst/ip/isr/photodiode.py

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def toDict(self):
150150
return outDict
151151

152152
@classmethod
153-
def fromTable(cls, tableList):
153+
def fromTable(cls, tableList, **kwargs):
154154
"""Construct calibration from a list of tables.
155155
156156
This method uses the `fromDict` method to create the
@@ -169,15 +169,40 @@ def fromTable(cls, tableList):
169169
The calibration defined in the tables.
170170
"""
171171
dataTable = tableList[0]
172-
173172
metadata = dataTable.meta
173+
174+
# Dump useless entries that are carried over from merging
175+
# HDU[0]'s header with the header from HDU[1] (which has the
176+
# data table).
177+
for key in ("SIMPLE", "BITPIX", "NAXIS", "EXTEND"):
178+
metadata.pop(key)
179+
180+
# Do translations:
181+
instrument = metadata.pop("INSTRUME", None)
182+
location = metadata.pop("LOCATN", "NO_LOCATION")
183+
184+
if instrument == "Electrometer_index_201" and location == "AuxTel":
185+
metadata["INSTRUME"] = "LATISS"
186+
elif location == "MainTel" and instrument in ("Electrometer_index_101",
187+
"Electrometer_index_102",
188+
"Electrometer_index_103"):
189+
metadata["INSTRUME"] = "LSSTCam"
190+
else:
191+
# This will cause problems in ingest, but we don't know
192+
# what to associate it with.
193+
metadata["INSTRUME"] = instrument
194+
174195
inDict = {}
175196
inDict['metadata'] = metadata
197+
176198
if 'OBSTYPE' not in metadata:
177199
inDict['metadata']['OBSTYPE'] = cls._OBSTYPE
178200
inDict['integrationMethod'] = metadata.pop('INTEGRATION_METHOD', 'DIRECT_SUM')
179201

180-
for key in ('TIME', 'Elapsed Time', ):
202+
# These will use the last column found, so "RNUM" (which is in
203+
# seconds) will replace "Elapsed Time" (which is in integer
204+
# sample counts) when both are found in the table.
205+
for key in ('TIME', 'Elapsed Time', 'RNUM'):
181206
if key in dataTable.columns:
182207
inDict['timeSamples'] = dataTable[key]
183208
for key in ('CURRENT', 'Signal', ):

0 commit comments

Comments
 (0)