WebbPSF Tutorials

This article provides basic examples of how to use WebbPSF . We also provide information on additional Jupyter Notebooks and narrative documentation that further demonstrate the usage of the Roman functionality with WebbPSF



In addition to the examples provided below, the WebbPSF GitHub repository offers many tutorials, including one specific to Roman, to help users get started. The foremost example is a Jupyter Notebook with a general demonstration of how to simulate, visualize, analyze, and export a point spread function (PSF) for the Roman Wide Field Instrument (WFI). To run the tutorials on your system, please follow the installation instructions from the readthedocs documentation

The readthedocs documentation's dedicated page on the Roman Instrument Model contains several more detailed usage examples alongside narrative text explaining how all of the functionality comes together. Readers with previous experience using the JWST modes of WebbPSF should note the differences highlighted for Roman simulations.

Warning

While the GitHub repository for WebbPSF also offers a Jupyter Notebook that demonstrates usage of its class for the Roman Coronagraph Instrument, we warn the reader that WebbPSF's Coronagraph model was developed as a prototype and has not been actively updated or developed since 2017.




Example 1: PSF with Default Parameters

import matplotlib.pyplot as plt
import webbpsf

plt.rcParams['figure.figsize'] = (8, 10) # Make the default figure size larger
plt.rcParams['image.interpolation'] = 'nearest' # Don't blur/smooth image plots

wfi = webbpsf.roman.WFI()

default_psf = wfi.calc_psf(display=True)

Figure of WFI F062 PSF from WebbPSF 

WebbPSF for Roman: PSF with default parameters.

The simulated PSF in detector pixels can be displayed and saved using the following calls:

webbpsf.display_psf(default_psf, ext='DET_SAMP')

default_psf.writeto('./test_PSF.fits', overwrite=True)

Figure of WFI PSF in Detector Pixels 

WebbPSF for Roman: Displaying the PSF in detector pixels.






Example 2: PSF with various specified parameters 

import matplotlib.pyplot as plt
import webbpsf

plt.rcParams['figure.figsize'] = (8, 10) # Make the default figure size larger
plt.rcParams['image.interpolation'] = 'nearest' # Don't blur/smooth image plots

wfi = webbpsf.roman.WFI()

wfi.filter = 'GRISM1'
wfi.detector = 'SCA14'
wfi.detector_position = (1024, 1024)

src = webbpsf.specFromSpectralType('G0V', catalog='phoenix')

poly_psf = wfi.calc_psf(source=src, nlambda=10, display=True)

Figure of WFI Grism PSF from WebbPSF

WebbPSF for Roman: Specifying a few parameters.





Example 3: PSF Profile & Encircled Energy 

WebbPSF also includes functions for measuring encircled energy, profiles, and centroids (described in the WebbPSF documentation and the POPPY documentation). Below, we measure the radial profile and encircled energy curve for the polychromatic PSF. Note that the FWHM is also computed and labeled on the radial profile plot.

import matplotlib.pyplot as plt
import webbpsf
  
wfi = webbpsf.roman.WFI()

wfi.filter = 'GRISM1'
wfi.detector = 'SCA14'
wfi.detector_position = (1024, 1024)

src = webbpsf.specFromSpectralType('G0V', catalog='phoenix')

poly_psf = wfi.calc_psf(source=src, nlambda=10, display=False)

webbpsf.display_profiles(poly_psf)

Figure of PSF Profile and Encircled Energy Plots 

WebbPSF for Roman: PSF Profile (top) and Encircled Energy (bottom)





For additional questions not answered in this article, please contact the Roman Help Desk at STScI. You may also open an issue at the GitHub repository.




Latest Update

 

Updated for version 1.2.1.
Publication

 

Initial publication of the article.