Nicole Drakos

Research Blog

Welcome to my Research Blog.

This is mostly meant to document what I am working on for myself, and to communicate with my colleagues. It is likely filled with errors!

This project is maintained by ndrakos

Mirage

I want to run the DREaM catalogs through Multi-Instrument Ramp Generator (Mirage) to make COSMOS-Web images. This post is my initial installation/checking it works. I will be using the online documentation.

Installation

Installation instructions are here.

I simply did a pip install, and it worked fine.

Reference Files

There is documentation on the reference files here.

I downloaded the relevant Mirage files as follows:

from mirage.reference_files import downloader
download_path = '/Users/nicoledrakos/Documents/Software/Mirage/'
downloader.download_reffiles(download_path, instrument='NIRCam', dark_type='linearized', skip_darks=False, single_dark=False, skip_cosmic_rays=False, skip_psfs=False)

This is absolutely huge, so I only downloaded the NIRCam files. It is still over 300 Gb.

I then added the following to my ~/.zshrc file

export MIRAGE_DATA="/Users/nicoledrakos/Documents/Software/Mirage/mirage_data"
export CRDS_PATH="/Users/nicoledrakos/Documents/Software/Mirage/crds_cache"
export CRDS_SERVER_URL=https://jwst-crds.stsci.edu

Overview of Process

First, the code can take APT files, catalogs, and other inputs to create yaml files that Mirage uses to create all the observations. The code works in three stages.

  1. Create a “seed” image. This is a noiseless, idealized image of the sources (but seed images include instrument distortion effects). This can be made from either a source catalog, or a distortion free image.

  2. Preparation of the dark current exposure to use for the simulation. This will allow addition of e.g. 1/f noise, bias structure, and hot pixel population.

  3. Observation generation. This creates a combination of the seed image and the dark current in order to produce the output exposure. Other effects are also added at this stage, including cosmic rays, interpixel capacitance (IPC) and crosstalk effects.

Test Run

I’m going to go through the quick start guide in this post, and log any trouble shooting I had to do here

1) Import functions

When importing functions, I got an error from the line from mirage import imaging_simulator.

The error message: “cannot import name ‘wraps’ from ‘astropy.utils.decorators’ “

My solution was that in /usr/local/lib/python3.9/site-packages/poppy/utils.py I changed the line “from astropy.utils.decorators import wraps” to “from functools import wraps”.

2) Create Catalogs

Here is documentation on how to create catalogs. I will want to provide a list of galaxies from the DREaM catalogs. But in this post, I’m just going to create a small number of galaxies to test. Note that I made them all around RA=150, Dec=2.4, since that is where the field is centered.

catalogfile= output_dir+ 'galaxies.cat'
N = 10
ra_list = ((2*np.random.random(N)-1)*0.01 + 1 )* 150
dec_list = ((2*np.random.random(N)-1)*0.01 + 1) * 2.4
radius = np.random.random(N)*0.1
ellipticity = np.random.random(N) * 0.75
sersic_index = np.random.random(N) * 4.
position_angle = np.random.random(N) * 359.

nrc_f115w_mag = np.random.random(N) + 16.
nrc_f150n_mag = np.random.random(N) + 19.
nis_f277w_mag = np.random.random(N) + 15.5
nis_f444w_mag = np.random.random(N) + 15.5

starting_index=11
gal = catalog_generator.GalaxyCatalog(ra=ra_list, dec=dec_list, radius=radius, ellipticity=ellipticity,
                                      sersic_index=sersic_index, position_angle=position_angle,
                                      starting_index=starting_index)
gal.add_magnitude_column(nrc_f115w_mag, instrument='nircam', filter_name='F115W', magnitude_system='abmag')
gal.add_magnitude_column(nrc_f150n_mag, instrument='nircam', filter_name='F150N', magnitude_system='abmag')
gal.add_magnitude_column(nis_f277w_mag, instrument='niriss', filter_name='F277W', magnitude_system='abmag')
gal.add_magnitude_column(nis_f444w_mag, instrument='niriss', filter_name='F444W', magnitude_system='abmag')

gal.save(catalogfile)

Note the radius line was not included in the example. Without this, it wouldn’t work. I also changed the magnitudes to be the same as the COSMOS-Web. The file catalogfile contains all the galaxy properties that will be added to the image.

3) Create mirage input yaml files from an APT file

Here is the code I used to generate the yaml files (for now with no catalog). I got the APT files from slack channel.

cosmic_rays = {'library':'SUNMAX', 'scale':1.0} # This is the default
dates = '2022-12-31' #only used to put in header
pav3 = 0# This is the default, just changes the orientation of the data
ghosts=False; convolve_ghosts=False
catalogs = {'galaxy':catalogfile}

yam = yaml_generator.SimInput(xml_file, pointing_file, catalogs=catalogs, verbose=True,
                              output_dir=output_dir, simdata_output_dir=simdata_output_dir,
                              cosmic_rays=cosmic_rays,roll_angle=pav3, dates=dates, datatype='raw',
                              dateobs_for_background=True, reffile_defaults='crds',
                              add_ghosts=ghosts, convolve_ghosts_with_psf=convolve_ghosts
                              )

yam.create_inputs()

4) Make simulated image

As outlined above, there are three steps to generating an image with Mirage. However, there is a wrapper imaging_simulator that should perform all of the steps at once. I’m going to try this first.

yaml_files = glob(output_dir+'/*yaml')
test_yaml_file = yaml_files[0]
img_sim = imaging_simulator.ImgSim()
img_sim.paramfile = test_yaml_file
img_sim.create()

This seemed to run fine, and made some output files in the simulated_data folder

Next Steps

  1. Go through these steps more carefully, and check all my chosen parameters
  2. Break down the imaging_simulator step into the three separate steps to get a better picture of what is happening
  3. Update the source catalog to be the dream galaxies
  4. Check that the noise levels look right in the catalog
  5. Add stars
  6. Other checks?

« Add DREaM to FLAGS Comparison
JWST Pipeline »