pypeit.gui.binospec_ifu_extract module
Matplotlib GUI for interactively selecting fibers from a fiber-fed IFU spec1d file and extracting a combined 1D spectrum.
- class pypeit.gui.binospec_ifu_extract.BinospecIFUExtractGUI(fibers, raw_hdr, pyp_spec, outfile)[source]
Bases:
objectMatplotlib widget GUI for selecting fibers and extracting spectra.
Displays the IFU as a hexagonal flux map, lets the user select fibers by drawing a region or clicking, and writes the combined selection as a
OneSpecFITS file.- Parameters:
fibers (
listofdict) – Per-fiber records (seepypeit.core.datacube.load_fibers()), each carryingwave,flux,ivar,ra, anddec.raw_hdr (astropy.io.fits.Header) – Primary header of the source spec1d, copied to the output.
pyp_spec (
str) – Spectrograph short name, written asPYP_SPECon the output.outfile (
str) – Default output OneSpec FITS path.
- _default_save_path()[source]
Return a non-clobbering default output path.
Starts from
self.outfile(..._<base>.fits) and inserts a two-digit counter before the extension (..._<base>_00.fits), incrementing the counter until a path that does not already exist on disk is found.- Returns:
The first
..._<NN>.fitspath (NN starting at00) that does not yet exist.- Return type:
- _draw_spectrum()[source]
Redraw the extracted spectrum honoring the current display toggles.
On a log scale, non-positive flux values (e.g. sky-subtraction residuals) are masked so they neither appear in the trace nor distort the axis limits. When sky-line masking is enabled, pixels within
_SKY_LINE_MASK_HALFWIDTHof a line in_SKY_LINE_WAVELENGTHSare likewise masked.
- _get_fiber_mask()[source]
Return a boolean mask of fibers inside
self.selected_region.- Returns:
1D boolean array of length
self.nspec,Truefor fibers whose sky position falls within the currently drawn selection region. Returns all-Falseif no region is defined.- Return type:
- pypeit.gui.binospec_ifu_extract.compute_fiber_fluxes(waves, fluxes, wave_min, wave_max)[source]
Per-fiber integrated flux with sky-line masking.
Each fiber is integrated over its own native wavelength grid, with pixels in any sky-line region (see
_SKY_LINE_WAVELENGTHS) excluded. Used to colour the fiber-IFU extractor display; the actual extracted spectrum (pypeit.core.datacube.resample_and_combine()) is unaffected.- Parameters:
waves (
listof numpy.ndarray) – Per-fiber native wavelengths and fluxes (parallel lists).fluxes (
listof numpy.ndarray) – Per-fiber native wavelengths and fluxes (parallel lists).wave_min (
float) – Integration range, Angstrom.wave_max (
float) – Integration range, Angstrom.
- Returns:
1D array of integrated fluxes, one per fiber.
- Return type:
- pypeit.gui.binospec_ifu_extract.sky_line_mask(wave)[source]
Return a boolean mask that is
Trueinside any sky-line region.- Parameters:
wave (numpy.ndarray) – 1D array of wavelengths in Angstrom.
- Returns:
1D boolean array, same shape as
wave,Truewhere the wavelength falls within_SKY_LINE_MASK_HALFWIDTHof any line in_SKY_LINE_WAVELENGTHS.- Return type: