JWInstrument¶
- class webbpsf.JWInstrument(*args, **kwargs)[source]¶
Bases:
SpaceTelescopeInstrument
Superclass for all JWST instruments
Attributes Summary
SIAF aperture name for detector pixel to sky coords transformations
Filename or fits.HDUList for JWST pupil OPD.
Methods Summary
calc_psf
([outfile, source, nlambda, ...])Compute a PSF.
get_opd_file_full_path
([opdfilename])Return full path to the named OPD file.
get_optical_system
([fft_oversample, ...])Return an OpticalSystem instance corresponding to the instrument as currently configured.
interpolate_was_opd
(array, newdim)Interpolates an input 2D array to any given size.
load_was_opd
(inputWasOpd[, size, save, filename])Load and interpolate an OPD from the WAS.
set_position_from_aperture_name
(aperture_name)Set the simulated center point of the array based on a named SIAF aperture.
visualize_wfe_budget
([slew_delta_time, ...])Display a visual WFE budget showing the various terms that sum into the overall WFE for a given instrument
Attributes Documentation
- aperturename¶
SIAF aperture name for detector pixel to sky coords transformations
- pupilopd = None¶
Filename or fits.HDUList for JWST pupil OPD.
This can be either a full absolute filename, or a relative name in which case it is assumed to be within the instrument’s
data/OPDs/
directory, or an actual fits.HDUList object corresponding to such a file. If the file contains a datacube, you may set this to a tuple (filename, slice) to select a given slice, or else the first slice will be used.
- telescope = 'JWST'¶
Methods Documentation
- calc_psf(outfile=None, source=None, nlambda=None, monochromatic=None, fov_arcsec=None, fov_pixels=None, oversample=None, detector_oversample=None, fft_oversample=None, overwrite=True, display=False, save_intermediates=False, return_intermediates=False, normalize='first', add_distortion=True, crop_psf=True)[source]¶
Compute a PSF. The result can either be written to disk (set outfile=”filename”) or else will be returned as a FITS HDUlist object.
Output sampling may be specified in one of two ways:
Set
oversample=
. This will use that oversampling factor beyond detector pixels for output images, and beyond Nyquist sampling for any FFTs to prior optical planes.set
detector_oversample=
andfft_oversample=
. This syntax lets you specify distinct oversampling factors for intermediate and final planes.
By default, both oversampling factors are set equal to 2.
- Parameters
- sourcesynphot.spectrum.SourceSpectrum or dict
specification of source input spectrum. Default is a 5700 K sunlike star.
- nlambdaint
How many wavelengths to model for broadband? The default depends on how wide the filter is: (5,3,1) for types (W,M,N) respectively
- monochromaticfloat, optional
Setting this to a wavelength value (in meters) will compute a monochromatic PSF at that wavelength, overriding filter and nlambda settings.
- fov_arcsecfloat
field of view in arcsec. Default=5
- fov_pixelsint
field of view in pixels. This is an alternative to fov_arcsec.
- outfilestring
Filename to write. If None, then result is returned as an HDUList
- oversample, detector_oversample, fft_oversampleint
How much to oversample. Default=4. By default the same factor is used for final output pixels and intermediate optical planes, but you may optionally use different factors if so desired.
- overwritebool
overwrite output FITS file if it already exists?
- displaybool
Whether to display the PSF when done or not.
- save_intermediates, return_intermediatesbool
Options for saving to disk or returning to the calling function the intermediate optical planes during the propagation. This is useful if you want to e.g. examine the intensity in the Lyot plane for a coronagraphic propagation.
- normalizestring
Desired normalization for output PSFs. See doc string for OpticalSystem.calc_psf. Default is to normalize the entrance pupil to have integrated total intensity = 1.
- add_distortionbool
If True, will add 2 new extensions to the PSF HDUlist object. The 2nd extension will be a distorted version of the over-sampled PSF and the 3rd extension will be a distorted version of the detector-sampled PSF.
- crop_psfbool
If True, when the PSF is rotated to match the detector’s rotation in the focal plane, the PSF will be cropped so the shape of the distorted PSF will match it’s undistorted counterpart. This will only be used for NIRCam, NIRISS, and FGS PSFs.
- Returns
- outfitsfits.HDUList
The output PSF is returned as a fits.HDUlist object. If
outfile
is set to a valid filename, the output is also written to that file.
Notes
More advanced PSF computation options (pupil shifts, source positions, jitter, …) may be set by configuring the
options
dictionary attribute of this class.
- get_opd_file_full_path(opdfilename=None)[source]¶
Return full path to the named OPD file.
- The OPD may be:
a local or absolute path,
or relative implicitly within an SI directory, e.g. $WEBBPSF_PATH/NIRCam/OPD
or relative implicitly within $WEBBPSF_PATH
This function handles filling in the implicit path in the latter cases.
- get_optical_system(fft_oversample=2, detector_oversample=None, fov_arcsec=2, fov_pixels=None, options=None)[source]¶
Return an OpticalSystem instance corresponding to the instrument as currently configured.
When creating such an OpticalSystem, you must specify the parameters needed to define the desired sampling, specifically the oversampling and field of view.
- Parameters
- fft_oversampleint
Oversampling factor for intermediate plane calculations. Default is 2
- detector_oversample: int, optional
By default the detector oversampling is equal to the intermediate calculation oversampling. If you wish to use a different value for the detector, set this parameter. Note that if you just want images at detector pixel resolution you will achieve higher fidelity by still using some oversampling (i.e. not setting
oversample_detector=1
) and instead rebinning down the oversampled data.- fov_pixelsfloat
Field of view in pixels. Overrides fov_arcsec if both set.
- fov_arcsecfloat
Field of view, in arcseconds. Default is 2
- Returns
- osyspoppy.OpticalSystem
an optical system instance representing the desired configuration.
- interpolate_was_opd(array, newdim)[source]¶
Interpolates an input 2D array to any given size.
- Parameters
- array: float
input array to interpolate
- newdim: int
new size of the 2D square array (newdim x newdim)
- Returns
- newopd: new array interpolated to (newdim x newdim)
- load_was_opd(inputWasOpd, size=1024, save=False, filename='new_was_opd.fits')[source]¶
Load and interpolate an OPD from the WAS.
Ingests a WAS OPD and interpolates it to the proper size for WebbPSF.
- Parameters
- HDUlist_or_filenamestring
Either a fits.HDUList object or a filename of a FITS file on disk
- size: int, optional
Desired size of the output OPD. Default is 1024.
- save: bool, optional
Save the interpolated OPD if True. Default is False.
- filenamestring, optional
Filename of the output OPD, if ‘save’ is True. Default is ‘new_was_opd.fits’.
- Returns
- HDUliststring
fits.HDUList object of the interpolated OPD
- set_position_from_aperture_name(aperture_name)[source]¶
Set the simulated center point of the array based on a named SIAF aperture. This will adjust the detector and detector position attributes.
- visualize_wfe_budget(slew_delta_time=<Quantity 14. d>, slew_case='EOL', ptt_only=False, verbose=True)[source]¶
Display a visual WFE budget showing the various terms that sum into the overall WFE for a given instrument
Compares a WebbPSF instrument instance with the JWST optical budget for that instrument
- Parameters
- instwebbpsf.JWInstrument
A JWST instrument instance
- slew_delta_timeastropy.Quantity time
Time duration for thermal slew model
- slew_casebasestring
‘BOL’ or ‘EOL’ for beginning of life or end of life thermal slew model. EOL is about 3x higher amplitude
- ptt_onlybool
When decomposing wavefront into controllable modes, use a PTT-only basis? The default is to use all controllable pose modes. (This is mostly a leftover debug option at this point, not likely useful in general)
- verbosebool
Be more verbose