slsim.Microlensing package

Subpackages

Submodules

slsim.Microlensing.lightcurve module

class slsim.Microlensing.lightcurve.MicrolensingLightCurve(magnification_map: MagnificationMap, observation_time_array: ndarray, point_source_morphology: str = 'gaussian', kwargs_source_morphology: dict = {}, source_morphology_instance=None)[source]

Bases: object

Class to generate microlensing lightcurve(s) for a single source based on the magnification map, source morphology, and lens properties.

generate_lightcurves(source_redshift, cosmo, lightcurve_type='magnitude', effective_transverse_velocity=1000, num_lightcurves=1, x_start_position=None, y_start_position=None, phi_travel_direction=None)[source]

Generate lightcurves for a point source based on the convolved map.

Parameters:
  • source_redshift – Redshift of the source

  • cosmo – astropy.cosmology instance for the lens class

  • lightcurve_type – Type of lightcurve to generate, either ‘magnitude’ or ‘magnification’. If ‘magnitude’, the lightcurve is returned in magnitudes normalized to the macro magnification. If ‘magnification’, the lightcurve is returned in magnification without normalization. Default is ‘magnitude’.

  • effective_transverse_velocity – Transverse velocity in source plane (in km/s). Default is 1000 km/s (typical effective velocity of the source with respect to microlenses/stars).

  • num_lightcurves – Number of lightcurves to generate. Default is 1.

  • x_start_position – Starting x position of the lightcurve on the magnification map in arcsec. A value of 0 indicates the center of the magnification map. Default is None. If None, a random position is chosen.

  • y_start_position – Starting y position of the lightcurve on the magnification map in arcsec. A value of 0 indicates the center of the magnification map. Default is None. If None, a random position is chosen.

  • phi_travel_direction – Angle of the travel direction in degrees. Default is None. If None, a random angle is chosen. A value of 0 implies the positive x-axis of the magnification map.

Returns:

A tuple of lightcurves, tracks, and time arrays.

lightcurves: list of lightcurves

tracks: x and y positions (in pixels) on the magnification map grid for the paths used to generate the lightcurves.

time_arrays: list of time arrays for each lightcurve

property magnification_map

Get the magnification map used for this lightcurve generation.

Returns:

MagnificationMap object (see slsim.Microlensing.magmap.MagnificationMap).

Return type:

MagnificationMap

property time_duration_observer_frame

Get the total time duration covered by the observation time array in the observer frame (in days).

Returns:

Time duration in observer frame (in days).

Return type:

float

slsim.Microlensing.lightcurvelensmodel module

class slsim.Microlensing.lightcurvelensmodel.MicrolensingLightCurveFromLensModel(source_redshift, deflector_redshift, kappa_star_images, kappa_tot_images, shear_images, shear_phi_angle_images, ra_lens, dec_lens, deflector_velocity_dispersion, cosmology, kwargs_magnification_map=None, point_source_morphology=None, kwargs_source_morphology=None)[source]

Bases: object

Class to generate microlensing lightcurves based on the microlensing parameters for each image of a source.

property effective_transverse_velocity_images

Returns the effective transverse velocity in the source plane for each image position in the frame of the magnification map by using appropriate transformations. Once calculated, the values are cached for future use.

Returns:

effective_velocities: list containing the effective transverse velocity in km/s for each image of the source.

Returns:

effective_velocities_angles_deg: list containing the angle of the effective transverse velocity in degrees for each image of the source.

Return type:

tuple

generate_magnification_maps_from_microlensing_params()[source]

Generate magnification maps for each image of the source based on the image positions and the lens model.

Returns: magmaps_images: a list which contains the [magnification map for each image of the source].

generate_point_source_lightcurves(time, lightcurve_type='magnitude', num_lightcurves=1)[source]

Generate lightcurves for one single point source with certain size, but for all images of that source based on the lens model. The point source is simulated as a “gaussian”, “agn” (Accretion Disk) or “supernovae”.

The lightcurves are generated based on the microlensing map convolved with the source morphology kernel.

The generated lightcurves will have the same length of time as the “time” array provided.

