romanimpreprocess.from_sim.sim_to_isim
Functions to convert external simulated images to Roman L1/L2-like format.
This works entirely at the single exposure level. Some parts wrap romanisim.
Functions
- hdu_sip_hflip
Flips an SCA in the 3n row in Detector coordinates to align with Science coordinates.
- hdu_sip_vflip
Flips an SCA in the 3n+1 or 3n+2 rows in Detector coordinates to align with Science coordinates.
- make_l1_fullcal
Makes an L1 image using an OpenUniverse input and the calibration data. (Merges with romanisim routines.)
- noise_1f_frame
Generates 1/f noise.
- fill_in_refdata_and_1f
Fills in reference pixels and reference output, as well as 1/f noise.
- simpletest
Quick look tool for Level 1 to Level 2 conversion (not for production).
- runconfig
Configuration-driven function to convert a simulation to Level 1 format.
Classes
- Image2D
2D image (may be from simulation).
- Image2D_from_L1
2D image from Level 1 data (useful for ‘shortcut’ workflow, for most applications use L1_to_L2).
Attributes
Classes
2D image, along with WCS and sky information. |
|
Similar to Image2D, but constructed from L1 data file. |
Functions
|
Horizontal flip of SCA and WCS. Assumes SIP convention. |
|
Vertical flip of SCA and WCS. Assumes SIP convention. |
|
Make an L1 image with the full calibration information. |
|
Generates a 4096x128 block of 1/f noise. |
|
Fills in the reference pixel data in an image, and adds 1/f noise. |
This is a simple script to convert Roman to L1/L2. |
|
|
This allows the L1 image construction to be called as a Python function instead of a |
Module Contents
- hdu_sip_hflip(data, header)[source]
Horizontal flip of SCA and WCS. Assumes SIP convention.
This function operates on the data and WCS header in place.
- Parameters:
data (np.array) – 2D image of an SCA.
header (astropy.io.fits.header.Header) – Header containing the WCS.
- Return type:
None
See also
hdu_sip_vflipSimilar, but for vertical flip instead.
- hdu_sip_vflip(data, header)[source]
Vertical flip of SCA and WCS. Assumes SIP convention.
This function operates on the data and WCS header in place.
- Parameters:
data (np.array) – 2D image of an SCA.
header (astropy.io.fits.header.Header) – Header containing the WCS.
- Return type:
None
See also
hdu_sip_hflipSimilar, but for horizontal flip instead.
- make_l1_fullcal(counts, read_pattern, caldir, rng=None, persistence=None, tstart=None)[source]
Make an L1 image with the full calibration information.
This carries out similar steps to romanisim.l1.make_l1, but provides us a bit more control over the settings.
- Parameters:
counts (galsim.Image) – Contains mean number electrons per pixel per exposure.
read_pattern (list of list of int) – MultiAccum table.
caldir (dict) – Dictionary of the reference files.
rng (galsim.BaseDeviate, optional) – The random number generator.
persistence (romanisim.persistence.Persistence, optional) – Persistence object, not used yet.
tstart (float, optional) – Start time to feed to romanisim.
- Returns:
l1 (np.array) – 3D image array
dq (np.array) – 3D quality array
- noise_1f_frame(rng)[source]
Generates a 4096x128 block of 1/f noise.
The frame is normalized to variance of 1 per logarithmic range in frequency, i.e., S(f) = 1/f, where Var X = int_0^infty S(f) df.
- Parameters:
rng (galsim.BaseDeviate) – The random number generator.
- Returns:
Shape (4096,128).
- Return type:
np.array of float
- fill_in_refdata_and_1f(im, caldir, rng, tij, fill_in_banding=True, amp33=None)[source]
Fills in the reference pixel data in an image, and adds 1/f noise.
If amp33 is provided, then also tries to fill in the reference output (if the calibration reference files have that information).
Noise is added in-place to im and (if provided) amp33, keeping the same data type.
- Parameters:
im (np.array) – The image data cube. Shape (ngrp, ny, nx).
caldir (dict) – The dictionary of calibration reference files.
rng (galsim.BaseDeviate) – The random number generator.
tij (list of list of float) – Time stamps of the reads in seconds.
fill_in_banding (bool, optional) – Whether to gennerate 1/f noise.
amp33 (np.array, optional) – If provided, array to put the reference output.
- Return type:
None
- class Image2D(intype, **kwargs)[source]
2D image, along with WCS and sky information.
It can be constructed from simulations or (ultimately) from Roman data.
- Parameters:
intype (str) – Input type (e.g., “anlsim”)
- image
A 2D image. Units are e/p/s if generated from a simulation in e.
- Type:
np.array of flat
- galsimwcs
The world coordinate system for this image.
- Type:
galsim.wcs.CelestialWCS
- header
The world coordinate system for this image in FITS WCS format.
- Type:
astropy.io.fits.header.Header
- date
The observation date (ISO 8601 string).
- Type:
str
- filter
The observation filter (4 characters, e.g., R062).
- Type:
str
- idsca
The observation ID and SCA.
- Type:
(int, int)
- ra_
Right ascension (in degrees) of the WFI.
- Type:
float
- dec_
Declination (in degrees) of the WFI.
- Type:
float
- pa_
Position angle (in degrees) of the WFI.
- Type:
float
- refdata
Reference data locations.
- Type:
dict
- af
Level 1 data
- Type:
asdf.AsdfFile
- af2
Level 2 data
- Type:
asdf.AsdfFile
Notes
The legal intype strings are:
anlsim: The Open Universe 2024 simulation “truth” (or equivalent)
- init_anlsim(fname, flip=True)[source]
Constructor from Open Universe 2024-type simulation.
- Parameters:
fname (str) – The input file name.
flip (bool, optional) – If True, then flips from SCA native coordinates to science-aligned (SOC-like product).
- Return type:
None
- simulate(use_read_pattern, caldir=None, config={}, seed=43)[source]
Performs Level 1 & 2 simulations.
This is based on the
romanisim.image.simulatefunction, but some functionality has been changed to be useful for this class.- Parameters:
use_read_pattern (list of list of int) – The MultiAccum table.
caldir (dict, optional) – Dictionary of where the calibration files are located. (Otherwise uses internal defaults, only good for testing.)
config (dict, optional) – Configuration file (usually expanded from YAML).
seed (int, optional) – Random number seed.
- Return type:
None
- class Image2D_from_L1(infile, refdata, thewcs, verbose_err=True)[source]
Bases:
Image2DSimilar to Image2D, but constructed from L1 data file.
- with Image2D_from_L1(infile, refdata, thewcs) as L1:
…
- simpletest()[source]
This is a simple script to convert Roman to L1/L2. For internal testing only, not production.