Roman I-Sim Tutorials

This article provides a few simple command-line examples of the basic functionalities of  Roman I-Sim . Users can find a more extensive list of tutorials and examples in the form of Python Jupyter notebooks on the Roman Research Nexus (RRN). Additional information is available from the tool's online documentation.

This documentation is written for  Roman I-Sim version 0.14.0 (released on May 14, 2026).

The purpose of these examples is to show how to: (1) use the command-line tool to generate a catalog of sources; (2) use the command-line tool to generate a simulated Level 2 (L2Roman WFI ASDF file based on the catalog; and (3) display the output image in python. For more examples covering other aspects of the simulation tool, including the Roman I-Sim creation of uncalibrated Level 1 (L1) images and astronomical scenes (called Level 3, L3 in Roman I-Sim , but not to be confused with the Level 3 data products created using romancal ), please visit the RNN and/or consult the readthedocs documentation.

Note

  • L1 WFI data contain uncalibrated ramp exposures in units of Digital Numbers (DN).  L1 files are three-dimensional data cubes, one dimension for time and two dimensions for image coordinates, that are shaped as arrays with N resultants, 4096 image rows, 4096 image columns. 
  • L2 WFI data contain calibrated rate images in units of DN per second (DN/s).  They are shaped as two-dimensional arrays with 4088 image rows, 4088 image columns.

 Additional details about the Roman data levels can be found on the WFI Data Levels and Products RDox article. 

Note

The RNN provides a self-consistent Python environment in which several software tools are consistently tested and work together in concert. Because of this, it might occasionally happens that the latest public version of  Roman I-Sim might not yet be present in the RNN. 

While there are multiple examples for using Roman I-Sim below, some additional details exist on the Roman Research Nexus (RRN). In the dedicated Roman I-Sim notebook, users will find a list of the following: 

  • Source Catalog Generation: explore how to create a Roman I-Sim -compatible source catalog using Gaia.
  • Image Generation: run a simulation with  Roman I-Sim to generate Level 2 products
  • Dithered Observations: create a set of dithered observations with Roman I-Sim
  • Parallelized Simulations: run multiple simulations in parallel using Dask
  • Simulating Dithered Observations in Parallel: use parallelized simulations to run multiple dithered observations
  • Injecting Sources into Level 2 Images: use Roman I-Sim to inject sources into L2 images




Example 1: Creating a Catalog of Gaia Sources

The command-line executable romanisim-gaia-catalog allows users to fetch Gaia sources at a user-specified specified R.A., Dec. location and within a defined cone radius. The program then estimates Roman fluxes in the 8 imaging optical elements, accounts for proper motions if a specific epoch is set with the time argument, and saves the resulting catalog in a format compatible with  Roman I-Sim .

Using the arguments -h or --help will produce the following message at the prompt:

usage: romanisim-gaia-catalog [-h] [--radius RADIUS] ra dec time filename

Generate a romanisim input catalog from Gaia.

positional arguments:
  ra               right ascension (degree)
  dec              declination (degree)
  time             time (ISO 8601)
  filename         output catalog

options:
  -h, --help       show this help message and exit
  --radius RADIUS  find sources within this radius of query (default: None)

EXAMPLE: romanisim-gaia-catalog 270.0 66.0 2026-01-01T00:00:00 gaia.ecsv

Let's now use romanisim-gaia-catalog to create a generate a list of sources at location (R.A., Dec) = (6, -72) and within a cone radius of 0.5 degrees, which is around the Galactic globular cluster NGC 104, and save positions at epoch 2026-01-01T00:00:00 to a file called gaia-catalog_ngc104.ecsv:

Shell command
romanisim-gaia-catalog 6 -72 --radius 0.5 2016-01-01T00:00:00 gaia-catalog_ngc104.ecsv

Note

The filename argument is used by romanisim-gaia-catalog to validate the format of the output filename. Not all file formats are compatible with Roman I-Sim . We recommend users save their catalogs in ecsv (enhanced character-separated values) format.

Note

When the time argument is used, romanisim-gaia-catalog will output nan nan coordinate pairs for sources without valid proper motions in the Gaia catalog.

Warning

Because everything after the first dot in the filename string is used to validate the output file format, users should avoid using multiple dots in the output filename. For example, using filenames like "My.catalog.ecsv", will produce an error message.




Example 2: Generating a Simulated Image

The command-line executable romanisim-make-image allows users to simulate a Roman exposure given an input catalog of sources and other observation information such as where the telescope is pointing, the optical element to use, the MA table, etc.

Using the arguments -h or --help will produce the following message at the prompt:

usage: romanisim-make-image [-h] [--bandpass BANDPASS] [--boresight] [--catalog CATALOG] [--config CONFIG] [--date DATE] [--level LEVEL] [--ma_table_number MA_TABLE_NUMBER] [--nobj NOBJ] [--previous PREVIOUS] [--radec RADEC RADEC] [--rng_seed RNG_SEED] [--roll ROLL] [--sca SCA]
                            [--usecrds] [--psftype {epsf,galsim,stpsf}] [--webbpsf] [--stpsf] [--truncate TRUNCATE] [--pretend-spectral PRETEND_SPECTRAL] [--drop-extra-dq] [--scale-factor SCALE_FACTOR] [--extra-counts EXTRA_COUNTS [EXTRA_COUNTS ...]]
                            filename

Make a demo image.

positional arguments:
  filename              output image (asdf). {} and {bandpass} strings will be automatically populated with detector and bandpass information.

options:
  -h, --help            show this help message and exit
  --bandpass BANDPASS   bandpass to simulate (default: F087)
  --boresight           radec specifies location of boresight, not center of WFI. (default: False)
  --catalog CATALOG     input catalog (ecsv) (default: None)
  --config CONFIG       input parameter override file (yaml) (default: None)
  --date DATE           UTC Date and Time of observation to simulate in ISOT format. (default: 2026-01-01T00:00:00.000)
  --level LEVEL         1 or 2, for L1 or L2 output (default: 2)
  --ma_table_number MA_TABLE_NUMBER
  --nobj NOBJ
  --previous PREVIOUS   previous simulated file in chronological order used for persistence modeling. (default: None)
  --radec RADEC RADEC   ra and dec (deg) (default: None)
  --rng_seed RNG_SEED
  --roll ROLL           Position angle (North towards YIdl) measured at the V2Ref/V3Ref of the aperture used. (default: 0)
  --sca SCA             SCA to simulate. Use -1 to generate images for all SCAs; include {} in filename for this mode to indicate where the detector number should be filled, e.g. l1_{}.asdf (default: 7)
  --usecrds             Use CRDS references. (default: False)
  --psftype {epsf,galsim,stpsf}
                        Type of PSF generator to use. If None and --usecrds, then "epsf" will be used otherwise "galsim" is used. (default: galsim)
  --webbpsf             Use stpsf for PSF (deprecated, use `--psftype stpsf`) (default: False)
  --stpsf               Use stpsf for PSF (deprecated, use `--psftype stpsf`) (default: False)
  --truncate TRUNCATE   If set, truncate the MA table at given number of resultants. (default: None)
  --pretend-spectral PRETEND_SPECTRAL
                        Pretend the image is spectral. exposure.type and instrument.element are updated to be grism / prism. (default: None)
  --drop-extra-dq       Do not store the optional simulated dq array. (default: False)
  --scale-factor SCALE_FACTOR
                        Velocity aberration-induced scale factor. If negative, use given time to calculated based on orbit ephemeris. (default: -1.0)
  --extra-counts EXTRA_COUNTS [EXTRA_COUNTS ...]
                        An optional FITS file to read to get an array of counts to add into the simulated image. Useful for wrapping idealized images. If 2 arguments are sent in, then the second argument is assumed to be the HDU to use (default=0). (default: None)

EXAMPLE: romanisim-make-image output_image.asdf

Let's use romanisim-make-image to simulate a L2 image (with the argument --level 2) of the detector WFI01 (--sca 1) based on the Gaia-based catalog we created above (--catalog gaia catalog_ngc104.ecsv). We point the Telescope at the center of the catalog (–-radec 6 -72), with a roll angle of zero (–roll 0), we select the F158 optical element (--bandpass F158) and the IM_66_6 MA Table (–-ma_table_number 1002, for a comprehensive list of MA Tables and corresponding IDs, please visit the MA Table reference page). We also make sure the program is using the latest reference files from the Roman Calibration Reference Data System (CRDS) and the best PSF models from STPSF with the arguments --crds and --psftype stpsf, respectively. The output filename is example_ngc_104.asdf.

The full executable command is:

Shell command
romanisim-make-image --bandpass F158 --catalog gaia-catalog_ngc104.ecsv --level 2 --ma_table_number 1002 --radec 6 -72 --roll 0 --sca 1 --usecrds --psftype stpsf example_ngc104.asdf


Note

Make sure that the environment variables CRDS_PATH and CRDS_CONTEXT are correctly set, and that CRDS_CONTEXT is up-to-date. Users can find what is the latest CRDS_CONTEXT on the CRDS website.


Warning

Sometimes romanisim-make-image might produce error messages related to information stored in CRDS. If both CRDS_PATH and CRDS_CONTEXT are set correctly and the error message still appears, we recommend users empty the content of  CRDS_PATH, or have CRDS_PATH point to a new location on disk. This way, the content of the path will be rebuilt from scratch and there should be no more error messages.





Example 3: Displaying a Simulated Image

We can now read the ASDF file created by romanisim-make-image above and display the data content. In the following, we provide an example on how to do so using python and matplotlib. The code also shows how to access the World Coordinate System (WCS) information from the ASDF file.

First, we import the relevant packages:

Python
import roman_datamodels as rdm

from astropy.io import fits
from astropy import visualization
from astropy import units as u

import matplotlib
import matplotlib.pyplot as plt
from matplotlib import colors
from matplotlib import colormaps as cm

import numpy as np


Next, we read the ASDF file, assign the data to a numpy array, and extract the WCS information:

Python
filename = 'example_ngc104.asdf'

with rdm.open(filename) as file:
    wfi = file.meta.instrument.detector # we also extract the string corresponding to the WFI detector that has been simulated
    image = np.array(file.data)
    wcs = file.meta.wcs


Finally, we set up the plot canvas and a few plotting parameters:

Python
# font settings
matplotlib.rcParams['mathtext.fontset'] = 'stix'
matplotlib.rcParams['font.family'] = 'STIXGeneral'

# color-map settings
cmap = cm['YlOrBr_r']

# figure settings
fig, ax = plt.subplots(figsize=(8, 6), subplot_kw={'projection':wcs})
ax.set_title(f"Roman I-Sim {wfi}")
ax.imshow(image, cmap=cm["YlOrBr_r"], origin="lower", norm=colors.LogNorm(0.1, 200.0))
ax.coords.grid(linestyle='dashed', color='grey', alpha=0.5)

# axes settings
lon = ax.coords[0]
lat = ax.coords[1]
lon.set_axislabel('R.A. (degrees)')
lat.set_axislabel('Dec. (degrees)')
lon.set_major_formatter('d.dd')
lat.set_major_formatter('d.dd')
lon.set_ticks(spacing=2 * u.arcminute)
lat.set_ticks(spacing=2 * u.arcminute)

plt.show()


Figure of the Roman I-Sim simulated Image based on Examples 1 and 2 above.

Roman I-Sim simulation of an L2 image of WFI01 in a field near the globular cluster NGC 104, as generated using the command-line examples and the matplotlib code above. 







For additional questions not answered in this article, please contact the Roman Help Desk.




Latest Update

 

Added notes on RRN notebook
Publication

 

Initial publication of the article.