Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2114 #2115

Merged
merged 1 commit into from
Sep 11, 2023
Merged
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
11 changes: 8 additions & 3 deletions py/desispec/trace_shifts.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,17 @@ def shift_ycoef_using_external_spectrum(psf, xytraceset, image, fibers,
# to assign variance to a spectrum (1.48 is MAD factor,
# pi/2 is a factor from Stddev[median(N(0,1))]
mad_factor = 1.48
mad = np.maximum(np.median(np.abs(flux - mflux[None, :]),
axis=0), 1e-100)
# I prevent it from being zero to avoid the warning below
# The exact value does not matter as we're comparing to actual
# median(ivar)
mivar = np.minimum(
np.median(ivar, axis=0) ,
1./mad_factor**2 / np.median(np.abs(flux - mflux[None, :]),
axis=0)**2) * flux.shape[0] * (2. / np.pi)
1./mad_factor**2 / mad**2) * flux.shape[0] * (2. / np.pi)
# finally use use the MAD of the background subtracted spectra to
# assign further variance limit
# assign further variance limit
# this is sort of "effective" noise in the continuum subtracted spectrum
mivar = np.minimum(mivar, 1. / mad_factor**2 / np.median(np.abs(mflux))**2)
# do not allow negatives
mflux[mflux < 0] = 0
Expand Down
Loading