desihub / specex

DESI spectrograph PSF fitting
BSD 3-Clause "New" or "Revised" License
0 stars 4 forks source link

Use input PSF if possible #52

Closed marcelo-alvarez closed 3 years ago

marcelo-alvarez commented 3 years ago

Previous behaviour of specex prevented using input PSF parameters when the Legendre degree was specified with the --legendre-deg-wave flag to run_specex, as is currently the case.

Using input PSF parameters when the Legendre degree is specified gives a speedup on cori of about 20-40% for b and z cameras, for arc exposure 00098135 on 20210710, using input consistent with the current trunk of desi_spectro_calib, with respect to using desi environment 21.7e on cori and the current master branch of specex.

Using input PSF parameters also results in output PSF that are nearly identical, differing by d_psf < 1e-3 for fiber = [4, 495] and wavelength = [3800, 5000, 5600], [6000, 6700, 7300], and [7900, 8700, 9500], for all 10 b, r, and z cameras, respectively, for arc exposure 00098135 on 20210710 (180 PSF comparisons total), with d_psf defined using:

import specter.psf
xx1,yy1,fpix1=psf1.xypix(fiber,wavelength)
xx2,yy2,fpix2=psf2.xypix(fiber,wavelength)
# code to clip psf[1,2] to same range if necessary omitted
d_psf = 1-np.abs(np.sum(fpix1*fpix2)/np.sum(fpix2**2))

The change in the output PSF for other exposures, fibers, and wavelengths has not been measured, but there is no reason to believe the differences from this change would not be similarly negligible.

marcelo-alvarez commented 3 years ago

An additional commit compares input PSF properties to those that are specified (either by default or the command line), and only uses the input PSF if they all match; otherwise, it prints a warning message and does not use the input PSF as a starting point.

The performance and behaviour for the case discussed above remain unchanged.