Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added more detailed instructions

...

Warning
titleAPI Compatibility

The Pandeia Engine API may change at any time. The following information and examples are for Pandeia Engine 2.0.x only, and are not guaranteed to be accurate or functional for previous or future releases. Updates (and information about planned pending API changes) can be found on the Pandeia Engine News page.

...


Engine inputs take the form of a heirarchical Python dictionary describing, in different sections, the instrument setup, the scene with definitions of all sources within it, and the flux extraction strategy.

Such input dictionaries are available in JWST Webapp download files (as a JSON-formatted file named input.json, suitable for reading in with the built-in Python 'json' module), or default versions can be created with the function build_default_calc() and then edited (this is the only option for Roman Space Telescope calculations)

Warning
titleAPI Checking

The Pandeia Engine expects a specific hierarchical format, but does not generally validate the format. It may silently replace missing or misplaced information with defaults, and it generally will not warn about keys in the wrong place.


Create a default calculation

Code Block
languagepy
titlePandeia Engine InputsCreate a default calculation
from pandeia.engine import calc_utils
from pandeia.engine import perform_calculation

resultcalculation = calc_utils.build_default_calc("jwst","nircam","sw_imaging")
results = perform_calculation.perform_calculation(calculation)

where "calculation" is a hierarchical input dictionary describing a scene of sources, an instrument setup, and an extraction strategy, and "result" is a hierarchical output dictionary.

...

The command above produces the NIRCam SW Imaging calculation below, and then runs it through the engine. "results" will be a dictionary, defined in the Output API documentation

Warning
titleAPI Default

In the event that there is a typo in the mode name ("sw_imaging", above), the function will substitute the default mode for that instrument.

Load a calculation from the JWST Webapp

Calculation downloads from the JWST Webapp contain the engine inputs in a JSON-formatted text file called input.json.

Code Block
languagepy
titleCreate Load a default calculation from a file
import json
from pandeia.engine import calc_utils

calculation = calc_utils.build_default_calc("jwst","nircam","sw_imaging")

The command above produces the NIRCam SW Imaging calculation below.

...

titleAPI Default
 perform_calculation

with open("input.json") as infile:
    calculation = json.load(infile)

results = perform_calculation.perform_calculation(calculation)

The command above reads a file called "input.json" in the current directory, loads it into a Python dictionary, and runs it through the engine. "results" will be a dictionary, defined in the Output API documentation. Results should match the JWST Webapp

...

.


Full API


The full API documentation, with all possible options and combinations for any instrument, can be found in this link.

...

The following calculation defines a JWST NIRCam observation in SW Imaging mode using the full subarray and rapid readout pattern and f070w filter, for a flat-spectrum (in fnu) point source normalized to 0.001 mJy, intended to be observed with a 0.2" aperture. Note that it specifies a background precomputed for a specific date and celestial locationthe JWST minzodi benchmark position; actual user-configured backgrounds are available in the JWST web ETC Webapp (and can be downloaded from there)

...