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. SLRealizer objects 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

get_obs_info(obsID=None, rownum=None)[source]
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]

make_object_table(object_table_path, source_table_path=None, include_std=False)[source]

Generates the object table from the given source table at source_table_path by averaging the properties for each filter, and saves it as object_table_path.

make_source_table_rowbyrow(save_file, method='analytical')[source]

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

get_lens_info(objID=None, rownum=None)[source]
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

estimate_hsm(obs_info, lens_info)[source]
get_lens_info(objID=None, rownum=None)[source]
make_source_table_vectorized(save_file)[source]

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.

class slrealizer.data.dataloader.Dataloader[source]

Utility class for reading in data files and doing some operations, such as querying or basic preprocessing, on them.

read(filename, is_test)[source]

Reads in the data file

read(filename, is_test)[source]

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.e1e2_to_ephi(e1, e2)[source]
slrealizer.utils.utils.ephi_to_e1e2(e, phi)[source]
slrealizer.utils.utils.flux_to_mag(flux, zeropoint_mag=0.0, from_unit=None, to_unit=None)[source]
slrealizer.utils.utils.fwhm_to_sigma(fwhm)[source]
slrealizer.utils.utils.get_1D_columns(multidimColNames, table)[source]
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

slrealizer.utils.utils.hlr_to_sigma(hlr)[source]
slrealizer.utils.utils.mag_to_flux(mag, zeropoint_mag=0.0, from_unit=None, to_unit=None)[source]
slrealizer.utils.utils.physical_to_pixel(physicalPos, canvas_size, pixel_scale)[source]
slrealizer.utils.utils.pixel_to_physical(pixelPos, canvas_size, pixel_scale)[source]
slrealizer.utils.utils.return_mean_properties(lens_array)[source]

returns the mean value of flux, 1st moment of x, 1st moment of y, qzz, qxy, qyy, flux_err, 1st moment x error, 1st moment y error, qxx error, qxy error, and qyy error

slrealizer.utils.utils.scale_mag_as_flux(mag, flux_scale=1.0)[source]

Identical to from_flux_to_mag(from_mag_to_flux(mag)*flux_scale)

Useful Constants

The constants module provides a number of constants used by the SLRealizer worker class and its descendants.

slrealizer.utils.constants.get_SDSS_pixel_arcsec_conversion()[source]
slrealizer.utils.constants.get_ellipticity_cut()[source]
slrealizer.utils.constants.get_filter_AB_offset()[source]
slrealizer.utils.constants.get_first_moment_err()[source]
slrealizer.utils.constants.get_first_moment_err_std()[source]
slrealizer.utils.constants.get_flux_err()[source]
slrealizer.utils.constants.get_flux_err_std()[source]
slrealizer.utils.constants.get_second_moment_err()[source]
slrealizer.utils.constants.get_second_moment_err_std()[source]
slrealizer.utils.constants.get_x_max()[source]
slrealizer.utils.constants.get_x_min()[source]
slrealizer.utils.constants.get_y_max()[source]
slrealizer.utils.constants.get_y_min()[source]
slrealizer.utils.constants.return_obs_RA_DEC()[source]

Return OM10’s lensed system’s position

slrealizer.utils.constants.return_zeropoint()[source]

returns zeropoint for the SDSS magnitude system