Pandeia Quickstart

This article describes how to create a default Pandeia calculation with "build_default_calc" or by importing a JSON file from the web UI, how to make basic configuration edits, how to run the calculation, and how to get commonly-used elements of the results. 

On this page

Creating a Pandeia observation requires a configuration dictionary, which is most easily created with either the "build_default_calcfunction, or by importing a JSON file created by the JWST ETC Web UI. Running a Pandeia calculation is relatively straightforward, and obtaining useful information (e.g. observation time, signal-to-noise, or saturation) from the calculation results is also relatively easy. Whilst there are more advanced operations that can be performed with Pandeia via python, a significant number of useful operations can be performed just by editing the default configuration.



Pandeia configuration files

Creating a Pandeia configuration dictionary

Importing a JSON configuration file from JWST ETC Web UI

When running the JWST ETC Web UI, at the bottom right of the page (when a calculation is selected) is a tabbed interface containing the option "Downloads". From this, it is possible to download your calculation result as a gzipped tar file. Inside the results is a file named "input.json", which contains the calculation parameters that were used in the calculation you prepared. It is possible to create a configuration dictionary from this file with the following python code (assuming that python is running in the directory containing input.json):

Importing JWST ETC Configuration JSON
import json
with open('input.json', 'r') as inf:
    calculation = json.loads(inf.read())

Once you have done this, "calculation" is a standard python dictionary of key-value pairs that you can change as you would for any other python dictionary (see examples below).

Creating a default configuration dictionary

You can create a Pandeia configuration dictionary by running the built-in Pandeia convenience function "build_default_calc". In order to do so, enter the following commands whilst running python from within your Pandeia environment:

Creating Default Pandeia Configuration
from pandeia.engine.calc_utils import build_default_calc
calculation = build_default_calc(<telescope>, <instrument>, <mode>)

where "telescope", "instrument", and "mode" are the telescope you are using (here "jwst"), the instrument (one of "nircam", "miri", "niriss", or "nirspec"), and the observation mode of interest (see below for a list of modes).

Regardless of the values of "telescope", "instrument", and "mode", the "build_default_calc" function will create a scene with a single object. That object will be a point source with x and y offsets of zero, and a flat spectrum in f_nu normalized to 2.0 mjy at 0.001 microns. The source will have zero redshift, zero extinction, and no applied emission or absorption lines.

Three instrument modes have multiple possible data reduction strategies. For NIRSpec's IFU mode and MIRI's MRS mode, there are options of "ifunodinscene" (the default) and "ifunodoffscene"; for NIRSpec's MOS mode (called "msa" internally) there are options of "msafullapphot" (the default) and "specapphot". These can be set with a fourth option to "build_default_calc", so that it produces a properly configured calculation:

Select Data Reduction Strategy
calculation = build_default_calc("jwst", "nirspec", "msa", "specapphot")
calculation = build_default_calc("jwst", "miri", "mrs", "ifunodoffscene")

Editing Pandeia configuration files

Changing the observation filter

Changing Observation Filter
calculation['configuration']['instrument']['filter'] = <filter>

Where "filter" is the filter you wish to use (see below for a full list).

Changing the disperser

Changing Observation Disperser
calculation['configuration']['instrument']['disperser'] = <disperser>
calculation['configuration']['instrument']['filter'] = <matching_filter>

Where "disperser" is one of the available dispersers (see below), and <matching_filter> the filter that goes along with it (again, see below).

Changing the scene

Changing Scene
scene = {<dictionary_designing_scene>}
calculation['scene'][0] = scene

The "scene" in the configuration is a list of all the sources in the calculation. There are a number of examples of creating scene dictionaries below.



Running Pandeia

Once you have a configuration dictionary, running a Pandeia calculation on that dictionary may be done as follows:

Running Pandeia
from pandeia.engine.perform_calculation import perform_calculation
report = perform_calculation(calculation)



Pandeia Calculation Results

