"""
Module for JWST NIRCAM WFSS specific methods.
.. include:: ../include/links.rst
"""
import glob
import numpy as np
from astropy.io import fits
from astropy.time import Time
from pypeit import msgs
from pypeit import telescopes
from pypeit.core import framematch
from pypeit.par import pypeitpar
from pypeit.spectrographs import spectrograph
from pypeit.core import parse
from pypeit.images import detector_container
from IPython import embed
[docs]
class JWSTNIRCamSpectrograph(spectrograph.Spectrograph):
"""
Child to handle JWST/NIRCAM WFSS specific code
"""
ndet = 2
name = 'jwst_nircam'
header_name = 'jwst_nircam'
telescope = telescopes.JWSTTelescopePar()
camera = 'NIRCAM'
url = 'https://jwst-docs.stsci.edu/jwst-near-infrared-camera/nircam-observing-modes/nircam-wide-field-slitless-spectroscopy'
supported = False
[docs]
def get_detector_par(self, det, hdu=None):
"""
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
NIRCAM. The optional use of ``hdu`` is only viable for
automatically generated documentation.
Args:
det (:obj:`int`):
1-indexed detector number.
hdu (`astropy.io.fits.HDUList`_, optional):
The open fits file with the raw image of interest. If not
provided, frame-dependent parameters are set to a default.
Returns:
:class:`~pypeit.images.detector_container.DetectorContainer`:
Object with the detector metadata.
"""
# TODO Fill in values for NIRCAM
# Detector 1, i.e. A5
# https://jwst-docs.stsci.edu/jwst-near-infrared-camera/nircam-instrumentation/nircam-detector-overview/nircam-detector-performance
detector_dict1 = dict(
binning='1,1',
det=1,
dataext=0,
specaxis=1,
specflip=False,
spatflip=False,
xgap=0.,
ygap=0.,
ysize=1.,
platescale=0.063,
darkcurr=120.6, # e-/pixel/hour (=0.0335 e-/pixel/s)
saturation=59200.,
nonlinear=0.95, # need to look up and update
mincounts=-1e10,
numamplifiers=1,
gain=np.atleast_1d(1.84),
ronoise=np.atleast_1d(8.55), # This is in 1000s, its complicated
datasec=None,
oscansec=None
)
# Detector 2
detector_dict2 = detector_dict1.copy()
detector_dict2.update(dict(
det=2,
dataext=0,
darkcurr=126.0, # e-/pixel/hour (=0.035 e-/pixel/s)
saturation=58500.,
gain=np.atleast_1d(1.80),
ronoise=np.atleast_1d(8.57),
))
detector_dicts = [detector_dict1, detector_dict2]
return detector_container.DetectorContainer(**detector_dicts[det-1])
[docs]
@classmethod
def default_pypeit_par(cls):
"""
Return the default parameters to use for this instrument.
Returns:
:class:`~pypeit.par.pypeitpar.PypeItPar`: Parameters required by
all of PypeIt methods.
"""
par = super().default_pypeit_par()
# Reduce
par['reduce']['trim_edge'] = [0,0]
# Object finding
par['reduce']['findobj']['find_trim_edge'] = [0,0]
par['reduce']['findobj']['maxnumber_sci'] = 2
par['reduce']['findobj']['snr_thresh'] = 10.0
par['reduce']['findobj']['trace_npoly'] = 5
par['reduce']['findobj']['snr_thresh'] = 10.0
par['reduce']['findobj']['find_fwhm'] = 2.0
# Sky-subtraction
par['reduce']['skysub']['bspline_spacing'] = 1.2 # JWST sky is smooth
par['reduce']['skysub']['max_mask_frac'] = 0.95
par['reduce']['skysub']['mask_by_boxcar'] = False
par['reduce']['skysub']['sky_sigrej'] = 4.0
# Extraction
par['reduce']['extraction']['model_full_slit'] = True
par['reduce']['extraction']['sn_gauss'] = 6.0
par['reduce']['extraction']['boxcar_radius'] = 0.25 # extent in calwebb is 0.55" source and on NIRSpec website
par['reduce']['extraction']['use_2dmodel_mask'] = False # Don't use 2d mask in local skysub
# Cosmic ray rejection parameters for science frames
par['scienceframe']['process']['sigclip'] = 5.0
par['scienceframe']['process']['objlim'] = 2.0
par['scienceframe']['process']['mask_cr'] = False # Turn off for now since we coadd.
# Skip reference frame correction for now.
par['calibrations']['wavelengths']['refframe'] = 'observed'
return par