Page History
...
The Pandeia Engine is a Python module (compatible with Python 3.6 8 and later) that functions as the computational engine of the JWST ETC and Roman ETC. It can be imported and run as a standalone module.
Warning | ||
---|---|---|
| ||
The Pandeia Engine API may change at any time. The following information and examples are for Pandeia Engine 3.1.6.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. |
The engine itself can be run with the command
Engine inputs take the form of a hierarchical 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 Pandeia Webapp download files (as a JSON-formatted file named input.json, suitable for reading in with the built-in Python 'json' module). Alternatively, default versions of calculations can be created with the function build_default_calc() and then edited (this is the only option for Roman Space Telescope calculations)
Warning | ||
---|---|---|
| ||
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 will generally not warn about unexpected keywords. By design, the Engine does not validate inputs: setups that may not be permitted in the Webapp or in APT may compute, but we do not and cannot guarantee the validity of the results. |
Create a default calculation
Code Block | ||||
---|---|---|---|---|
| ||||
from pandeia.engine import calc_utils
| ||||
Code Block | ||||
| ||||
from pandeia.engine import perform_calculation result perform_calculation calculation = 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
Load a calculation from the JWST Webapp
Calculation downloads from the JWST Pandeia Webapp contain the engine inputs in a JSON-formatted text file called input.json.
Code Block | ||||
---|---|---|---|---|
| ||||
from pandeia.engine import calc_utils
calculation = calc_utils.build_default_calc("jwst","nircam","sw_imaging") |
...
| |
import json
from pandeia.engine import 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 Pandeia Webapp.
Full API
The full API documentation, with all possible options and combinations for any instrument, can be found in this file. engine_input_api_3.1.rst
Examples
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)
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
{ "background": "minzodi", "background_level": "benchmark", "calculation": { "effects": { "saturation": null }, "noise": { "effectscrs": {null, "saturationdark": null, } "excess": null, "noiseffnoise": {null, "crsreadnoise": null, "ffnoisescatter": null } }, "configuration": { "detector": { "nexp": 1, "ngroup": 10, "nint": 1, "readout_pattern": "rapid", "subarray": "full" }, "instrument": { "aperture": "sw", "disperser": null, "filter": "f070w", "instrument": "nircam", "mode": "sw_imaging" } }, "scene": [ { "position": { "orientation": 0.0, "x_offset": 0.0, "y_offset": 0.0 }, "shape": { "geometry": "point" }, "spectrum": { "extinction": { "bandpass": "j", "law": "mw_rv_31", "unit": "mag", "value": 0.0 }, "lines": [], "name": "generic source", "normalization": { "norm_flux": 0.001, "norm_fluxunit": "mjy", "norm_wave": 2.0, "norm_waveunit": "microns", "type": "at_lambda" }, "redshift": 0.0, "sed": { "sed_type": "flat", "unit": "fnu", "z": 0.0 } } } ], "strategy": { "aperture_size": 0.1, "background_subtraction": true, "display_string": "Imaging Aperture Photometry", "is_aperture_ee": false, "method": "imagingapphot", "sky_annulus": [ 0.22, 0.4 ], "target_source": "1", "target_type": "coords", "target_xy": [ 0.0, 0.0 ], "units": "arcsec" } } |
The following dictionary defines a Roman WFI Imaging observation with the F062 filter, 1024x1024 defocus_small subarray (for a similar 3.66s read time to what is expected for Roman WFI Imaging), medium8 readout pattern, and 6 groups; for a 0.001 mJy flat-spectrum point source (in fnu) intended to be observed with a 0.2" aperture.
(click here to download as a JSON file: anyimaging_f062_hlwas_medium8imaging_1024x1024full.jeng)
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
{ "background": "minzodi", "background_level": "benchmark", "calculation": { { "backgroundeffects": { "minzodi", "saturation": null }, "background_levelnoise": "benchmark", { "calculationcrs": { null, "effectsdark": {null, "saturationexcess": null, }, "noiseffnoise": {null, "crsreadnoise": null, "ffnoisescatter": null } }, "configuration": { "detector": { "nexpma_table_name": 1, "ngroup": 6"hlwas_imaging", "nintnexp": 1, "readout_patternnresultants": "medium8"5, "subarray": "1024x1024full" }, "instrument": { "aperture": "anyimaging", "disperser": null, "filter": "f062", "instrument": "wfi", "mode": "imaging" } }, "scene": [ { "position": { "orientation": 0.0, "x_offset": 0.0, "y_offset": 0.0 }, "shape": { "geometry": "point" }, "spectrum": { "extinction": { "bandpass": "j", "law": "mw_rv_31", "unit": "mag", "value": 0.0 }, "extinction_first": true, "lines": [], "name": "generic source", "normalization": { "norm_flux": 0.001, "norm_fluxunit": "mjy", "norm_wave": 2.0, "norm_waveunit": "microns", "type": "at_lambda" }, "redshift": 0.0, "sed": { "sed_type": "flat", "unit": "fnu", "z": 0.0 } } } ], "strategy": { "aperture_size": 0.2, "background_subtraction": true, "display_string": "Imaging Aperture Photometry", "is_aperture_ee": false, "method": "imagingapphot", "sky_annulus": [ 0.4, 0.6 ], "target_source": "1", "target_type": "coords", "target_xy": [ 0.0, 0.0 ], "units": "arcsec" } } |