roman_shear_sims.sim
sim.py
Functions
|
Make the simulation |
|
Make a single exposure for the simulation. |
|
Make a single exposure for the simulation. |
|
Get a stamp for one object. This where we draw the object. |
|
Get the true PSF image. |
|
Get the PSF image used for the deconvolution. |
Module Contents
- make_sim(rng, galaxy_catalog, psf_maker, simu_type='sca', n_epochs=6, exp_time=107, cell_size_pix=500, oversamp_factor=3, bands=None, g1=0.0, g2=0.0, chromatic=False, simple_noise=False, noise_sigma=1.0, n_noise_realizations=1, image_factor=1.0, draw_method='phot', n_photons=None, avg_gal_sed_path=None, make_deconv_psf=True, make_true_psf=True, verbose=True)[source]
Make the simulation
- Parameters:
rng (np.random.Generator) – The random number generator to use for the simulation.
galaxy_catalog (GalaxyCatalog) – The galaxy catalog to use for the simulation.
psf_maker (PSFMaker) – The PSF maker to use for the simulation.
simu_type (str, optional) – The type of simulation to run. Options are ‘sca’ for SCA simulation and ‘imcom’ for IMCOM simulation. Default: ‘sca’.
n_epochs (int, optional) – The number of epochs to simulate. Default: 6.
exp_time (float, optional) – The exposure time in seconds. Default: 107.
cell_size_pix (int, optional) – The size of the cell in pixels. Default: 500.
oversamp_factor (int, optional) – The oversampling factor for the WCS. Default: 3.
bands (list of str, optional) – The list of bands to simulate. If None, defaults to [‘Y106’, ‘J129’, ‘H158’].
g1 (float or array-like, optional) – The shear component g1. Default: 0.0.
g2 (float or array-like, optional) – The shear component g2. Default: 0.0.
chromatic (bool, optional) – Whether the PSF is chromatic. Default: False.
simple_noise (bool, optional) – Whether to use simple Gaussian noise instead of the full Roman noise model. Default: False.
noise_sigma (float, optional) – The standard deviation of the Gaussian noise if simple_noise is True. Required if simple_noise is True. Default: 1.0.
n_noise_realizations (int, optional) – The number of independent noise realizations to create. Default: 1.
image_factor (float, optional) – A factor to scale the noise level. Default: 1.0.
draw_method (str, optional) – The method to use for drawing the objects. Default: ‘phot’.
n_photons (int, optional) – The number of photons to use for the ‘phot’ draw method. If None, it will be calculated based on the galaxy flux and image_factor. Default: None.
avg_gal_sed_path (str, optional) – The path to the average galaxy SED file. Required if chromatic is True.
make_deconv_psf (bool, optional) – Whether to create the deconvolved PSF image. If sim_type is ‘imcom’, this parameter is used to determine whether to create the PSF image. Default: True.
make_true_psf (bool, optional) – Whether to create the true PSF image. Default: True.
verbose (bool, optional) – Whether to print progress messages. Default: True.
- Returns:
A dictionary containing the simulation results for each band. Each key is a band name and the value is a list of dictionaries for each epoch. Each epoch dictionary contains the following keys:
’sca’: The SCA number.
’wcs’: The WCS object for the epoch.
’flux_scaling’: The flux scaling factor for the band.
’psf_avg’: The average PSF image for deconvolution.
’psf_true_galsim’: The true PSF object for the epoch.
’sci’: A dictionary with keys ‘shear_<g1>_<g2>’ for each shear component, containing the science image array.
’noise’: List of noise realizations as image arrays.
’noise_var’: The variance of the noise images.
’weight’: The weight image array.
- Return type:
dict
- make_exp(rng, galaxy_catalog, psf_maker, band, cell_center_world, g1, g2, pa_point=0.0, exp_time=107, cell_size_pix=500, oversamp_factor=3, chromatic=False, simple_noise=False, noise_sigma=None, n_noise_realizations=1, image_factor=1.0, draw_method='phot', n_photons=None, avg_gal_sed_path=None, make_deconv_psf=False, make_true_psf=False, verbose=True)[source]
Make a single exposure for the simulation.
- Parameters:
rng (np.random.Generator) – The random number generator to use for the simulation.
galaxy_catalog (GalaxyCatalog) – The galaxy catalog to use for the simulation.
psf_maker (PSFMaker) – The PSF maker to use for the simulation.
band (str, optional) – The band to simulate. If None, defaults to ‘Y106’.
cell_center_world (galsim.CelestialCoord) – The celestial coordinates of the cell center.
g1 (float or array-like, optional) – The shear component g1. Default: 0.0.
g2 (float or array-like, optional) – The shear component g2. Default: 0.0.
pa_point (float, optional) – The position angle in degrees for the WCS. Default: 0.0.
exp_time (float, optional) – The exposure time in seconds. Default: 107.
cell_size_pix (int, optional) – The size of the cell in pixels. Default: 500.
oversamp_factor (int, optional) – The oversampling factor for the WCS. Default: 3.
chromatic (bool, optional) – Whether the PSF is chromatic. Default: False.
simple_noise (bool, optional) – Whether to use simple Gaussian noise instead of the full Roman noise model. Default: False.
noise_sigma (float, optional) – The standard deviation of the Gaussian noise if simple_noise is True. Required if simple_noise is True. Default: 1.0.
n_noise_realizations (int, optional) – The number of independent noise realizations to create. Default: 1.
image_factor (float, optional) – A factor to scale the noise level. Default: 1.0.
draw_method (str, optional) – The method to use for drawing the objects. Default: ‘phot’.
n_photons (int, optional) – The number of photons to use for the ‘phot’ draw method. If None, it will be calculated based on the galaxy flux and image_factor. Default: None.
avg_gal_sed_path (str, optional) – The path to the average galaxy SED file. Required if chromatic is True.
make_deconv_psf (bool, optional) – Whether to create the deconvolved PSF image. Default: True.
make_true_psf (bool, optional) – Whether to create the true PSF image. Default: True.
verbose (bool, optional) – Whether to print progress messages. Default: True.
- make_IMCOM(rng, galaxy_catalog, psf_maker, band, cell_center_world, g1, g2, exp_time=107, cell_size_pix=500, simple_noise=False, noise_sigma=None, n_noise_realizations=1, image_factor=6.0, draw_method='phot', n_photons=None, avg_gal_sed_path=None, make_psf=False, verbose=True)[source]
Make a single exposure for the simulation.
- Parameters:
rng (np.random.Generator) – The random number generator to use for the simulation.
galaxy_catalog (GalaxyCatalog) – The galaxy catalog to use for the simulation.
psf_maker (PSFMaker) – The PSF maker to use for the simulation.
band (str, optional) – The band to simulate. If None, defaults to ‘Y106’.
cell_center_world (galsim.CelestialCoord) – The celestial coordinates of the cell center.
g1 (float or array-like, optional) – The shear component g1. Default: 0.0.
g2 (float or array-like, optional) – The shear component g2. Default: 0.0.
exp_time (float, optional) – The exposure time in seconds. Default: 107.
cell_size_pix (int, optional) – The size of the cell in pixels. Default: 500.
simple_noise (bool, optional) – Whether to use simple Gaussian noise instead of the full Roman noise model. Default: False.
noise_sigma (float, optional) – The standard deviation of the Gaussian noise if simple_noise is True. Required if simple_noise is True. Default: 1.0.
n_noise_realizations (int, optional) – The number of independent noise realizations to create. Default: 1.
image_factor (float, optional) – A factor to scale the noise level. Default: 1.0.
draw_method (str, optional) – The method to use for drawing the objects. Default: ‘phot’.
n_photons (int, optional) – The number of photons to use for the ‘phot’ draw method. If None, it will be calculated based on the galaxy flux and image_factor. Default: None.
avg_gal_sed_path (str, optional) – The path to the average galaxy SED file. Required if chromatic is True.
make_psf (bool, optional) – Whether to create the PSF image. Default: False.
verbose (bool, optional) – Whether to print progress messages. Default: True.
- get_stamp(obj, dx, dy, wcs, cell_center_world, bp, gal_flux, rng_galsim, draw_method='phot', image_factor=1.0, n_photons=None)[source]
Get a stamp for one object. This where we draw the object.
- Parameters:
obj (galsim.GSObject) – The object to draw.
dx (float) – The x offset in arcseconds from the cell center.
dy (float) – The y offset in arcseconds from the cell center.
wcs (galsim.BaseWCS) – The WCS object for the image.
cell_center_world (galsim.CelestialCoord) – The celestial coordinates of the cell center.
bp (galsim.Bandpass) – The bandpass for which to draw the object.
gal_flux (float) – The flux of the galaxy in the bandpass.
rng_galsim (galsim.BaseDeviate) – The random number generator to use for drawing the object.
draw_method (str, optional) – The method to use for drawing the object. Default: ‘phot’.
image_factor (float, optional) – A factor to scale the noise level. Default: 1.0.
n_photons (int, optional) – The number of photons to use for the ‘phot’ draw method. If None, it will be calculated based on the galaxy flux and image_factor. Default: None.
- Returns:
The drawn image of the object.
- Return type:
galsim.Image
- get_true_psf(star, psf, wcs, bp, draw_method='no_pixel')[source]
Get the true PSF image.
- Parameters:
star (galsim.DeltaFunction) – The star object to use for the PSF with the SED.
psf (galsim.GSObject) – The PSF object.
wcs (galsim.BaseWCS) – The WCS object for the image.
bp (galsim.Bandpass) – The bandpass for which to draw the PSF.
draw_method (str, optional) – The method to use for drawing the PSF. Default: ‘no_pixel’.
- Returns:
The true PSF image array.
- Return type:
np.ndarray
- get_deconv_psf(psf, wcs, wcs_oversampled, cell_center_world, bp=None, chromatic=False, avg_gal_sed_path=None)[source]
Get the PSF image used for the deconvolution.
- Parameters:
psf (galsim.GSObject) – The PSF object.
wcs (galsim.BaseWCS) – The WCS object for the image.
wcs_oversampled (galsim.BaseWCS) – The oversampled WCS object for the image.
cell_center_world (galsim.CelestialCoord) – The celestial coordinates of the image center.
bp (galsim.Bandpass, optional) – The bandpass for which to draw the PSF. Required if chromatic is True.
chromatic (bool, optional) – Whether the PSF is chromatic. Default: False.
avg_gal_sed_path (str, optional) – The path to the average galaxy SED file. Required if chromatic is True. Default: None.
- Returns:
The PSF image array.
- Return type:
np.ndarray