When run using its default parameters, Pandeia returns a python dictionary reporting on the results of the simulation. Amongst the useful contents of this dictionary are:

  • "report['warnings']" contains any warnings generated by the calculation
  • "report['input']" contains a copy of the configuration dictionary (which may be useful)
  • "report['scalar']" contains
    • The exposure time in "report['scalar']['exposure_time']"
    • The signal-to-noise ratio in "report['scalar']['sn']"
    • The extracted flux in "report['scalar']['extracted_flux']"
    • The extracted background counts in "report['scalar']['background']"



Appendices

Observing modes

  • MIRI
    • coronagraphy - (Coronagraphic Imaging)
    • imaging - (Imaging)
    • lrsslit - (Low Resolution Spectroscopy (LRS) Slit)
    • lrsslitless - (Low Resolution Spectroscopy (LRS) Slitless)
    • mrs - (Medium Resolution Spectroscopy (MRS))
    • target_acq - (Target Acquisition)
  • NIRCam
    • coronagraphy - (Coronagraphic Imaging)
    • lw_imaging - (Long Wavelength Imaging)
    • sw_imaging - (Short Wavelength Imaging)
    • ssgrism - (Time Series Grism)
    • wfgrism - (Wide Field Slitless Spectroscopy)
    • target_acq - (Target Acquisition)
  • NIRISS
    • imaging - (Imaging)
    • soss - (SOSS)
    • wfss - (WFSS)
    • ami - (AMI)
    • target_acq - (Target Acqusition)
  • NIRSpec
    • msa - (Multi-Object Spectroscopy)
    • fixed_slit - (Fixed Slit/BOTS)
    • ifu - (IFU)
    • target_acq - (Target Acquisition)

Observation filters

  • MIRI
    • F560W
    • F770W
    • F1000W
    • F1130W
    • F1280W
    • F1500W
    • F1800W
    • F2100W
    • F2550W
  • NIRCam
    • Short Wavelength
      • F070W
      • F090W
      • F115W
      • F140M
      • F150W
      • F162M
      • F164N
      • F182M
      • F187N
      • F200W
      • F210M
      • F212N
    • Long Wavelength
      • F250M 
      • F277W
      • F300M
      • F323N
      • F335M
      • F356W
      • F360M
      • F405N
      • F410M
      • F430M
      • F444W
      • F460M
      • F466N
      • F470N
      • F480M
  • NIRISS
    • F090W
    • F115W
    • F140M
    • F150W
    • F158M
    • F200W
    • F277W
    • F356W
    • F380M
    • F430M
    • F444W
    • F480M
  • NIRSpec
    • F110W
    • F140X

Dispersers and associated filters

  • NIRCam
    • GRISMC
      • F250M
      • F277W
      • F300M
      • F322W2
      • F335M
      • F356W
      • F360M
      • F410M
      • F430M
      • F444W
      • F460M
      • F480M
    • GRISMR
      • F277W
      • F322W2
      • F356W
      • F444W
  • NIRISS
    • GR150R/GR150C
      • F090W
      • F115W
      • F140M
      • F150W
      • F158M
      • F200W
    • GR700XD: None
  • NIRSpec
    • G140H
      • F070LP
      • F100LP
    • G140M
      • F070LP
      • F100LP
    • G235H
      • F170LP
    • G235M
      • F170LP
    • G395H
      • F290LP
    • G395M
      • F290LP
    • PRISM
      • CLEAR



Sample code

Creating a Scene with a centered flat-spectrum point source normalized to 2 mJy at 2.5 μm

Scene: Flat Spectrum
# The following section is only needed if the PYSYN_CDBS environment variable is not already set.
# The PYSYN_CDBS environment variable should point to the path of the CDBS data files
import os
location_of_cdbs = "/path/to/cdbs/files"
os.environ['PYSYN_CDBS'] = location_of_cdbs
# End section 
 
# The following section is only needed if the pandeia_refdata environment variable is not already set
# The pandeia_refdata environment variable should point to the path of the pandeia reference data
import os
location_of_pandeia_refdata = "/path/to/pandeia/refdata"
os.environ['pandeia_refdata'] = location_of_pandeia_refdata
# End section

from pandeia.engine.calc_utils import build_default_calc
 
