Skip to content

Commit

Permalink
Merge pull request #22 from lsst/tickets/DM-34193
Browse files Browse the repository at this point in the history
DM-34193: Merge upstream master to lsst-dev via ticket
  • Loading branch information
mfisherlevine authored Mar 28, 2022
2 parents 96af3fe + bfdc4e7 commit 0dfba41
Show file tree
Hide file tree
Showing 27 changed files with 39,280 additions and 39,094 deletions.
2 changes: 1 addition & 1 deletion config/auxtel.ini
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ PIXWIDTH_BACKGROUND = 40
PIXWIDTH_BOXSIZE = 20

[PSF]
# the PSF model: Moffat or MoffatGauss
# the PSF model: Gauss, Moffat or MoffatGauss
PSF_TYPE = Moffat
# the order of the polynomials to model wavelength dependence of the PSF shape parameters
PSF_POLY_ORDER = 2
Expand Down
2 changes: 1 addition & 1 deletion config/auxtel_quicklook.ini
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ PIXWIDTH_BOXSIZE = 20
SPEC_ORDER = 1

[PSF]
# the PSF model: Moffat or MoffatGauss
# the PSF model: Gauss, Moffat or MoffatGauss
PSF_TYPE = Moffat
# the order of the polynomials to model wavelength dependence of the PSF shape parameters
PSF_POLY_ORDER = 2
Expand Down
6 changes: 4 additions & 2 deletions config/ctio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ DISPERSER_DIR = extractor/dispersers/
# relative path to throughput directory
THROUGHPUT_DIR = simulation/CTIOThroughput/

#LSST_SAVEFIGPATH = outputs/plots/paper/sim_20170530_134

[pipeline]
# method to get target centroid, choose among: guess, fit, WCS
SPECTRACTOR_FIT_TARGET_CENTROID = fit
Expand Down Expand Up @@ -32,7 +34,7 @@ OBS_OBJECT_TYPE = STAR
# telescope transmission file
OBS_TELESCOPE_TRANSMISSION = ctio_throughput.txt
# full instrument transmission file
OBS_FULL_INSTRUMENT_TRANSMISSON = multispectra_Thor300_HD111980_CTIO_throughput_prod7.5.3.txt
OBS_FULL_INSTRUMENT_TRANSMISSON = multispectra_Thor300_HD111980_CTIO_throughput_prod7.5.4.txt
# quantum efficiency of the detector file
OBS_QUANTUM_EFFICIENCY = qecurve.txt
# Camera (x,y) rotation angle with respect to (north-up, east-left) system
Expand Down Expand Up @@ -99,7 +101,7 @@ PIXWIDTH_BACKGROUND = 100
PIXWIDTH_BOXSIZE = 40

[PSF]
# the PSF model: Moffat or MoffatGauss
# the PSF model: Gauss, Moffat or MoffatGauss
PSF_TYPE = Moffat
# the order of the polynomials to model wavelength dependence of the PSF shape parameters
PSF_POLY_ORDER = 4
Expand Down
2 changes: 1 addition & 1 deletion config/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ PIXWIDTH_BACKGROUND = 40
PIXWIDTH_BOXSIZE = 20

[PSF]
# the PSF model: Moffat or MoffatGauss
# the PSF model: Gauss, Moffat or MoffatGauss
PSF_TYPE = Moffat
# the order of the polynomials to model wavelength dependence of the PSF shape parameters
PSF_POLY_ORDER = 2
Expand Down
2 changes: 1 addition & 1 deletion config/lpnhe.ini
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ PIXDIST_BACKGROUND = 80
PIXWIDTH_BACKGROUND = 60

