pypeit.spectrographs.keck_kcwi module
Implements KCWI-specific functions.
- class pypeit.spectrographs.keck_kcwi.KeckKCRMSpectrograph[source]
Bases:
KeckKCWIKCRMSpectrograph
Child to handle Keck/KCRM specific code
- camera = 'KCRM'
Name of the spectrograph camera or arm. This is used by specdb, so use that naming convention
- comment = 'Supported setups: RL, RM1, RM2, RH3; see :doc:`keck_kcwi`'
A brief comment or description regarding PypeIt usage with this spectrograph.
- classmethod default_pypeit_par()[source]
Return the default parameters to use for this instrument.
- Returns:
Parameters required by all of PypeIt methods.
- Return type:
- get_detector_par(det, hdu=None)[source]
Return metadata for the selected detector.
Warning
Many of the necessary detector parameters are read from the file header, meaning the
hdu
argument is effectively required for KCRM. The optional use ofhdu
is only viable for automatically generated documentation.- Parameters:
det (
int
) – 1-indexed detector number.hdu (astropy.io.fits.HDUList, optional) – The open fits file with the raw image of interest.
- Returns:
Object with the detector metadata.
- Return type:
- get_rawimage(raw_file, det)[source]
Read a raw KCRM data frame
- Parameters:
- Returns:
detector_par (
pypeit.images.detector_container.DetectorContainer
) – Detector metadata parameters.raw_img (numpy.ndarray) – Raw image for this detector.
hdu (astropy.io.fits.HDUList) – Opened fits file
exptime (
float
) – Exposure time read from the file headerrawdatasec_img (numpy.ndarray) – Data (Science) section of the detector as provided by setting the (1-indexed) number of the amplifier used to read each detector pixel. Pixels unassociated with any amplifier are set to 0.
oscansec_img (numpy.ndarray) – Overscan section of the detector as provided by setting the (1-indexed) number of the amplifier used to read each detector pixel. Pixels unassociated with any amplifier are set to 0.
- header_name = 'KCRM'
Name of the spectrograph camera or arm from the Header. Usually the INSTRUME card.
- init_meta()[source]
Define how metadata are derived from the spectrograph files.
That is, this associates the PypeIt-specific metadata keywords with the instrument-specific header cards using
meta
.
- static is_nasmask(hdr)[source]
Determine if a frame used nod-and-shuffle.
- Parameters:
hdr (astropy.io.fits.Header) – The header of the raw frame.
- Returns:
True if NAS used.
- Return type:
- name = 'keck_kcrm'
The name of the spectrograph. See Spectrographs for the currently supported spectrographs.
- raw_header_cards()[source]
Return additional raw header cards to be propagated in downstream output files for configuration identification.
The list of raw data FITS keywords should be those used to populate the
configuration_keys()
or are used inconfig_specific_par()
for a particular spectrograph, if different from the name of the PypeIt metadata keyword.This list is used by
subheader_for_spec()
to include additional FITS keywords in downstream output files.- Returns:
List of keywords from the raw data files that should be propagated in output files.
- Return type:
- url = 'https://www2.keck.hawaii.edu/inst/kcwi/'
Reference url
- class pypeit.spectrographs.keck_kcwi.KeckKCWIKCRMSpectrograph[source]
Bases:
Spectrograph
Parent to handle Keck/KCWI+KCRM specific code
Todo
Need to apply spectral flexure and heliocentric correction to waveimg – done?
Copy fast_histogram code into PypeIt?
Re-write flexure code with datamodel + implement spectral flexure QA in find_objects.py
When making the datacube, add an option to apply a spectral flexure correction from a different frame?
Write some detailed docs about the corrections that can be used when making a datacube
Consider introducing a new method (par[‘flexure’][‘spec_method’]) for IFU flexure corrections (see find-objects.py)
- bpm(filename, det, shape=None, msbias=None)[source]
Generate a default bad-pixel mask for KCWI and KCRM.
Even though they are both optional, either the precise shape for the image (
shape
) or an example file that can be read to get the shape (filename
usingget_image_shape()
) must be provided.- Parameters:
filename (
str
or None) – An example file to use to get the image shape.det (
int
) – 1-indexed detector number to use when getting the image shape from the example file.shape (tuple, optional) – Processed image shape Required if filename is None Ignored if filename is not None
msbias (numpy.ndarray, optional) – Processed bias frame used to identify bad pixels. This is ignored for KCWI.
- Returns:
An integer array with a masked value set to 1 and an unmasked value set to 0. All values are set to 0.
- Return type:
- calc_pattern_freq(frame, rawdatasec_img, oscansec_img, hdu)[source]
Calculate the pattern frequency using the overscan region that covers the overscan and data sections. Using a larger range allows the frequency to be pinned down with high accuracy.
NOTE: The amplifiers are arranged as follows:
(0,ny) ——— (nx,ny)| 3 | 4 |———| 1 | 2 |(0,0) ——— (nx, 0)Todo
PATTERN FREQUENCY ALGORITHM HAS NOT BEEN TESTED WHEN BINNING != 1x1
- Parameters:
frame (numpy.ndarray) – Raw data frame to be used to estimate the pattern frequency.
rawdatasec_img (numpy.ndarray) – Array the same shape as
frame
, used as a mask to identify the data pixels (0 is no data, non-zero values indicate the amplifier number).oscansec_img (numpy.ndarray) – Array the same shape as
frame
, used as a mask to identify the overscan pixels (0 is no data, non-zero values indicate the amplifier number).hdu (astropy.io.fits.HDUList) – Opened fits file.
- Returns:
patt_freqs – List of pattern frequencies.
- Return type:
- check_frame_type(ftype, fitstbl, exprng=None)[source]
Check for frames of the provided type.
- Parameters:
ftype (
str
) – Type of frame to check. Must be a valid frame type; see frame-type Definitions.fitstbl (astropy.table.Table) – The table with the metadata for one or more frames to check.
exprng (
list
, optional) – Range in the allowed exposure time for a frame of typeftype
. Seepypeit.core.framematch.check_frame_exptime()
.
- Returns:
Boolean array with the flags selecting the exposures in
fitstbl
that areftype
type frames.- Return type:
- compound_meta(headarr, meta_key)[source]
Methods to generate metadata requiring interpretation of the header data, instead of simply reading the value of a header card.
- Parameters:
headarr (
list
) – List of astropy.io.fits.Header objects.meta_key (
str
) – Metadata keyword to construct.
- Returns:
Metadata value read from the header(s).
- Return type:
- config_specific_par(scifile, inp_par=None)[source]
Modify the PypeIt parameters to hard-wired values used for specific instrument configurations.
- Parameters:
scifile (
str
) – File to use when determining the configuration and how to adjust the input parameters.inp_par (
ParSet
, optional) – Parameter set used for the full run of PypeIt. If None, usedefault_pypeit_par()
.
- Returns:
The PypeIt parameter set adjusted for configuration specific parameter values.
- Return type:
- configuration_keys()[source]
Return the metadata keys that define a unique instrument configuration.
This list is used by
PypeItMetaData
to identify the unique configurations among the list of frames read for a given reduction.- Returns:
List of keywords of data pulled from file headers and used to constuct the
PypeItMetaData
object.- Return type:
- classmethod default_pypeit_par()[source]
Return the default parameters to use for this instrument.
- Returns:
Parameters required by all of PypeIt methods.
- Return type:
- get_datacube_bins(slitlength, minmax, num_wave)[source]
Calculate the bin edges to be used when making a datacube.
- Parameters:
slitlength (
int
) – Length of the slit in pixelsminmax (numpy.ndarray) – An array with the minimum and maximum pixel locations on each slit relative to the reference location (usually the centre of the slit). Shape must be \((N_{\rm slits},2)\), and is typically the array returned by
get_radec_image()
.num_wave (
int
) –- Number of wavelength steps. Given by::
int(round((wavemax-wavemin)/delta_wave))
:param
tuple
: Three 1D numpy.ndarray providing the bins to use :param when constructing a histogram of the spec2d files. The elements: :param are \(: :type are :math:\): x,y,lambda
- get_lamps_status(headarr)[source]
Return a string containing the information on the lamp status.
- Parameters:
headarr (
list
) – A list of 1 or more astropy.io.fits.Header objects.- Returns:
A string that uniquely represents the lamp status.
- Return type:
- get_wcs(hdr, slits, platescale, wave0, dwv, spatial_scale=None)[source]
Construct/Read a World-Coordinate System for a frame.
- Parameters:
hdr (astropy.io.fits.Header) – The header of the raw frame. The information in this header will be extracted and returned as a WCS.
slits (
SlitTraceSet
) – Slit traces.platescale (
float
) – The platescale of an unbinned pixel in arcsec/pixel (e.g. detector.platescale). See also ‘spatial_scale’wave0 (
float
) – The wavelength zeropoint.dwv (
float
) – Change in wavelength per spectral pixel.spatial_scale (
float
, None, optional) – The spatial scale (units=arcsec/pixel) of the WCS to be used. This variable is fixed, and is independent of the binning. If spatial_scale is set, it will be used for the spatial size of the WCS and the platescale will be ignored. If None, then the platescale will be used.
- Returns:
The world-coordinate system.
- Return type:
- init_meta()[source]
Define how metadata are derived from the spectrograph files.
That is, this associates the PypeIt-specific metadata keywords with the instrument-specific header cards using
meta
.
- lamps(fitstbl, status)[source]
Check the lamp status.
- Parameters:
fitstbl (astropy.table.Table) – The table with the fits header meta data.
status (
str
) – The status to check. Can be'off'
,'arcs'
, or'dome'
.
- Returns:
A boolean array selecting fits files that meet the selected lamp status.
- Return type:
- Raises:
ValueError – Raised if the status is not one of the valid options.
- ndet = 1
Number of detectors for this instrument.
- pypeit_file_keys()[source]
Define the list of keys to be output into a standard PypeIt file.
- Returns:
The list of keywords in the relevant
PypeItMetaData
instance to print to the PypeIt Reduction File.- Return type:
- pypeline = 'SlicerIFU'
String used to select the general pipeline approach for this spectrograph.
- supported = True
Flag that PypeIt code base has been sufficiently tested with data from this spectrograph that it is officially supported by the development team.
- telescope = Parameter Value Default Type Callable ---------------------------------------------------------------- name KECK KECK str False longitude -155.47833333333335 None int, float False latitude 19.828333333333333 None int, float False elevation 4160.000000000756 None int, float False fratio 15 None int, float False diameter 10 None int, float False eff_aperture 72.3674 None int, float False
Instance of
TelescopePar
providing telescope-specific metadata.
- class pypeit.spectrographs.keck_kcwi.KeckKCWISpectrograph[source]
Bases:
KeckKCWIKCRMSpectrograph
Child to handle Keck/KCWI specific code
- camera = 'KCWI'
Name of the spectrograph camera or arm. This is used by specdb, so use that naming convention
- comment = 'Supported setups: BL, BM, BH2, BH3; see :doc:`keck_kcwi`'
A brief comment or description regarding PypeIt usage with this spectrograph.
- classmethod default_pypeit_par()[source]
Return the default parameters to use for this instrument.
- Returns:
Parameters required by all of PypeIt methods.
- Return type:
- fit_2d_det_response(det_resp, gpmask)[source]
Perform a 2D model fit to the KCWI detector response. A few different setups were inspected (BH2 & BM with different grating angles), and a very similar response pattern was found for all setups, indicating that this structure is something to do with the detector. The starting parameters and functional form are assumed to be sufficient for all setups.
- Parameters:
det_resp (numpy.ndarray) – An image of the flatfield structure.
gpmask (numpy.ndarray) – Good pixel mask (True=good), the same shape as ff_struct.
- Returns:
A model fit to the flatfield structure.
- Return type:
- get_detector_par(det, hdu=None)[source]
Return metadata for the selected detector.
Warning
Many of the necessary detector parameters are read from the file header, meaning the
hdu
argument is effectively required for KCWI. The optional use ofhdu
is only viable for automatically generated documentation.- Parameters:
det (
int
) – 1-indexed detector number.hdu (astropy.io.fits.HDUList, optional) – The open fits file with the raw image of interest.
- Returns:
Object with the detector metadata.
- Return type:
- get_rawimage(raw_file, det)[source]
Read a raw KCWI data frame
NOTE: The amplifiers are arranged as follows:
(0,ny) ——— (nx,ny)| 3 | 4 |———| 1 | 2 |(0,0) ——— (nx, 0)- Parameters:
- Returns:
detector_par (
pypeit.images.detector_container.DetectorContainer
) – Detector metadata parameters.raw_img (numpy.ndarray) – Raw image for this detector.
hdu (astropy.io.fits.HDUList) – Opened fits file
exptime (
float
) – Exposure time read from the file headerrawdatasec_img (numpy.ndarray) – Data (Science) section of the detector as provided by setting the (1-indexed) number of the amplifier used to read each detector pixel. Pixels unassociated with any amplifier are set to 0.
oscansec_img (numpy.ndarray) – Overscan section of the detector as provided by setting the (1-indexed) number of the amplifier used to read each detector pixel. Pixels unassociated with any amplifier are set to 0.
- header_name = 'KCWI'
Name of the spectrograph camera or arm from the Header. Usually the INSTRUME card.
- init_meta()[source]
Define how metadata are derived from the spectrograph files.
That is, this associates the PypeIt-specific metadata keywords with the instrument-specific header cards using
meta
.
- static is_nasmask(hdr)[source]
Determine if a frame used nod-and-shuffle.
- Parameters:
hdr (astropy.io.fits.Header) – The header of the raw frame.
- Returns:
True if NAS used.
- Return type:
- name = 'keck_kcwi'
The name of the spectrograph. See Spectrographs for the currently supported spectrographs.
- raw_header_cards()[source]
Return additional raw header cards to be propagated in downstream output files for configuration identification.
The list of raw data FITS keywords should be those used to populate the
configuration_keys()
or are used inconfig_specific_par()
for a particular spectrograph, if different from the name of the PypeIt metadata keyword.This list is used by
subheader_for_spec()
to include additional FITS keywords in downstream output files.- Returns:
List of keywords from the raw data files that should be propagated in output files.
- Return type:
- scattered_light_archive(binning, dispname)[source]
Archival model parameters for the scattered light. These are based on best fits to currently available data.
For KCWI, the main contributor to the scattered light is referred to as the “narcissistic ghost” by Morrissey et al. (2018), ApJ, 864, 93. This scattered light is thought to be a reflection off the detector that travels back through the optical system. Some fraction gets sent back out to space, while the remained comes back through the optical system and a fuzzy version of this is re-imaged onto the detector. The current KCWI scattered light model is designed to account for these effects.
- Parameters:
- Returns:
x0 (numpy.ndarray) – A 1D array containing the best-fitting model parameters
bounds (
tuple
) – A tuple of two elements, containing two numpy.ndarray of the same length as x0. These two arrays contain the lower (first element of the tuple) and upper (second element of the tuple) bounds to consider on the scattered light model parameters.
- url = 'https://www2.keck.hawaii.edu/inst/kcwi/'
Reference url