Skip to content

Commit

Permalink
Update transmission_sensor/qe rewrite and test codee.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Nov 8, 2022
1 parent 530889e commit f00bc7a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 3 additions & 1 deletion python/lsst/obs/lsst/script/rewrite_ts8_qe_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ def rewrite_ts8_files(picklefile, out_root='.', valid_start='1970-01-01T00:00:00
os.makedirs(outpath, exist_ok=True)
full_detector_name = '_'.join([raft_name, detector_name])
detector_id = cam[full_detector_name].getId()
curve_table.meta.update({'CALIBDATE': valid_start, 'INSTRUME': 'TS8', 'OBSTYPE': 'qe_curve',
curve_table.meta.update({'CALIBDATE': valid_start, 'INSTRUME': 'TS8',
'OBSTYPE': 'transmission_sensor', 'TYPE': 'transmission_sensor',
'DETECTOR': detector_id, 'PICKLEFILE': os.path.split(picklefile)[1]})

curve_table.meta['CALIB_ID'] = (f'raftName={raft_name} detectorName={detector_name} '
f'detector={detector_id} calibDate={valid_start} '
f'ccd={detector_id} ccdnum={detector_id} filter=None')
Expand Down
19 changes: 15 additions & 4 deletions tests/test_rewrite_qe.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import glob

import lsst.utils
from lsst.meas.algorithms import Curve
from lsst.obs.lsst.script.rewrite_ts8_qe_files import rewrite_ts8_files
from lsst.ip.isr import IntermediateSensorTransmissionCurve

TESTDIR = os.path.abspath(os.path.dirname(__file__))
DATADIR = lsst.utils.getPackageDir('obs_lsst_data')
Expand All @@ -47,9 +47,20 @@ def testRewriteQe(self):
files = glob.glob(os.path.join(root, '*', '19700101T000000.ecsv'))
self.assertEqual(len(files), 9)
for f in files:
curve1 = Curve.readText(f)
expect_file = os.path.join(DATADIR, 'ts8', 'qe_curve', os.path.relpath(f, root))
curve2 = Curve.readText(expect_file)
curve1 = IntermediateSensorTransmissionCurve.readText(f)
expect_file = os.path.join(DATADIR, 'ts8', 'transmission_sensor', os.path.relpath(f, root))
curve2 = IntermediateSensorTransmissionCurve.readText(expect_file)

# These fields are created every time, and therefore
# differ between the test data and the references.
curve1.getMetadata().pop('DATE')
curve1.getMetadata().pop('CALIB_CREATION_DATE')
curve1.getMetadata().pop('CALIB_CREATION_TIME')

curve2.getMetadata().pop('DATE')
curve2.getMetadata().pop('CALIB_CREATION_DATE')
curve2.getMetadata().pop('CALIB_CREATION_TIME')

self.assertEqual(curve1, curve2)
except Exception:
failed = True
Expand Down

0 comments on commit f00bc7a

Please sign in to comment.