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

Trace fix improvements #2386

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
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
23 changes: 11 additions & 12 deletions py/desispec/scripts/trace_shifts.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ def fit_trace_shifts(image, args):

spectrum_filename = args.spectrum
if args.sky :
continuum_subtract = True
srch_file = "data/spec-sky.dat"
if not resources.files('desispec').joinpath(srch_file).is_file():
log.error("Cannot find sky spectrum file {:s}".format(srch_file))
raise RuntimeError("Cannot find sky spectrum file {:s}".format(srch_file))
spectrum_filename = resources.files('desispec').joinpath(srch_file)
elif args.arc_lamps :
continuum_subtract = False
srch_file = "data/spec-arc-lamps.dat"
if not resources.files('desispec').joinpath(srch_file).is_file():
log.error("Cannot find arc lamps spectrum file {:s}".format(srch_file))
Expand Down Expand Up @@ -196,7 +198,7 @@ def fit_trace_shifts(image, args):
x_for_dx,y_for_dx,dx,ex,fiber_for_dx,wave_for_dx = compute_dx_from_cross_dispersion_profiles(xcoef,ycoef,wavemin,wavemax, image=image, fibers=fibers, width=args.width, deg=args.degxy,image_rebin=args.ccd_rows_rebin)
if internal_wavelength_calib :
# measure y shifts
x_for_dy,y_for_dy,dy,ey,fiber_for_dy,wave_for_dy = compute_dy_using_boxcar_extraction(tset, image=image, fibers=fibers, width=args.width)
x_for_dy,y_for_dy,dy,ey,fiber_for_dy,wave_for_dy = compute_dy_using_boxcar_extraction(tset, image=image, fibers=fibers, width=args.width, continuum_subtract=continuum_subtract)
mdy = np.median(dy)
log.info("Subtract median(dy)={}".format(mdy))
dy -= mdy # remove median, because this is an internal calibration
Expand All @@ -216,17 +218,14 @@ def fit_trace_shifts(image, args):
degyy=args.degyy

# if any quadrant is masked, reduce to a single offset
hy=image.pix.shape[0]//2
hx=image.pix.shape[1]//2
allgood=True
allgood &= (np.sum((x_for_dx<hx)&(y_for_dx<hy))>0) # some data in this quadrant
allgood &= (np.sum((x_for_dx<hx)&(y_for_dx>hy))>0) # some data in this quadrant
allgood &= (np.sum((x_for_dx>hx)&(y_for_dx<hy))>0) # some data in this quadrant
allgood &= (np.sum((x_for_dx>hx)&(y_for_dx>hy))>0) # some data in this quadrant
allgood &= (np.sum((x_for_dy<hx)&(y_for_dy<hy))>0) # some data in this quadrant
allgood &= (np.sum((x_for_dy<hx)&(y_for_dy>hy))>0) # some data in this quadrant
allgood &= (np.sum((x_for_dy>hx)&(y_for_dy<hy))>0) # some data in this quadrant
allgood &= (np.sum((x_for_dy>hx)&(y_for_dy>hy))>0) # some data in this quadrant
hy = image.pix.shape[0] // 2
hx = image.pix.shape[1] // 2
allgood = True
for _curx, _cury in [(x_for_dx,y_for_dx),(x_for_dy, y_for_dy)]:
for curxop in [np.less, np.greater]:
for curyop in [np.less, np.greater]:
allgood &= np.any(curxop(_curx, hx) & curyop(_cury, hy))
# some data in this quadrant
if not allgood :
log.warning("No shift data for at least one quadrant of the CCD, falls back to deg=0 shift")
degxx=0
Expand Down
Loading
Loading