Skip to content

Commit

Permalink
convert to spat_flexure
Browse files Browse the repository at this point in the history
  • Loading branch information
rcooke-ast committed Dec 21, 2024
1 parent ea6961d commit 5a4c0c4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion pypeit/coadd3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,8 @@ def load(self):
crval_wv = self.cubepar['wave_min'] if self.cubepar['wave_min'] is not None else wave0
cd_wv = self.cubepar['wave_delta'] if self.cubepar['wave_delta'] is not None else dwv
self.all_wcs.append(self.spec.get_wcs(spec2DObj.head0, slits, detector.platescale, crval_wv, cd_wv))
ra_img, dec_img, minmax = slits.get_radec_image(self.all_wcs[ff], alignSplines, spec2DObj.tilts, flexure=spat_flexure)
ra_img, dec_img, minmax = slits.get_radec_image(self.all_wcs[ff], alignSplines, spec2DObj.tilts,
spat_flexure=spat_flexure)

# Extract wavelength and delta wavelength arrays from the images
wave_ext = waveimg[onslit_gpm]
Expand Down
4 changes: 2 additions & 2 deletions pypeit/core/flexure.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ def spat_flexure_qa(img, slits, shift, gpm=None, vrange=None, outfile=None):
vrange = None

# TODO: should we use initial or tweaked slits in this plot?
left_slits, right_slits, mask_slits = slits.select_edges(initial=True, flexure=None)
left_flex, right_flex, mask = slits.select_edges(initial=True, flexure=shift)
left_slits, right_slits, mask_slits = slits.select_edges(initial=True, spat_flexure=None)
left_flex, right_flex, mask = slits.select_edges(initial=True, spat_flexure=shift)

if debug:
# where to start and end the plot in the spatial&spectral direction
Expand Down
16 changes: 9 additions & 7 deletions pypeit/core/gui/skysub_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class SkySubGUI:
"""

def __init__(self, canvas, image, frame, outname, det, slits, axes, pypeline, spectrograph, printout=False,
runtime=False, resolution=None, initial=False, flexure=None, overwrite=False):
runtime=False, resolution=None, initial=False, spat_flexure=None, overwrite=False):
"""Controls for the interactive sky regions definition tasks in PypeIt.
The main goal of this routine is to interactively select sky background
Expand Down Expand Up @@ -73,8 +73,8 @@ def __init__(self, canvas, image, frame, outname, det, slits, axes, pypeline, sp
initial : bool, optional
To use the initial edges regardless of the presence of
the tweaked edges, set this to True.
flexure : float, optional
If provided, offset each slit by this amount
spat_flexure : float, optional
If provided, offset each slit in the spatial direction by this amount
runtime : bool
Is the GUI being launched during data reduction?
resolution : int
Expand Down Expand Up @@ -137,7 +137,7 @@ def __init__(self, canvas, image, frame, outname, det, slits, axes, pypeline, sp
self._fitr = [] # Matplotlib shaded fit region
self._fita = None

self.slits_left, self.slits_right, _ = slits.select_edges(initial=initial, spat_flexure=flexure)
self.slits_left, self.slits_right, _ = slits.select_edges(initial=initial, spat_flexure=spat_flexure)
self.initialize_menu()
self.reset_regions()

Expand All @@ -149,7 +149,7 @@ def __init__(self, canvas, image, frame, outname, det, slits, axes, pypeline, sp
@classmethod
def initialize(cls, det, frame, slits, pypeline, spectrograph, outname="skyregions.fits",
overwrite=False, initial=False,
flexure=None, runtime=False, printout=False):
spat_flexure=None, runtime=False, printout=False):
"""
Initialize the 'ObjFindGUI' window for interactive object tracing
Expand All @@ -167,6 +167,8 @@ def initialize(cls, det, frame, slits, pypeline, spectrograph, outname="skyregio
Name of the spectrograph
printout : bool
Should the results be printed to screen
spat_flexure : float, optional
If provided, offset each slit in the spatial direction by this amount
runtime : bool
Is this GUI being launched during a data reduction?
Expand All @@ -178,7 +180,7 @@ def initialize(cls, det, frame, slits, pypeline, spectrograph, outname="skyregio
# NOTE: SlitTraceSet objects always store the left and right
# traces as 2D arrays, even if there's only one slit.
nslit = slits.nslits
lordloc, rordloc, _ = slits.select_edges(initial=initial, spat_flexure=flexure)
lordloc, rordloc, _ = slits.select_edges(initial=initial, spat_flexure=spat_flexure)

# Determine the scale of the image
med = np.median(frame)
Expand Down Expand Up @@ -210,7 +212,7 @@ def initialize(cls, det, frame, slits, pypeline, spectrograph, outname="skyregio
# Initialise the object finding window and display to screen
fig.canvas.manager.set_window_title('PypeIt - Sky regions')
srgui = SkySubGUI(fig.canvas, image, frame, outname, det, slits, axes, pypeline, spectrograph,
printout=printout, runtime=runtime, initial=initial, flexure=flexure, overwrite=overwrite)
printout=printout, runtime=runtime, initial=initial, spat_flexure=spat_flexure, overwrite=overwrite)
plt.show()

return srgui
Expand Down
2 changes: 1 addition & 1 deletion pypeit/scripts/skysub_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def main(args):
# Finally, initialise the GUI
skyreg = SkySubGUI.initialize(det, frame, slits, pypeline, specname, outname=regfile,
overwrite=args.overwrite, runtime=False, printout=True,
initial=args.initial, flexure=spat_flexure)
initial=args.initial, spat_flexure=spat_flexure)

# Get the results
msskyreg = skyreg.get_result()
Expand Down
8 changes: 4 additions & 4 deletions pypeit/slittrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def get_slitlengths(self, initial=False, median=False):
slitlen = right - left
return np.median(slitlen, axis=1) if median else slitlen

def get_radec_image(self, wcs, alignSplines, tilts, slit_compute=None, slice_offset=None, initial=False, flexure=None):
def get_radec_image(self, wcs, alignSplines, tilts, slit_compute=None, slice_offset=None, initial=False, spat_flexure=None):
"""Generate an RA and DEC image for every pixel in the frame
NOTE: This function is currently only used for SlicerIFU reductions.
Expand All @@ -504,8 +504,8 @@ def get_radec_image(self, wcs, alignSplines, tilts, slit_compute=None, slice_off
is set to 0.0.
initial : bool
Select the initial slit edges?
flexure : float, optional
If provided, offset each slit by this amount.
spat_flexure : float, optional
If provided, offset each slit in the spatial direction by this amount.
Returns
-------
Expand Down Expand Up @@ -542,7 +542,7 @@ def get_radec_image(self, wcs, alignSplines, tilts, slit_compute=None, slice_off
decimg = np.zeros((self.nspec, self.nspat))
minmax = np.zeros((self.nslits, 2))
# Get the slit information
slitid_img_init = self.slit_img(pad=0, initial=initial, spat_flexure=flexure)
slitid_img_init = self.slit_img(pad=0, initial=initial, spat_flexure=spat_flexure)
for slit_idx, spatid in enumerate(self.spat_id):
if slit_idx not in slit_compute:
continue
Expand Down

0 comments on commit 5a4c0c4

Please sign in to comment.