lenstronomy.SimulationAPI package

Subpackages

Submodules

lenstronomy.SimulationAPI.data_api module

class lenstronomy.SimulationAPI.data_api.DataAPI(numpix, **kwargs_single_band)[source]

Bases: lenstronomy.SimulationAPI.observation_api.SingleBand

This class is a wrapper of the general description of data in SingleBand() to translate those quantities into configurations in the core lenstronomy Data modules to simulate images according to those quantities. This class is meant to be an example of a wrapper. More possibilities in terms of PSF and data type options are available. Have a look in the specific modules if you are interested in.

property data_class

creates a Data() instance of lenstronomy based on knowledge of the observation

Returns

instance of Data() class

property kwargs_data
Returns

keyword arguments for ImageData class instance

lenstronomy.SimulationAPI.model_api module

class lenstronomy.SimulationAPI.model_api.ModelAPI(lens_model_list=[], z_lens=None, z_source=None, lens_redshift_list=None, source_light_model_list=[], lens_light_model_list=[], point_source_model_list=[], source_redshift_list=None, cosmo=None, z_source_convention=None)[source]

Bases: object

This class manages the model choices. The role is to return instances of the lenstronomy LightModel, LensModel, PointSource modules according to the options chosen by the user. Currently, all other model choices are equivalent to the ones provided by LightModel, LensModel, PointSource. The current options of the class instance only describe a subset of possibilities.

property lens_light_model_class
Returns

instance of lenstronomy LightModel class describing the non-lensed light profiles

property lens_model_class
Returns

instance of lenstronomy LensModel class

physical2lensing_conversion(kwargs_mass)[source]
Parameters

kwargs_mass – list of keyword arguments of all the lens models. Einstein radius ‘theta_E’ are replaced by ‘sigma_v’, velocity dispersion in km/s, ‘alpha_Rs’ and ‘Rs’ of NFW profiles are replaced by ‘M200’ and ‘concentration’

Returns

kwargs_lens in reduced deflection angles compatible with the lensModel instance of this module

property point_source_model_class
Returns

instance of lenstronomy PointSource class describing the point sources (lensed and unlensed)

property source_model_class
Returns

instance of lenstronomy LightModel class describing the source light profiles

lenstronomy.SimulationAPI.observation_api module

class lenstronomy.SimulationAPI.observation_api.Instrument(pixel_scale, read_noise=None, ccd_gain=None)[source]

Bases: object

basic access points to instrument properties

class lenstronomy.SimulationAPI.observation_api.Observation(exposure_time, sky_brightness=None, seeing=None, num_exposures=1, psf_type='GAUSSIAN', kernel_point_source=None, truncation=5, point_source_supersampling_factor=1)[source]

Bases: object

basic access point to observation properties

property exposure_time

total exposure time

Returns

summed exposure time

property psf_class

creates instance of PSF() class based on knowledge of the observations For the full possibility of how to create such an instance, see the PSF() class documentation

Returns

instance of PSF() class

update_observation(exposure_time=None, sky_brightness=None, seeing=None, num_exposures=None, psf_type=None, kernel_point_source=None)[source]

updates class instance with new properties if specific argument is not None

Parameters
  • exposure_time – exposure time per image (in seconds)

  • sky_brightness – sky brightness (in magnitude per square arcseconds)

  • seeing – full width at half maximum of the PSF (if not specific psf_model is specified)

  • num_exposures – number of exposures that are combined

  • psf_type – string, type of PSF (‘GAUSSIAN’ and ‘PIXEL’ supported)

  • kernel_point_source – 2d numpy array, model of PSF centered with odd number of pixels per axis (optional when psf_type=’PIXEL’ is chosen)

Returns

None, updated class instance

class lenstronomy.SimulationAPI.observation_api.SingleBand(pixel_scale, exposure_time, magnitude_zero_point, read_noise=None, ccd_gain=None, sky_brightness=None, seeing=None, num_exposures=1, psf_type='GAUSSIAN', kernel_point_source=None, truncation=5, point_source_supersampling_factor=1, data_count_unit='e-', background_noise=None)[source]

Bases: lenstronomy.SimulationAPI.observation_api.Instrument, lenstronomy.SimulationAPI.observation_api.Observation

class that combines Instrument and Observation

property background_noise

Gaussian sigma of noise level per pixel in counts (e- or ADU) per second

Returns

sqrt(variance) of background noise level in data units

estimate_noise(image)[source]
Parameters

image – noisy data, background subtracted

Returns

estimated noise map sqrt(variance) for each pixel as estimated from the instrument and observation

flux_iid(flux_per_second)[source]