Parameters:
  • time – Time array for which the lightcurve is needed. NOTE: For time-varying sources (like supernovae), this array dictates the physical elapsed time since the explosion in observer days.

  • lightcurve_type – Type of lightcurve to generate, either ‘magnitude’ or ‘magnification’. If ‘magnitude’, the lightcurve is returned in magnitudes normalized to the macro magnification. If ‘magnification’, the lightcurve is returned in magnification without normalization. Default is ‘magnitude’.

  • num_lightcurves – Default is 1. If require multiple lightcurves for each image using the same magnification map, set this parameter to the number of lightcurves required.

Returns:

lightcurves: numpy array of microlensing magnitudes

with the shape (num_images, num_lightcurves, len(time)). The first dimension is the number of images of the source and the second dimension is the length of the time array.

tracks: list of tracks for each image of the source.

Each track is a list of tuples with the x and y positions of the source at each time step.

time_arrays: list of time arrays for each image of the

source. Each time array is a numpy array with the same length as the time array provided.

Return type:

tuple

generate_point_source_microlensing_magnitudes(time)[source]

Generate microlensing lightcurve magnitudes normalized to the mean magnification for various source morphologies. For single source only, it produces the lightcurve magnitudes for all images of the source.

Parameters:

time – Time array for which the lightcurve is needed (in days). NOTE: For time-varying sources (like supernovae), this array dictates the physical elapsed time since the explosion in observer days.

Returns:

lightcurves_single: numpy array of microlensing magnitudes with the shape (num_images, len(time)).

property lc_start_position

Chooses a random starting position for the lightcurve track on the magnification map. Once set, the starting position remains fixed for subsequent calls.

Returns:

x_start_position: x-coordinate of the starting position on the magnification map (in arcsec).

Returns:

y_start_position: y-coordinate of the starting position on the magnification map (in arcsec).

Return type:

tuple

property lightcurves

Returns the cached lightcurves generated for the point source.

Has shape (num_images, len(time)).

property magmaps_images

Returns the magnification maps for each image of the source.

reset_start_position(x_start_position=None, y_start_position=None)[source]

Resets the starting position for the lightcurve track. If x_start_position and y_start_position are provided, the starting position will be set to those values. Otherwise, a new random starting position will be generated.

Parameters:
  • x_start_position – The new x-coordinate for the starting position on the magnification map (in arcsec)

  • y_start_position – The new y-coordinate for the starting position on the magnification map (in arcsec)

property tracks

Returns the cached track coordinates on the magnification map, generated for the point source.

update_source_morphology(kwargs_source_morphology)[source]

Updates the source morphology parameters (e.g., for a new band) without requiring re-initialization of the class or re-generation of magnification maps.

slsim.Microlensing.magmap module

class slsim.Microlensing.magmap.MagnificationMap(magnifications_array: ndarray = None, kappa_tot: float = None, shear: float = None, kappa_star: float = None, theta_star: float = None, mass_function: str = None, m_solar: float = None, m_lower: float = None, m_upper: float = None, center_x: float = None, center_y: float = None, half_length_x: float = None, half_length_y: float = None, num_pixels_x: int = None, num_pixels_y: int = None, kwargs_IPM: dict = {})[source]

Bases: object

Class to generate magnification maps based on the kappa_tot, shear, kappa_star, etc.

get_pixel_size_meters(source_redshift, cosmo)[source]

Returns the pixel size in meters.

Parameters:
  • source_redshift – redshift of the source.

  • cosmo – astropy.cosmology instance.

Returns:

pixel size in meters.

property magnitudes

Returns the magnitudes of the magnification map normalized by the average magnification.

property mu_ave

Returns the average (macro) magnification of the magnification map.

property num_pixels

Returns the number of pixels in the magnification map in (x, y) format.

property pixel_scales

Returns the pixel scales in (x, y) format.

The units are arcseconds.

property pixel_size

Returns the pixel size in arcseconds.

property smooth_fraction

Returns the convergence fraction of that is due to smooth matter.

property stellar_fraction

Returns the convergence fraction of that is due to stars/compact objects.

Module contents