slsim.Sources package

Subpackages

Submodules

slsim.Sources.source module

class slsim.Sources.source.Source(extended_source_type=None, point_source_type=None, **source_dict)[source]

Bases: object

Class to manage an individual source.

property angular_size

Returns angular size of the extended source.

property ellipticity

Returns ellipticity components of extended source. Defined as:

\[e1 = \frac{1-q}{1+q} * cos(2 \phi) e2 = \frac{1-q}{1+q} * sin(2 \phi)\]

with q being the minor-to-major axis ratio.

property extended_source

Returns the extended source object if it exists, otherwise returns None.

extended_source_magnitude(band)[source]

Get the magnitude of the extended source in a specific band.

Parameters:

band (str) – Imaging band

Returns:

Magnitude of the extended source in the specified band

Return type:

float

property extended_source_position

Extended source position.

Returns:

[x_pos, y_pos]

kwargs_extended_light(band=None)[source]

Provides dictionary of keywords for the source light model(s). Keywords used are in lenstronomy conventions.

Parameters:

band – Imaging band

Returns:

dictionary of keywords for the source light model(s)

kwargs_point_source(band, image_observation_times=None, image_pos_x=None, image_pos_y=None, ps_mag=None)[source]
Parameters:
  • band (str) – Imaging band

  • image_observation_times – Images observation time for an image.

  • image_pos_x – pre-calculated image positions (solutions of the lens equation) RA [arcseconds]

  • image_pos_y – pre-calculated image positions (solutions of the lens equation) DEC [arcseconds]

  • ps_mag – magnitudes of images (or source)

Returns:

source type, list of dictionary in lenstronomy convention

property name

Meaningful name string of the source.

Returns:

name string

property point_source

Returns the point source object if it exists, otherwise returns None.

point_source_magnitude(band, image_observation_times=None)[source]

Get the magnitude of the point source in a specific band.

Parameters:
  • band (str) – Imaging band

  • image_observation_times – Images observation time for an image.

Returns:

Magnitude of the point source in the specified band

Return type:

float

property point_source_position

Point source position. point source could be at the center of the extended source, or it can be off from center of the extended source.

Returns:

[x_pos, y_pos]

point_source_type(image_positions=False)[source]

Type of point source model.

Parameters:

image_positions

Returns:

point source model string, or None

property redshift

Returns source redshift.

surface_brightness_reff(band=None)[source]

Calculate average surface brightness within half light radius of a galaxy.

Parameters:

band – Imaging band

Returns:

average surface brightness within half light radius [mag/arcsec^2]

update_center(area=None, reference_position=None, center_x=None, center_y=None)[source]

Overwrites the source center position.

Parameters:
  • reference_position (2d numpy array) – [RA, DEC] in arc-seconds of the reference from where within a circle the source position is being drawn from

  • area – area (in solid angle arc-seconds^2) to dither the center of the source

  • center_x – RA position [arc-seconds] (optional, otherwise renders within area)

  • center_y – DEC position [arc-seconds] (optional, otherwise renders within area)

Returns:

Source() instance updated with new center position

Module contents

class slsim.Sources.Galaxies(galaxy_list, kwargs_cut, cosmo, sky_area, list_type='astropy_table', catalog_type=None, downsample_to_dc2=False, source_size='Bernardi', extended_source_type='single_sersic', extended_source_kwargs={})[source]

Bases: SourcePopBase

Class describing elliptical galaxies.

draw_galaxies(area, z_max=None)[source]

Draw galaxies within a specified area and redshift limit.

Parameters:
  • (astropy.units.Quantity) (area) – Area in which to draw galaxies (in square arcseconds).

  • z_max – Maximum redshift for the galaxies. If None, no redshift cut is applied.

Returns:

List of drawn galaxy instances.

draw_source(z_max=None, z_min=None, galaxy_index=None)[source]

Choose source at random.

Parameters:
  • z_max – maximum redshift limit for the galaxy to be drawn. If no galaxy is found for this limit, None will be returned.

  • z_min – minimum redshift limit for the galaxy to be drawn. If no galaxy is found for this limit, None will be returned.

  • galaxy_index – index of galaxy to pic (if provided)

Returns:

instance of Source class

draw_source_dict(z_max=None, z_min=None, galaxy_index=None)[source]

Choose source at random.

Parameters:
  • z_max – maximum redshift limit for the galaxy to be drawn. If no galaxy is found for this limit, None will be returned.

  • z_min – minimum redshift limit for the galaxy to be drawn. If no galaxy is found for this limit, None will be returned.

  • galaxy_index – index of galaxy to pic (if provided)

Returns:

dictionary of source

property source_number

Number of sources registered (within given area on the sky)

Returns:

number of sources

property source_number_selected

Number of sources selected (within given area on the sky)

Returns:

number of sources passing the selection criteria

class slsim.Sources.PointPlusExtendedSources(point_plus_extended_sources_list, cosmo, sky_area, kwargs_cut, list_type='astropy_table', catalog_type=None, source_size='Bernadi', point_source_type=None, extended_source_type=None, point_source_kwargs={}, extendedsource_kwargs={})[source]

Bases: Galaxies, SourcePopBase

Class to describe point and extended sources.

draw_source(z_max=None)[source]

Choose source at random.

Parameters:

z_max – maximum redshift limit for the galaxy to be drawn. If no galaxy is found for this limit, None will be returned.

Returns:

instance of Source class

class slsim.Sources.PointSources(point_source_list, cosmo, sky_area, kwargs_cut, list_type='astropy_table', point_source_type=None, point_source_kwargs={})[source]

Bases: SourcePopBase

Class to describe point sources.

draw_source(z_max=None, z_min=None, point_source_index=None)[source]

Choose source at random within the selected redshift range.

Parameters:
  • z_max – maximum redshift limit for the point source to be drawn. If no point source is found for this limit, None will be returned.

  • z_min – minimum redshift limit for the point source to be drawn. If no point source is found for this limit, None will be returned.

  • point_source_index – index of point source to pick (if provided)

Returns:

instance of Source class

property source_number

Number of sources registered (within given area on the sky)

Returns:

number of sources

property source_number_selected

Number of sources selected (within given area on the sky)

Returns:

number of sources passing the selection criteria

class slsim.Sources.ScotchSources(cosmo: Cosmology, scotch_path: list[str] | str, sky_area=None, transient_types: list[str] | str | None = None, transient_subtypes: dict[list[str]] | None = None, kwargs_cut: dict | None = None, rng: Generator | int | None = None, sample_uniformly: bool = False, exclude_agn: bool = False)[source]

Bases: SourcePopBase

close()[source]
draw_source(*args, **kwargs) Source[source]

Draw a source from the population, returning a Source object. Transients are instantiated as “general_lightcurve” point sources, and hosts (if any) as “double_sersic” extended sources. If the transient is hostless, the Source is an instance of PointSource, otherwise it is an instance of PointPlusExtendedSource.

Returns

Source

The drawn source object. If hostless, an instance of PointSource; otherwise, an instance of PointPlusExtendedSource.

property source_number: int

Number of sources in the population before any selection cuts.

Returns

int

Number of sources.

property source_number_selected: int

Number of sources in the population after applying selection cuts.

Returns

int

Number of sources passing the selection criteria.