spacetelescope/nircam_simulator

Name: nircam_simulator

Owner: Space Telescope Science Institute

Description: This code can be used to generate simulated NIRCam data

Created: 2017-11-08 13:58:01.0

Updated: 2018-05-18 14:32:14.0

Pushed: 2018-05-18 15:51:42.0

Homepage:

Size: 8574

Language: Jupyter Notebook

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

This repository contains code that can be used to generate simulated NIRCam data.

Installation

To install: python setup.py install

Dependencies

To simulate wide field slitless spectroscopy (WFSS) data: NIRCam_Gsim: to disperse imaging data GRISM_NIRCAM: NIRCam-specific grism configuration and sensitivity files GRISMCONF: grism dispersion polynomials

Background signals: JWST backgrounds: Generate JWST Exposure Time Calculator-type backgrounds (zodiacal+thermal)

Calibration pipeline: JWST calibration pipeline. Necessary if using raw dark current exposures as input. Optional otherwise.

Examples

See the notebooks in the “examples” subdirectory. There is one notebook for imaging simulations, one for WFSS simulations, and one for moving target (non-sidereal) simulations.

Functionality

The code needed to create simulated data is split into four general parts:

  1. Generate a “seed image”
  2. (OPTIONAL) to create WFSS data, disperse the seed image
  3. Prepare an existing dark current ramp
  4. Combine the seed image with the dark

More details on these steps are given below:

Generate a “seed image”

This portion of the code generates a “seed image” from either input source catalogs or an input large field-of-view observation (fits file).

The seed image is a noiseless countrate image containing all of the sources specified in the input catalogs. Sources are scaled to the requested magnitudes and placed in the appropriate location given the NIRCam distortion model.

The main input to the code is a yaml file (examples are in the 'inputs' subdirectory). This file contains more information than is actually needed to run the code, but the information is all needed to run the entire NIRCam Data Simulator, so for the moment we've kept all of the inputs.

To use the code:

1) From the command line: python catalog_seed_image.py myfile.yaml

2) Within python:

 nircam_simulator.nircam_simulator.scripts import catalog_seed_image as csi
= csi.Catalog_seed()
paramfile = 'myfile.yaml'
make_seed()

Outputs:

Multi-extension fits file with name ending in 'seed_image.fits', containing:

Extension 0: empty Extension 1: seed image Extension 2: segmentation map

Also, the seed image, segmentation map, and exposure info dictionary are available as: self.seedimage, self.seed_segmap, and self.seedinfo

Disperse the seed image

Requires multiple imaging seed images as input. Output is a single, dispersed seed image that can be passed to later simulator steps just as imaging seed images. See WFSS notebook for an example.

To use:

 NIRCAM_Gsim.grism_seed_disperser import Grism_seed
sing_filter = 'F444W'
le = 'A'    # 'A' or 'B'
ction = 'R' # 'R' for row or 'C' for column
e_seeds = [seed1.seed_file, seed2.seed_file, seed3.seed_file, seed4.seed_file]
e = 'mod{}_{}'.format(module.upper(),direction.upper())
= os.path.join(datadir,"GRISM_NIRCAM/")
ground_file = "{}_{}_back.fits".format(crossing_filter,dmode)
Grism_seed(image_seeds,crossing_filter,dmode,config_path=loc)
servation()
nalize(Back = background_file)
Prepare an existing dark current ramp

The input dark current exposure will be reorganized into the requested readout pattern (if possible). If the input is not a linearized exposure, then it will be run through the initial stages of the JWST calibration pipeline in order to linearize the data. This includes superbias subtraction and reference pixel subtraction, followed by the linearization step.

The signal associated with the superbias and reference pixels is saved along side the linearized dark ramp such that it can be added back in later, if the user requests a raw output ramp from the NIRCam Data Simulator.

Output:

The linearized dark current and zeroth frame as saved to a fits file that uses the name from the Output:file entry in the input yaml file and ending with '_linearizedDark.fits'.

These are also available as self.linDark and self.zeroModel

To use: python dark_prep.py myinputs.yaml

or:

 nircam_simulator.nircam_simluator.scripts import dark_prep
 = dark_prep.DarkPrep()
.paramfile = 'myinputs.yaml'
.prepare()
Combine the seed image with the dark

This step takes as input a seed image (with associated segmentation map) and a linearized dark current exposure.

The seed image is converted into a 4d signal ramp, and poisson noise, cosmic rays, and other detector effects are added.

The ramp is then reorganized into the requested readout pattern and added to the dark current ramp.

To use: python obs_generator.py myinputs.yaml

or:

 nircam_simulator.nircam_simulator.scripts import obs_generator
= obs_generator.Observation()
linDark = 'V42424024002P000000000112o_B5_F250M_uncal_linear_dark_prep_object.fits'
seed = 'V42424024002P000000000112o_B5_F250M_uncal_F250M_seed_image.fits'
paramfile = 'myinputs.yaml'
create()

To create a simulated exposure, string together all of the steps:

 nircam_simulator.nircam_simulator.scripts import catalog_seed_image
 nircam_simulator.nircam_simulator.scripts import dark_prep
 nircam_simulator.nircam_simulator.scripts import obs_generator

file = 'seed_catalog_test.yaml'
= catalog_seed_image.Catalog_seed()
paramfile = yamlfile
image, segmap, seedinfo = cat.make_seed()

dark_prep.DarkPrep()
ramfile = yamlfile
epare()

= obs_generator.Observation()
linDark = d.prepDark
seed = cat.seedimage 
segmap = cat.seed_segmap 
seedheader = cat.seedinfo 
.seed = 'V42424024002P000000000112o_B5_F250M_uncal_F250M_seed_image.fits'
paramfile = yamlfile
create()
Convenience Functions

imaging_pipeline.py - wrapper around the three steps needed to create an imaging mode simulated exposure. This also works for moving target simulations. Example use shown in the imaging notebook.

wfss_pipeline.py - wrapper around the steps needed to create an WFSS simulated exposure. Example use shown in the WFSS notebook.

yaml_generator.py - Beginning with an Astronomer's Proposal Tool (APT) file, create the yaml files necessary to simulate the entire proposal. Example use shown in the imaging and WFSS notebooks.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.