[PSF]
# the PSF model: Moffat or MoffatGauss
# the PSF model: Gauss, Moffat or MoffatGauss
PSF_TYPE = Order0
# the order of the polynomials to model wavelength dependence of the PSF shape parameters
PSF_POLY_ORDER = 1
Expand Down
17 changes: 12 additions & 5 deletions spectractor/extractor/chromaticpsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,15 @@ def __init__(self, psf, Nx, Ny, x0=0, y0=None, deg=4, saturation=None, file_name
self.y0 = y0
self.profile_params = np.zeros((Nx, len(self.psf.param_names)))
self.pixels = np.mgrid[:Nx, :Ny]
self.init_table(file_name=file_name, saturation=saturation)
self.opt_reg = parameters.PSF_FIT_REG_PARAM
self.cov_matrix = np.zeros((Nx, Nx))
if file_name != "":
self.poly_params = self.from_table_to_poly_params()

def init_table(self, file_name='', saturation=None):
if file_name == '':
arr = np.zeros((Nx, len(self.psf.param_names) + 10))
arr = np.zeros((self.Nx, len(self.psf.param_names) + 10))
self.table = Table(arr, names=['lambdas', 'Dx', 'Dy', 'Dy_disp_axis', 'flux_sum', 'flux_integral',
'flux_err', 'fwhm', 'Dy_fwhm_sup', 'Dy_fwhm_inf'] + list(
self.psf.param_names))
Expand Down Expand Up @@ -111,14 +118,11 @@ def __init__(self, psf, Nx, Ny, x0=0, y0=None, deg=4, saturation=None, file_name
self.poly_params_labels.append(f"{p}_{k}")
self.poly_params_names.append("$" + self.psf.axis_names[ip].replace("$", "")
+ "^{(" + str(k) + ")}$")
self.opt_reg = parameters.PSF_FIT_REG_PARAM
self.cov_matrix = np.zeros((Nx, Nx))
if file_name != "":
self.poly_params = self.from_table_to_poly_params()

def set_polynomial_degrees(self, deg):
self.deg = deg
self.degrees = {key: deg for key in self.psf.param_names}
self.degrees["x_c"] = max(self.degrees["x_c"], 1)
self.degrees['saturation'] = 0

def generate_test_poly_params(self):
Expand Down Expand Up @@ -1120,6 +1124,7 @@ def fit_chromatic_psf(self, data, bgd_model_func=None, data_errors=None, mode="1
w_reg = RegFitWorkspace(w, opt_reg=parameters.PSF_FIT_REG_PARAM, verbose=verbose)
w_reg.run_regularisation()
w.reg = np.copy(w_reg.opt_reg)
w.trace_r = np.trace(w_reg.resolution)
self.opt_reg = w_reg.opt_reg
w.simulate(*w.p)
if np.trace(w.amplitude_cov_matrix) < np.trace(w.amplitude_priors_cov_matrix):
Expand Down Expand Up @@ -1244,6 +1249,7 @@ def __init__(self, chromatic_psf, data, data_errors, bgd_model_func=None, file_n
self.amplitude_priors_method = amplitude_priors_method
self.fwhm_priors = np.copy(self.chromatic_psf.table['fwhm'])
self.reg = parameters.PSF_FIT_REG_PARAM
self.trace_r = -1
self.Q = np.zeros((self.Nx, self.Nx))
self.Q_dot_A0 = np.zeros(self.Nx)
if amplitude_priors_method not in self.amplitude_priors_list:
Expand Down Expand Up @@ -1312,6 +1318,7 @@ def plot_fit(self):
ax[3, 0].legend(fontsize=7)
ax[3, 0].set_xlim((0, data.shape[1]))
ax[3, 0].grid(True)
fig.tight_layout()
if self.live_fit: # pragma: no cover
plt.draw()
plt.pause(1e-8)
Expand Down
2 changes: 1 addition & 1 deletion spectractor/extractor/dispersers/HoloAmAg/NOTES
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- ratio_order_2over1.txt: fit of a model to Sylvie's data from CTIO spectra observed with a blue filter
- transmission.txt: fit on CTIO data 2017/30/05 normalized with multispectra_Thor300_HD111980_CTIO_throughput_prod7.5.3.txt
- transmission.txt: fit on CTIO data 2017/30/05 normalized with multispectra_Thor300_HD111980_CTIO_throughput_prod7.5.4.txt
../CTIODataJune2017_reduced_RG715_v2_prod7.5/data_30may17_A2=0.1/multispectra_HoloAmAg_HD111980_HoloAmAg_throughput.txt
(see jupyter notebook Multispectra.ipynb)
- N.txt: interpolation of Neff estimated with CTIO scan of the hologram
Expand Down
Loading

0 comments on commit 0dfba41

Please sign in to comment.