configuration = build_default_calc('jwst', 'nircam', 'sw_imaging')
scene = {}
scene['position'] = {'x_offset': 0., 'y_offset': 0., 'orientation': 0., 'position_parameters': ['x_offset', 'y_offset', 'orientation']}
scene['shape'] = {'geometry': 'point'}
scene['spectrum'] = {'name': 'Flat Source', 'spectrum_parameters': ['sed', 'normalization']}
scene['spectrum']['sed'] = {'sed_type': 'flat', 'unit': 'flam'}
scene['spectrum']['normalization'] = {'type': 'at_lambda', 'norm_wave': 2.5, 'norm_waveunit': 'um', 'norm_flux': 2., 'norm_fluxunit': 'mjy'}
configuration['scene'][0] = scene

Note that the supplied instrument and mode are examples intended for illustration only.

Creating a Scene with a 50,000 K blackbody spectrum gaussian extended source

Scene: Gaussian Extended Blackbody
# The following section is only needed if the PYSYN_CDBS environment variable is not already set.
# The PYSYN_CDBS environment variable should point to the path of the CDBS data files
import os
location_of_cdbs = "/path/to/cdbs/files"
os.environ['PYSYN_CDBS'] = location_of_cdbs
# End section 
 
# The following section is only needed if the pandeia_refdata environment variable is not already set
# The pandeia_refdata environment variable should point to the path of the pandeia reference data
import os
location_of_pandeia_refdata = "/path/to/pandeia/refdata"
os.environ['pandeia_refdata'] = location_of_pandeia_refdata
# End section

from pandeia.engine.calc_utils import build_default_calc

configuration = build_default_calc('jwst', 'nircam', 'sw_imaging')
scene = {}
scene['position'] = {'x_offset': 0., 'y_offset': 0., 'orientation': 0., 'position_parameters': ['x_offset', 'y_offset', 'orientation']}
scene['shape'] = {'geometry': 'gaussian2d', 'major': 3.5, 'minor': 1.5} #major and minor in arcseconds
scene['spectrum'] = {'name': 'Blackbody Source', 'spectrum_parameters': ['sed', 'normalization']}
scene['spectrum']['sed'] = {'sed_type': 'blackbody', 'temp': 50000.}
scene['spectrum']['normalization'] = {'type': 'photsys', 'bandpass': 'bessel,j', 'norm_flux': 20., 'norm_fluxunit': 'abmag'}
configuration['scene'][0] = scene

Note that, again, the supplied instrument and mode are intended for illustration only.

Creating and observing a scene with Pandeia

Full Example
# The following section is only needed if the PYSYN_CDBS environment variable is not already set.
# The PYSYN_CDBS environment variable should point to the path of the CDBS data files
import os
location_of_cdbs = "/path/to/cdbs/files"
os.environ['PYSYN_CDBS'] = location_of_cdbs
# End section 
 
# The following section is only needed if the pandeia_refdata environment variable is not already set
# The pandeia_refdata environment variable should point to the path of the pandeia reference data
import os
location_of_pandeia_refdata = "/path/to/pandeia/refdata"
os.environ['pandeia_refdata'] = location_of_pandeia_refdata
# End section

from pandeia.engine.calc_utils import build_default_calc
from pandeia.engine.perform_calculation import perform_calculation

configuration = build_default_calc('jwst', 'miri', 'imaging')
scene = {}
scene['position'] = {'x_offset': 0., 'y_offset': 0., 'orientation': 0., 'position_parameters': ['x_offset', 'y_offset', 'orientation']}
scene['shape'] = {'geometry': 'point'}
scene['spectrum'] = {'name': 'Phoenix Spectrum', 'spectrum_parameters': ['sed', 'normalization']}
scene['spectrum']['sed'] = {'sed_type': 'phoenix', 'key': 'g2v'}
scene['spectrum']['normalization'] = {'type': 'jwst', 'bandpass': 'miri,imaging,f560w', 'norm_flux': 2., 'norm_fluxunit': 'mjy'}
configuration['scene'][0] = scene
configuration['configuration']['instrument']['filter'] = 'f1000w'
 
report = perform_calculation(configuration)
print(report['scalar']['sn'])

The resulting output is 944.8801195627884.




Published

 

Latest updates

  • Updated for ETC v1.3