IID counts. This can be used by lenstronomy to estimate the Poisson errors keeping the assumption that the counts are IIDs (even if they are not).

Parameters

flux_per_second – flux count per second in the units set in this class (ADU or e-)

Returns

IID count number

flux_noise(flux)[source]
Parameters

flux – float or array, units of count_unit/seconds, needs to be positive semi-definite in the flux value

Returns

Gaussian approximation of Poisson statistics in IIDs sqrt(variance)

magnitude2cps(magnitude)[source]

converts an apparent magnitude to counts per second (in units of the data)

The zero point of an instrument, by definition, is the magnitude of an object that produces one count (or data number, DN) per second. The magnitude of an arbitrary object producing DN counts in an observation of length EXPTIME is therefore: m = -2.5 x log10(DN / EXPTIME) + ZEROPOINT

Parameters

magnitude – magnitude of object

Returns

counts per second of object

noise_for_model(model, background_noise=True, poisson_noise=True, seed=None)[source]
Parameters
  • model – 2d numpy array of modelled image (with pixels in units of data specified in class)

  • background_noise – bool, if True, adds background noise

  • poisson_noise – bool, if True, adds Poisson noise of modelled flux

  • seed – int, seed number to be used to render the noise properties. If None, then uses the current numpy.random seed to render the noise properties.

Returns

noise realization corresponding to the model

property sky_brightness
Returns

sky brightness (counts per square arcseconds in unit of data (e- or ADU’s) per unit time)

lenstronomy.SimulationAPI.observation_constructor module

lenstronomy.SimulationAPI.observation_constructor.observation_constructor(instrument_name, observation_name)[source]
Parameters
  • instrument_name – string, name of instrument referenced in this file

  • observation_name – string, name of observation referenced in this file

Returns

instance of the SimulationAPI.data_type instance

lenstronomy.SimulationAPI.point_source_variability module

class lenstronomy.SimulationAPI.point_source_variability.PointSourceVariability(source_x, source_y, variability_func, numpix, kwargs_single_band, kwargs_model, kwargs_numerics, kwargs_lens, kwargs_source_mag=None, kwargs_lens_light_mag=None, kwargs_ps_mag=None)[source]

Bases: object

This class enables to plug in a variable point source in the source plane to be added on top of a fixed lens and extended surface brightness model. The class inherits SimAPI and additionally requires the lens and light model parameters as well as a position in the source plane.

The intrinsic source variability can be defined by the user and additional uncorrelated variability in the image plane can be plugged in as well (e.g. due to micro-lensing)

property delays
Returns

time delays

property image_bkg
Returns

2d numpy array, image of the extended light components without the variable source

image_time(time=0)[source]
Parameters

time – time relative to the definition of t=0 for the first appearing image

Returns

image with time variable source at given time

point_source_time(t)[source]
Parameters

t – time (in units of days)

Returns

image plane parameters of the point source observed at t

lenstronomy.SimulationAPI.sim_api module

class lenstronomy.SimulationAPI.sim_api.SimAPI(numpix, kwargs_single_band, kwargs_model)[source]

Bases: lenstronomy.SimulationAPI.data_api.DataAPI, lenstronomy.SimulationAPI.model_api.ModelAPI

This class manages the model parameters in regard of the data specified in SingleBand. In particular, this API translates models specified in units of astronomical magnitudes into the amplitude parameters used in the LightModel module of lenstronomy. Optionally, this class can also handle inputs with cosmology dependent lensing quantities and translates them to the optical quantities being used in the lenstronomy LensModel module. All other model choices are equivalent to the ones provided by LightModel, LensModel, PointSource modules

image_model_class(kwargs_numerics=None)[source]
Parameters

kwargs_numerics – keyword arguments list of Numerics module

Returns

instance of the ImageModel class with all the specified configurations

magnitude2amplitude(kwargs_lens_light_mag=None, kwargs_source_mag=None, kwargs_ps_mag=None)[source]

‘magnitude’ definition are in APPARENT magnitudes as observed on the sky, not intrinsic!

Parameters
  • kwargs_lens_light_mag – keyword argument list as for LightModel module except that ‘amp’ parameters are ‘magnitude’ parameters.

  • kwargs_source_mag – keyword argument list as for LightModel module except that ‘amp’ parameters are ‘magnitude’ parameters.

  • kwargs_ps_mag – keyword argument list as for PointSource module except that ‘amp’ parameters are ‘magnitude’ parameters.

Returns

value of the lenstronomy ‘amp’ parameter such that the total flux of the profile type results in this magnitude for all the light models. These keyword arguments conform with the lenstronomy LightModel syntax.

Module contents