Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions spectractor/extractor/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions spectractor/fit/fit_spectrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down
Loading