inject_sources_into_l2
- romanisim.image.inject_sources_into_l2(model, cat, x=None, y=None, psf=None, seed=50, rng=None, gain=None, psftype='epsf')
Inject sources into an L2 image.
This routine allows sources to be injected into an existing L2 image. Source injection into an L2 image relies on knowing the objects’ x and y locations, the PSF, and the image gain; if these are not provided, reasonable defaults are generated from the input model.
The simulation proceeds by (optionally) using the model WCS to generate the x & y locations, inverting the model’s photometric calibration to get the electron rate corresponding to a source of a given flux, and grabbing the read_pattern from the model_metadata. The number of additional counts in each pixel are simulated. We create a “virtual” ramp that uses the input L2 image and evenly apportions the measured DN/s along the ramp using the MA table. We apportion the new counts to a new ramp, and add the new ramp to the virtual ramp. We then refit the new ramp, and replace the old fit with the new fit.
This simulation is not as complete as the full L2 simulation. We do not include non-linearity or saturation, for example. Identified CR hits are lost. But it should do a decent job at providing realistic uncertainties otherwise, including how read & Poisson noise influence the choice of weights used in ramp fitting and how those influence the final uncertainties.
- Parameters:
- model: roman_datamodels.datamodels.ImageModel
model into which to inject sources
- cat: astropy.table.Table
catalog of sources to inject into image
- x: list[float] or None
x coordinates of catalog locations in image
- y: list[float] or None
y coordinates of catalog locations in image
- psf: galsim.gsobject.GSObject
PSF to use
- seedint
Seed for populating RNG. Only used if rng is None.
- rng: galsim.BaseDeviate
galsim random number generator to use
- gain: float [electron / DN]
gain of the image. This sets how many electrons the injected sources have and so affects their Poisson noise, but their total flux is set by the image’s photometric calibration. If None, romanisim.models.parameters.reference_data[‘gain’] is used.
- psftypeOne of [‘epsf’, ‘galsim’, ‘stpsf]
How to determine the PSF.
- Returns:
- model_out: roman_datamodels.datamodel.ImageModel
model with additional sources