slsim.Microlensing package¶
Subpackages¶
- slsim.Microlensing.source_morphology package
- Submodules
- slsim.Microlensing.source_morphology.agn module
- slsim.Microlensing.source_morphology.gaussian module
- slsim.Microlensing.source_morphology.source_morphology module
SourceMorphologySourceMorphology.arcsecs_to_metres()SourceMorphology.get_kernel_map()SourceMorphology.kernel_mapSourceMorphology.length_xSourceMorphology.length_ySourceMorphology.metres_to_arcsecs()SourceMorphology.num_pix_xSourceMorphology.num_pix_ySourceMorphology.pixel_scaleSourceMorphology.pixel_scale_mSourceMorphology.pixel_scale_xSourceMorphology.pixel_scale_x_mSourceMorphology.pixel_scale_ySourceMorphology.pixel_scale_y_m
- slsim.Microlensing.source_morphology.supernovae module
- Module contents
Submodules¶
slsim.Microlensing.lightcurve module¶
- class slsim.Microlensing.lightcurve.MicrolensingLightCurve(magnification_map: MagnificationMap, time_duration: float, point_source_morphology: str = 'gaussian', kwargs_source_morphology: dict = {})[source]¶
Bases:
objectClass to generate microlensing lightcurve(s) for a single source based on the magnification map, source morphology, and lens properties.
- property convolved_map¶
Get the convolved map i.e., the magnification map convolved with the source morphology.
- 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
- get_convolved_map(return_source_morphology=False)[source]¶
Get the convolved map based on the source morphology.
- Parameters:
return_source_morphology – Whether to return the source morphology object or not. Default is False.
- Returns:
The convolved map and the source morphology object if requested. Otherwise, only the convolved map is returned.
- Return type:
numpy.ndarray or tuple
- property magnification_map¶
Get the magnification map.
- property time_duration_observer_frame¶
Get the lightcurve time duration in observer frame.
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:
objectClass 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.
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).
- 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.
- property tracks¶
Returns the cached track coordinates on the magnification map, generated for the point source.
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:
objectClass 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.