From e52b1494c99c1d1b6bb3e090ef36663f4ea64399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Neveu?= Date: Wed, 13 May 2026 00:25:01 +0000 Subject: [PATCH] holo4+prism analysis code with effective ADR amplitude --- spectractor/extractor/extractor.py | 13 +++++++------ spectractor/fit/fit_spectrogram.py | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/spectractor/extractor/extractor.py b/spectractor/extractor/extractor.py index 72647868..8e3752c6 100644 --- a/spectractor/extractor/extractor.py +++ b/spectractor/extractor/extractor.py @@ -74,20 +74,20 @@ def __init__(self, spectrum, amplitude_priors_method="noprior", verbose=False, p # for order in self.diffraction_orders: # p = np.concatenate([p] + [self.psf_poly_params * order]) input_labels = [f"A{order}" for order in self.diffraction_orders] - input_labels += [r"D_CCD [mm]", r"shift_x [pix]", r"shift_y [pix]", r"angle [deg]", "B", "A_star", "R", "P [hPa]", "T [Celsius]", "z"] + input_labels += [r"D_CCD [mm]", r"shift_x [pix]", r"shift_y [pix]", r"angle [deg]", "B", "A_star", "R", "ADR", "T [Celsius]", "z"] for order in self.diffraction_orders: input_labels += [label+f"_{order}" for label in psf_poly_params_labels] - axis_names = [f"$A_{order}$" for order in self.diffraction_orders] + axis_names = [rf"$A_{order}$" for order in self.diffraction_orders] axis_names += [r"$D_{CCD}$ [mm]", r"$\delta_{\mathrm{x}}^{(\mathrm{fit})}$ [pix]", r"$\delta_{\mathrm{y}}^{(\mathrm{fit})}$ [pix]", r"$\alpha$ [deg]", "$B$", r"$A_{star}$", "R", - r"$P_{\mathrm{atm}}$ [hPa]", r"$T_{\mathrm{atm}}$ [Celcius]", "$z$"] + r"$A_{ADR}$", r"$T_{\mathrm{atm}}$ [Celcius]", r"$z$"] for order in self.diffraction_orders: - axis_names += [label+rf"$\!_{order}$" for label in psf_poly_params_names] + axis_names += [label+r"$\!_$" + str(order) + "$" for label in psf_poly_params_names] bounds = [[0, 2], [0, 2], [0, 2], [D2CCD - 3 * parameters.DISTANCE2CCD_ERR, D2CCD + 3 * parameters.DISTANCE2CCD_ERR], [-parameters.PIXSHIFT_PRIOR, parameters.PIXSHIFT_PRIOR], [-10 * parameters.PIXSHIFT_PRIOR, 10 * parameters.PIXSHIFT_PRIOR], - [-90, 90], [0.2, 5], [0.5, 2], [-360, 360], [0, np.inf], [-100, 100], [1.001, 3]] + [-90, 90], [0.2, 5], [0.5, 2], [-360, 360], [-np.inf, np.inf], [-100, 100], [1.001, 3]] bounds += list(psf_poly_params_bounds) * len(self.diffraction_orders) fixed = [False] * p.size for k, par in enumerate(input_labels): @@ -128,7 +128,7 @@ def __init__(self, spectrum, amplitude_priors_method="noprior", verbose=False, p params.fixed[params.get_index("angle [deg]")] = False # angle params.fixed[params.get_index("B")] = True # B: not needed in simulations, to check with data params.fixed[params.get_index("R")] = True # camera rot - params.fixed[params.get_index("P [hPa]")] = False # pressure + params.fixed[params.get_index("ADR")] = False # pressure params.fixed[params.get_index("T [Celsius]")] = True # temperature params.fixed[params.get_index("z")] = True # airmass @@ -876,6 +876,7 @@ def adjust_spectrogram_position_parameters(self): self.params.fixed[self.params.get_index(f"A{self.diffraction_orders[0]}")] = True # A1 self.params.fixed[self.params.get_index(r"shift_y [pix]")] = False # shift y self.params.fixed[self.params.get_index(r"angle [deg]")] = False # angle + self.params.fixed[self.params.get_index(r"ADR")] = False # ADR run_minimisation(self, "newton", xtol=1e-2, ftol=0.01, with_line_search=False) # 1000 / self.data.size) self.params.fixed = fixed_default self.set_mask(params=self.params.values, fwhmx_clip=3 * parameters.PSF_FWHM_CLIP, fwhmy_clip=parameters.PSF_FWHM_CLIP) diff --git a/spectractor/fit/fit_spectrogram.py b/spectractor/fit/fit_spectrogram.py index c9d3740b..cc74875f 100644 --- a/spectractor/fit/fit_spectrogram.py +++ b/spectractor/fit/fit_spectrogram.py @@ -94,18 +94,18 @@ def __init__(self, spectrum, atmgrid_file_name="", fit_angstrom_exponent=False, p = np.concatenate([p] + [self.psf_poly_params] * len(self.diffraction_orders)) input_labels = [f"A{order}" for order in self.diffraction_orders] input_labels += ["VAOD", "angstrom_exp", "ozone [db]", "PWV [mm]", "B", "A_star", - r"D_CCD [mm]", r"shift_x [pix]", r"shift_y [pix]", r"angle [deg]", "P [hPa]"] + r"D_CCD [mm]", r"shift_x [pix]", r"shift_y [pix]", r"angle [deg]", "ADR"] for order in self.diffraction_orders: input_labels += [label + f"_{order}" for label in psf_poly_params_labels] axis_names = [f"$A_{order}$" for order in self.diffraction_orders] axis_names += ["VAOD", r'$\"a$', "ozone [db]", "PWV [mm]", "$B$", r"$A_{star}$", r"$D_{CCD}$ [mm]", r"$\Delta_{\mathrm{x}}$ [pix]", r"$\Delta_{\mathrm{y}}$ [pix]", r"$\theta$ [deg]", - r"$P_{\mathrm{atm}}$ [hPa]"] + r"$A_{\mathrm{ADR}}$"] for order in self.diffraction_orders: axis_names += [label+rf"$\!_{order}$" for label in psf_poly_params_names] bounds = [[0, 2], [0, 2], [0, 2], [0, 10], [0, 4], [100, 700], [0, 20], [0.8, 1.2], [0, np.inf], [D2CCD - 20 * parameters.DISTANCE2CCD_ERR, D2CCD + 20 * parameters.DISTANCE2CCD_ERR], [-10, 10], - [-10, 10], [-90, 90], [0, np.inf]] + [-10, 10], [-90, 90], [-np.inf, np.inf]] bounds += list(psf_poly_params_bounds) * len(self.diffraction_orders) fixed = [False] * p.size for k, par in enumerate(input_labels): @@ -141,7 +141,7 @@ def __init__(self, spectrum, atmgrid_file_name="", fit_angstrom_exponent=False, params.fixed[params.get_index(r"shift_y [pix]")] = False # Delta y params.fixed[params.get_index(r"angle [deg]")] = False # angle params.fixed[params.get_index("B")] = True # B - params.fixed[params.get_index("P [hPa]")] = False # pressure for ADR + params.fixed[params.get_index("ADR")] = False # pressure for ADR if self.spectrum.spectrogram_Ny > 2 * parameters.PIXDIST_BACKGROUND: self.crop_spectrogram()