JWInstrument

class webbpsf.JWInstrument(*args, **kwargs)[source]

Bases: webbpsf.webbpsf_core.SpaceTelescopeInstrument

Superclass for all JWST instruments

telescope : name of telescope pupilopd : filename or FITS file object

include_si_wfeboolean (default: True)

Should SI internal WFE be included in models? Requires the presence of si_zernikes_isim_cv3.fits in the WEBBPSF_PATH.

Attributes Summary

aperturename

SIAF aperture name for detector pixel to sky coords transformations

pupilopd

Filename or fits.HDUList for JWST pupil OPD.

telescope

Methods Summary

calc_psf([outfile, source, nlambda, ...])

Compute a PSF.

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.

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:

  1. 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.

  2. set detector_oversample= and fft_oversample=. This syntax lets you specify distinct oversampling factors for intermediate and final planes.

By default, both oversampling factors are set equal to 2.

More advanced PSF computation options (pupil shifts, source positions, jitter, …) may be set by configuring the options dictionary attribute of this class.

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.

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.

interpolate_was_opd(array, newdim)[source]

Interpolates an input 2D array to any given size.

array: float

input array to interpolate

newdim: int

new size of the 2D square array (newdim x newdim)

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.

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’.

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.