From dc4216f7ad70dbb3d22c006f8e37acfb2dd294ee Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Tue, 22 Aug 2023 09:43:44 -0700 Subject: [PATCH] Add output of adjusted parquet file. --- .../rewrite_lsstcam_qe_files_DM-40164.py | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/python/lsst/obs/lsst/script/rewrite_lsstcam_qe_files_DM-40164.py b/python/lsst/obs/lsst/script/rewrite_lsstcam_qe_files_DM-40164.py index 53b1aa1ee..127c5d68d 100644 --- a/python/lsst/obs/lsst/script/rewrite_lsstcam_qe_files_DM-40164.py +++ b/python/lsst/obs/lsst/script/rewrite_lsstcam_qe_files_DM-40164.py @@ -26,6 +26,7 @@ import numpy as np from scipy.interpolate import interp1d from scipy.optimize import leastsq +import copy import lsst.utils from lsst.meas.algorithms.simple_curve import AmpCurve @@ -141,6 +142,10 @@ def __call__(self, pars): data_path = lsst.utils.getPackageDir("obs_lsst_data") transmission_path = os.path.join(data_path, "lsstCam", "transmission_sensor") parquet_file = os.path.join(transmission_path, "qe_raft_allvalues_nircorrected_20230725.parquet") +parquet_file_update = os.path.join( + transmission_path, + "qe_raft_allvalues_nircorrected_20230725_adjust.parquet", +) valid_start = "1970-01-01T00:00:00" valid_date = dateutil.parser.parse(valid_start) @@ -252,12 +257,21 @@ def __call__(self, pars): fitter = SplineFitter(nodes, wavelengths, questionable_throughputs[raft], throughput_ref) pars = fitter.fit(np.ones(len(nodes))) - _, spl = fitter.compute_ratio_model(nodes, pars, wavelengths, questionable_throughputs[raft], throughput_ref, return_spline=True) + _, spl = fitter.compute_ratio_model( + nodes, + pars, + wavelengths, + questionable_throughputs[raft], + throughput_ref, + return_spline=True, + ) questionable_spline_correctors[raft] = spl det_nums = np.unique(data["idet"]) +data_update = copy.copy(data) + for det_num in det_nums: det_use, = np.where((data["idet"] == det_num) & (data["seg"] != "Ave")) slot = data["slot"][det_use[0]] @@ -270,6 +284,8 @@ def __call__(self, pars): spl = questionable_spline_correctors[bay] efficiency *= spl.interpolate(wavelength) + data_update["qecorr"][det_use][:] = efficiency + curve_table = QTable( { "amp_name": np.array(data["seg"][det_use]), @@ -306,3 +322,15 @@ def __call__(self, pars): os.remove(out_file) curve.writeText(out_file) + + # And update the average. + det_use_ave, = np.where((data["idet"] == det_num) & (data["seg"] == "Ave")) + wavelength_ave = np.array(data["wl"][det_use_ave]) + efficiency_ave = np.array(data["qecorr"][det_use_ave]) + if bay in questionable_rafts: + spl = questionable_spline_correctors[bay] + efficiency_ave *= spl.interpolate(wavelength_ave) + + data_update["qecorr"][det_use_ave][:] = efficiency_ave + +data_update.write(parquet_file_update, overwrite=True)