From ee2037036a281804aee0d1762a76eca2c593e102 Mon Sep 17 00:00:00 2001 From: "Sergey E. Koposov" Date: Wed, 9 Oct 2024 14:50:52 -0700 Subject: [PATCH] make sure arcs are still processed with continuum as before --- py/desispec/scripts/trace_shifts.py | 4 +++- py/desispec/trace_shifts.py | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/py/desispec/scripts/trace_shifts.py b/py/desispec/scripts/trace_shifts.py index e12a09ef1..b1ec93455 100644 --- a/py/desispec/scripts/trace_shifts.py +++ b/py/desispec/scripts/trace_shifts.py @@ -140,8 +140,10 @@ def fit_trace_shifts(image, args): internal_wavelength_calib = False elif flavor == "arc" : internal_wavelength_calib = True + subtract_continuum = False args.arc_lamps = True else : + subtract_continuum = True internal_wavelength_calib = True args.sky = True log.info("wavelength calib, internal={}, sky={} , arc_lamps={}".format(internal_wavelength_calib,args.sky,args.arc_lamps)) @@ -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, subtract_continuum=subtract_continuum) mdy = np.median(dy) log.info("Subtract median(dy)={}".format(mdy)) dy -= mdy # remove median, because this is an internal calibration diff --git a/py/desispec/trace_shifts.py b/py/desispec/trace_shifts.py index b580350c1..48ee843e3 100644 --- a/py/desispec/trace_shifts.py +++ b/py/desispec/trace_shifts.py @@ -393,7 +393,8 @@ def compute_dy_from_spectral_cross_correlations_of_frame(flux, ivar, wave , xcoe return x_for_dy,y_for_dy,dy,ey,fiber_for_dy,wave_for_dy -def compute_dy_using_boxcar_extraction(xytraceset, image, fibers, width=7, degyy=2) : +def compute_dy_using_boxcar_extraction(xytraceset, image, fibers, width=7, degyy=2, + continuum_subtract = False): """ Measures y offsets (internal wavelength calibration) from a preprocessed image and a trace set using a cross-correlation of boxcar extracted spectra. Uses boxcar_extraction , resample_boxcar_frame , compute_dy_from_spectral_cross_correlations_of_frame @@ -406,6 +407,7 @@ def compute_dy_using_boxcar_extraction(xytraceset, image, fibers, width=7, degyy fibers : 1D np.array of int (default is all fibers, the first fiber is always = 0) width : int, extraction boxcar width, default is 7 degyy : int, degree of polynomial fit of shifts as a function of y, used to reject outliers. + continuum_subtract : bool if true subtract continuum before cross-correlation Returns: x : 1D array of x coordinates on CCD (axis=1 in numpy image array, AXIS=0 in FITS, cross-dispersion axis = fiber number direction) @@ -418,7 +420,6 @@ def compute_dy_using_boxcar_extraction(xytraceset, image, fibers, width=7, degyy """ log=get_logger() - continuum_subtract = True # use continuum subtracted spectra to self-calibrate # boxcar extraction qframe = qproc_boxcar_extraction(xytraceset, image, fibers=fibers, width=7)