SLRealizer¶
The SLRealizer package enables the realization, or emulation, of LSST “Object” and “Source” catalogs, given an input “truth” catalog. The output catalogs have (some of) the same columns as the actual data release production (DRP) catalogs will have. Galaxies and PSFs are modeled as mixtures of Gaussians, and convolution is carried out arithmetically; mock measured quantities are estimated from the moments of the resulting GMMs. A very simple Gaussian error model is used to add noise to the emulated measurements. Please find below the the API documentation for the code.
Contents:
Basic Strong Lens Realization¶
-
class
slrealizer.realize_sl.SLRealizer(observation, add_moment_noise, add_flux_noise)[source]¶ Worker class equipped with functions for making LSST-like “Object” and “Source” tables. These are inherited by child classes which are associated with a specific non-LSST catalog, e.g. the child class OM10Realizer realizes the lenses in the OM10 catalog into mock LSST tables.
SLRealizerobjects are instantiated with an observation history, provided as a pandas dataframe.-
compare_truth_vs_emulated(lensID=None, rownum=None, save_dir=None)[source]¶ Draws two images of the lens system with the given rownum under randomly chosen observation conditions, one from the catalog info (truth image) and another from HSM’s estimation of the truth image
Keyword arguments: - lensID: an integer specifying the ID of the lens system in the OM10 catalog
Returns: A tuple of - the truth image drawn from the catalog info - the emulated image drawn from HSM’s derived info of aggregate system
-
create_source_row(derived_params, objectId, obs_info)[source]¶ Returns a dictionary of lens system’s properties computed the image of one lens system and the observation conditions, which makes up a row of the source table.
Keyword arguments: derived_params – derived lens properties obs_info – a row of the observation history df
Returns A dictionary with properties derived from HSM estimation (See code for which properties)
-
draw_emulated_system(estimated_params)[source]¶ Draws the emulated system, i.e. draws the aggregate system from properties HSM derived from the image, which was in turn drawn from the catalog’s truth properties. Only runs when DEBUG == True.
Returns a GalSim Image object of the emulated system
-
draw_system(lens_info, obs_info, save_path=None)[source]¶ Draws all objects of the given lens system in the given observation conditions, using GalSim.
Parameters: - lens_info (pandas.Dataframe) – a row of the OM10 DB
- obs_info (pandas.Dataframe) – a row of the observation history df
- save_path (string) – path in which to save the image
Returns: galsim_img – A GalSim image object of the aggregate system
Return type: galsim.Image
-
estimate_parameters(galsim_img, method='raw_numerical')[source]¶ Performs shape estimati on on the galsim_img using either GalSim’s HSM shape estimator or a native numerical moment calculator under the observation conditions obs_info
Keyword arguments: galsim_img – GalSim’s Image object on which parameters will be estimated method – one of “hsm” (GalSim’s HSM shape estimator) or
“raw_numerical” (a native numerical moment calculator) [default: “raw”]Returns a dictionary of the lens properties, which can be used to draw the emulated image
-
include_quasar_variability(save_output=False, input_source_path=None, output_source_path=None)[source]¶ Takes a source table and adds the intrinsic variability of the quasar images using the generative model introduced in MacLeod et al (2010)
Keyword arguments: save_output – whether to save the output to disk [default: False] input_source_path – path of input source table to be altered [default: None] output_source_path – path of output source table containing time variability [default: None]
-
Realizing OM10 Lensed Quasars¶
-
class
slrealizer.realize_om10.OM10Realizer(observation, catalog, debug=False, add_moment_noise=True, add_flux_noise=True)[source]¶ A class that realizes objects in the OM10 mock quasar catalog under the given observation conditions, into LSST DRP Source and Object catalogs
-
create_source_row(obs_info, lens_info, method='analytical')[source]¶ Returns a dictionary of lens system’s properties computed the image of one lens system and the observation conditions, which makes up a row of the source table.
Keyword arguments: image – a Numpy array of the lens system’s image obs_info – a row of the observation history df method – how to calculate the moments, one of “analytical”, “raw_numerical”, and “hsm”
(for details about “raw_numerical” vs. “hsm”, see method estimate_parameters)Returns A dictionary with properties derived from HSM estimation (See code for which properties)
-
draw_emulated_system(obs_info, lens_info)[source]¶ Draws the emulated system, i.e. draws the aggregate system from properties HSM derived from the image, which was in turn drawn from the catalog’s truth properties. Only runs when DEBUG == True.
Returns a GalSim Image object of the emulated system
-
draw_system(obs_info, lens_info, save_path=None)[source]¶ Draws all objects of the given lens system in the given observation conditions, using GalSim.
Parameters: - lens_info (pandas.Dataframe) – a row of the OM10 DB
- obs_info (pandas.Dataframe) – a row of the observation history df
- save_path (string) – path in which to save the image
Returns: galsim_img – A GalSim image object of the aggregate system
Return type: galsim.Image
-
estimate_parameters(obs_info, lens_info, method='raw_numerical')[source]¶ Performs GalSim’s HSM shape estimation on the image rendered with lens properties in lens_info under the observation conditions in obs_info
Keyword arguments: obs_info – dictionary containing the observation conditions lens_info – dictionary containing the lens properties method – one of “hsm” (GalSim’s HSM shape estimator) or
“raw_numerical” (a native numerical moment calculator) [default: “raw_numerical”]Returns a dictionary containing the shape information numerically derived by HSM
-
make_source_table_vectorized(output_source_path, include_time_variability)[source]¶ Generates the source table and saves it as a csv file.
Keyword arguments: output_source_path – save path for the output source table include_time_variability – whether to include intrinsic quasar variability
Returns (only if self.DEBUG == True): a Pandas dataframe of the source table
-
Realizing Non-Lenses: SDSS Galaxies¶
-
class
slrealizer.realize_sdss.SDSSRealizer(observation, catalog, debug=False, add_moment_noise=True, add_flux_noise=True)[source]¶ A class that realizes objects in the SDSS DR catalog under the given observation conditions, into LSST DRP Source and Object catalogs.
-
create_source_row(obs_info, lens_info, method='analytical')[source]¶ Returns a dictionary of lens system’s properties computed the image of one lens system and the observation conditions, which makes up a row of the source table.
Keyword arguments: derived_params – derived lens properties obs_info – a row of the observation history df
Returns A dictionary with properties derived from HSM estimation (See code for which properties)
-
draw_emulated_system(obs_info, lens_info)[source]¶ Draws the emulated system, i.e. draws the aggregate system from properties HSM derived from the image, which was in turn drawn from the catalog’s truth properties. Only runs when DEBUG == True.
Returns a GalSim Image object of the emulated system
-
draw_system(obs_info, lens_info, save_dir=None)[source]¶ Draws all objects of the given lens system in the given observation conditions, using GalSim.
Parameters: - lens_info (pandas.Dataframe) – a row of the OM10 DB
- obs_info (pandas.Dataframe) – a row of the observation history df
- save_path (string) – path in which to save the image
Returns: galsim_img – A GalSim image object of the aggregate system
Return type: galsim.Image
-
Utilities¶
Accessing Standard Data Files¶
The dataloader module contains the Dataloader utility class, which provides easy access to some standard test data files, including the OM10 lens database, and an example LSST observation history file.
Useful Functions¶
The utils module provides a number of utility functions used by the SLRealizer worker class and its descendants.
-
slrealizer.utils.utils.add_noise(mean, stdev, shape=None, measurement=1.0)[source]¶ Given a mean and a standard deviation of a measurement, adds Gaussian noise to the data
Keyword arguments: mean – the mean of Gaussian stdev – the standard deviation of Gaussian shape – the array shape of noise to be returned
If None, returns a scalar noise [default: None]- measurement – scaling factor, for adding fractional errors.
- If 1.0, error is absolute. [default: 1.0]
-
slrealizer.utils.utils.get_first_moments_from_image(image_array, pixel_scale)[source]¶ Returns the first moments in arcsec units numerically computed from an image on a pixel grid
Keyword arguments: image_array – a numpy image array pixel_scale – scale factor for the image in arcsec/pixel
Returns: a tuple of the first moments Ix, Iy in arcsec
-
slrealizer.utils.utils.get_second_moments_from_image(image_array, pixel_scale)[source]¶ Returns the second moments in arcsec units numerically computed from an image on a pixel grid
Keyword arguments: image_array – a numpy image array pixel_scale – scale factor for the image in arcsec/pixel
Returns: a tuple of the second moments Ixx, Ixy, Iyy in arcsec
Useful Constants¶
The constants module provides a number of constants used by the SLRealizer worker class and its descendants.