From 97e1bf7d9e0dc783bb4fbd083a578ba1683ce2f8 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Tue, 23 Jul 2024 16:41:32 -0700 Subject: [PATCH] Add script to put LATISS crosstalk matrix in obs_lsst_data. --- .../script/write_latiss_crosstalk_coeffs.py | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 python/lsst/obs/lsst/script/write_latiss_crosstalk_coeffs.py diff --git a/python/lsst/obs/lsst/script/write_latiss_crosstalk_coeffs.py b/python/lsst/obs/lsst/script/write_latiss_crosstalk_coeffs.py new file mode 100644 index 000000000..0f5ffc8fb --- /dev/null +++ b/python/lsst/obs/lsst/script/write_latiss_crosstalk_coeffs.py @@ -0,0 +1,55 @@ +# This file is part of obs_lsst. +# +# Developed for the LSST Data Management System. +# This product includes software developed by the LSST Project +# (https://www.lsst.org). +# See the COPYRIGHT file at the top-level directory of this distribution +# for details of code ownership. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +import re +import os +import dateutil.parser +from lsst.daf.butler import Butler +import lsst.utils + + +crosstalk_run = "u/czw/DM-37819/crosstalkGen.20230601a/20230601T201929Z" + +butler = Butler("/repo/embargo") + +camera = butler.get("camera", instrument="LATISS", collections=["LATISS/calib"]) +crosstalk = butler.get("crosstalk", instrument="LATISS", detector=0, collections=[crosstalk_run]) + +det = camera[0] +name = det.getName() + +# Make this valid for all time. +valid_start = "1970-01-01T00:00:00" +valid_date = dateutil.parser.parse(valid_start) +datestr = "".join(re.split(r"[:-]", valid_date.isoformat())) +directory = lsst.utils.getPackageDir("obs_lsst_data") +out_path = os.path.join(directory, "latiss", "crosstalk", name.lower()) +os.makedirs(out_path, exist_ok=True) +out_file = os.path.join(out_path, datestr + ".ecsv") + +crosstalk.updateMetadata( + camera=camera, + detector=det, + setCalibId=True, + setCalibInfo=True, + CALIBDATE=valid_start, +) + +crosstalk.writeText(out_file)