slsim.Util package¶
Subpackages¶
Submodules¶
slsim.Util.astro_util module¶
- slsim.Util.astro_util.bring_passband_to_source_plane(passband, redshift)[source]¶
Takes in a passband and converts the wavelengths from the observer to source plane.
- Parameters:
passband – Str or List representing passband data. Either from speclite or a user defined passband represented as a list of lists or arrays. The first must be wavelengths, and the second must be the throughput of signature: [wavelength, throughput].
redshift – Redshift of the source.
- Returns:
List of numpy arrays representing the passband in the source plane.
- slsim.Util.astro_util.calculate_accretion_disk_emission(r_out, r_resolution, inclination_angle, rest_frame_wavelength_in_nanometers, black_hole_mass_exponent, black_hole_spin, eddington_ratio, return_spectral_radiance_distribution=False)[source]¶
This calculates the emission of the accretion disk due to black body radiation. This emission is calculated by summing over all individual pixels.
- Parameters:
r_out – The maximum radial value of the accretion disk. This typically can be chosen as 10^3 to 10^5 [R_g].
r_resolution – The number of points between r = 0 and r = r_out. The final map will be shape (2 * r_resolution), (2 * r_resolution). Higher resolution leads to longer calculations but smoother response functions.
inclination_angle – The tilt of the accretion disk with respect to the observer in [degrees]. Zero degrees is face on, 90 degrees is edge on.
rest_frame_wavelength_in_nanometers – Wavelength in local rest frame in [nanometers].
black_hole_mass_exponent – The log of the black hole mass normalized by the mass of the sun; black_hole_mass_exponent = log_10(black_hole_mass / mass_sun). Typical AGN have an exponent ranging from 6 to 10.
black_hole_spin – The dimensionless spin parameter of the black hole, where the spinless case (spin = 0) corresponds to a Schwarzschild black hole. Positive spin represents the accretion disk’s angular momentum is aligned with the black hole’s spin, and negative spin represents retrograde accretion flow.
eddington_ratio – The desired Eddington ratio defined as a fraction of bolometric luminosity / Eddington luminosity.
return_spectral_radiance_distribution – Boolean flag to reutrn the distribution of spectral radiance (for True), or the sum of the distribution (for False).
- Returns:
The result of the Planck function for a distribution of temperatures, either as an array representing the distribution in the source plane or the sum of this array.
- slsim.Util.astro_util.calculate_accretion_disk_response_function(r_out, r_resolution, inclination_angle, rest_frame_wavelength_in_nanometers, black_hole_mass_exponent, black_hole_spin, corona_height, eddington_ratio)[source]¶
This calculates the response of the accretion disk due to a flash in the illuminating X-ray source in the lamppost geometry. This response function represents the kernel between any driving signal from the point-like source and the accretion disk at a specified wavelength.
This response function is calculated by summing over all individual pixel responses and binning them according to their time lag with a weighting of their wavelength dependent response.
Using this response function assumes: 1) The X-ray point source drives the optical variability. 2) The accretion disk behaves like a black body. 3) There is no significant absorption of the X-rays between the corona and disk. 4) The corona is compact enough that it may be treated like a point source. 5) The accretion disk is itself flat (otherwise cosine(theta_x) != h_corona/R_{*}). 6) The response function can be normalized.
To use the response function: 1) Resample the response function at the time resolution of the signal or resample the signal at units [R_g / c]. 2) The time axis of the response function must then be inverted as these are time lags. 3) Take the convolution between the driving signal and the response function. 4) The time axis of the convolution should then be shifted forward in time by the length of the response function to remain consistent with respect to the driving signal.
- Parameters:
r_out – The maximum radial value of the accretion disk. This typically can be chosen as 10^3 to 10^5 [R_g].
r_resolution – The number of points between r = 0 and r = r_out. The final map will be shape (2 * r_resolution), (2 * r_resolution). Higher resolution leads to longer calculations but smoother response functions.
inclination_angle – The tilt of the accretion disk with respect to the observer in [degrees]. Zero degrees is face on, 90 degrees is edge on.
rest_frame_wavelength_in_nanometers – Wavelength in local rest frame in [nanometers].
black_hole_mass_exponent – The log of the black hole mass normalized by the mass of the sun; black_hole_mass_exponent = log_10(black_hole_mass / mass_sun). Typical AGN have an exponent ranging from 6 to 10.
black_hole_spin – The dimensionless spin parameter of the black hole, where the spinless case (spin = 0) corresponds to a Schwarzschild black hole. Positive spin represents the accretion disk’s angular momentum is aligned with the black hole’s spin, and negative spin represents retrograde accretion flow.
corona_height – The height of the corona in gravitational_radii. Typical choices range from 0 to 100 [R_g].
eddington_ratio – The desired Eddington ratio defined as a fraction of bolometric luminosity / Eddington luminosity.
- Returns:
The normalized response of the accretion disk as a function of time lag in units [R_g / c].
- slsim.Util.astro_util.calculate_dt_dlx(radial_map, temperature_map, corona_height)[source]¶
This approximates the change in temperature on the accretion disk due to a change in the incident X-ray flux from the source in the lamppost model.
This approximation follows that the change of temperature due to a change in X-ray energy is small:
temp_disk^4 = temp_viscous^4 + mean_energy_irradiation * geometric_factor
(temp_disk + delta_temp)^4 = temp_viscous^4 + (mean_energy_irradiation + delta_Lx) * geometric_factor
temp_disk^4 + 4 * delta_temp * temp_disk^3 + (order delta_temp^2…) = temp_disk^4 + delta_Lx * geometric_factor
delta_temp / delta_Lx = geometric_factor / (4 * temp_disk^3) + higher order corrections
dt/dlx ~ geometric_factor / (4 * temp_disk^3)
Where temp_viscous is the temperature due to the viscous nature of the black body like disk, mean_energy_irradiation is the average energy of the Xray source (which drops out), and delta_temp is the change in temperature.
A small increase in the illuminating flux is introduced in (2). Terms are expanded and temp_disk^4 is reconstructed on right hand side of equation in (3). Terms are collected in (4), higher order terms are discarded. The fractional change in temperature with respect to flux is approximated to be the derivative in (5) as both delta_temp and delta_Lx are assumed to be small.
- Parameters:
radial_map – A 2-dimension array of radial values on the accretion disk in units [R_g].
temperature_map – A 2-dimensional array of temperature values on the accretion disk in [Kelvin].
corona_height – The height of the corona in units [R]. Typical values range from 0 to 100.
- Returns:
A 2-dimensional map of values representing the change in temperature with respect to a change in X-ray flux.
- slsim.Util.astro_util.calculate_eddington_luminosity(black_hole_mass_exponent)[source]¶
Calculates the Eddington luminosity for a black hole mass exponent. The Eddington luminosity is the theoretical limit of the accretion rate due to radiation pressure for spherical (Bondi) accretion.
- Eddington_luminosity = 4 * pi * G * black_hole_mass * mass_proton
c / sigma_thompson
- Parameters:
black_hole_mass_exponent – The log of the black hole mass normalized by the mass of the sun; black_hole_mass_exponent = log_10(black_hole_mass / mass_sun). Typical AGN have an exponent ranging from 6 to 10.
- Returns:
Eddington luminosity
- slsim.Util.astro_util.calculate_geometric_contribution_to_lamppost_model(radial_map, corona_height)[source]¶
This calculates the geometric scaling factor of the X-ray luminosity (L_x) as seen by the accretion disk due to the varying distances involved in the lamppost model.
According to Equation (2) of Cackett+ (2007), the scaling factor of L_x due to the geometry of the system is:
(1-A) cos(theta_x) / (4 * pi * sigma_sb * R_{*}^{2})
Where A is the albedo of the disk (taken to be zero for complete absorption), theta_x is the angle of incidence between the X-rays and the disk (zero is normal to the disk), cos(theta_x) is taken to be h_corona / R_{*} for a geometrically flat disk, sigma_sb is the Stefan-Boltzmann constant, and R_{*} is the distance between the X-ray source and any part of the disk.
- Parameters:
radial_map – A 2-dimension array of radial values on the accretion disk in units [R_g], potentially generated with the create_radial_map function above.
corona_height – The height of the corona in units [R_g]. Typical choices range from 0 to 100.
- Returns:
A 2-dimensional array of multiplicative factors representing the impact of geometry between the lamppost source and the accretion disk acting on the fluctuations of the X-ray source.
- slsim.Util.astro_util.calculate_gravitational_radius(black_hole_mass_exponent)[source]¶
Calculates the gravitational radius (R_g) of a black hole. The gravitational.
radius defines the typical size scales around a black hole for AGN. The formula for gravitational radius is: R_g = G * mass / c^2
- Parameters:
black_hole_mass_exponent – The log of the black hole mass normalized by the mass of the sun; black_hole_mass_exponent = log_10(black_hole_mass / mass_sun). Typical AGN have an exponent ranging from 6 to 10.
- Returns:
The gravitational radius in astropy length units.
- slsim.Util.astro_util.calculate_mean_time_lag(response_function)[source]¶
This helper function takes in a response function (or any array) and calculates the weighted average following:
weighted_average = sum(time_axis * response_function) / sum(response_function)
The function np.nansum() is used in favor of np.sum() to avoid issues with np.nan values.
- Parameters:
response_function – The input response function (or any array) to calculate the weighted average from (e.g. the output of astro_util.calculate_accretion_disk_response_function() which represents the accretion disk’s response function). Weighting is in the same units of spacing between values. For response functions generated with this code, these spacings are of units [R_g / c] by default.
- Returns:
A single value representing the weighted average. Units are equivalent to the x-axis spacings of the response_function (or array). For default response functions generated with this code, the output has units [R_g / c].
- slsim.Util.astro_util.calculate_time_delays_on_disk(radial_map, phi_map, inclination_angle, corona_height)[source]¶
This calculates the time lags due to light travel time from a point source located above the black hole to simulate the lamppost geometry. The corona is defined as the point-souce approximation of the X-ray variable source.
The light travel time lags, tau(r, phi), are defined in the lamppost geometry through:
- c * tau(r, phi|h_corona, inclination) = sqrt(h_corona^2 + r^2) +
h_corona * cos(inclination) - r * sin(inclination) * cos(phi)
- Parameters:
radial_map – A 2-dimension array of radial values on the accretion disk in units [R_g].
inclination_angle – The tilt of the accretion disk with respect to the observer in [degrees]. Zero degrees is face on, 90 degrees is edge on.
corona_height – The height of the corona in gravitational_radii. Typical choices range from 0 to 100 [R_g].
- Returns:
A 2-dimensional array of time delays between the corona and the accretion disk in units of [R_g / c].
- slsim.Util.astro_util.cone_radius_angle_to_physical_area(radius_rad, z, cosmo)[source]¶
Convert cone radius angle to physical area at a specified redshift.
This function computes the physical area, in square megaparsecs (Mpc^2), corresponding to a specified cone radius angle at a given redshift. The calculation is based on the angular diameter distance, which is dependent on the adopted cosmological model. This is particularly useful in cosmological simulations and observations where the physical scale of structures is inferred from angular measurements.
- Parameters:
radius_rad (float) – The half cone angle in radians.
z (float) – The redshift at which the physical area is calculated.
cosmo (astropy.cosmology instance) – The astropy cosmology instance used for the conversion.
- Returns:
The physical area in square megaparsecs (Mpc^2) for the given cone radius and redshift.
- Return type:
float :note: The calculation incorporates the angular diameter distance, highlighting the interplay between angular measurements and physical scales in an expanding universe.
- slsim.Util.astro_util.convert_black_hole_mass_exponent_to_mass(black_hole_mass_exponent)[source]¶
This function takes in the log of the black hole mass normalized by the mass of the sun and returns the mass of the black hole.
- Parameters:
black_hole_mass_exponent – The log of the black hole mass normalized by the mass of the sun; black_hole_mass_exponent = log_10(black_hole_mass / mass_sun). Typical AGN have an exponent ranging from 6 to 10.
- Returns:
The mass of the black hole in astropy units.
- slsim.Util.astro_util.convert_passband_to_nm(passband, wavelength_unit_input=Unit('Angstrom'))[source]¶
Takes in a passband and converts the wavelengths to nanometers.
- Parameters:
passband – Str or List representing passband data. Either from speclite or a user defined passband represented as a list of lists or arrays. The first must be wavelengths, and the second must be the throughput of signature: [wavelength, throughput].
wavelength_unit_input – Astropy unit representing the input wavelength units. Speclite passbands are typically in angstroms, but a user defined passband may have any unit convenient for their purposes.
- Returns:
List of numpy arrays representing the passband with units of nanometers.
- slsim.Util.astro_util.create_phi_map(r_out, r_resolution, inclination_angle)[source]¶
This creates a 2-dimentional array of phi values at all positions where the maximum radius is defined by r_out, and the radial resolution is defined by r_resolution.
- Parameters:
r_out – The maximum radial value in [R_g]. For an accretion disk, this can be 10^3 to 10^5.
r_resolution – The number of points between r = 0 and r = r_out. The final map will be shape (2 * r_resolution), (2 * r_resolution)
inclination_angle – The inclination of the plane of the accretion disk with respect to the observer in [degrees].
- Returns:
A 2-dimensional array of phi values at radial positions of shape ((2 * r_resolution), (2 * r_resolution)) in the projected plane of the sky, such that phi = 0 is nearest to the observer.
- slsim.Util.astro_util.create_radial_map(r_out, r_resolution, inclination_angle)[source]¶
This creates a 2-dimentional array of radial positions where the maximum radius is defined by r_out, and the radial resolution is defined by r_resolution.
- Parameters:
r_out – The maximum radial value in [R_g]. For an accretion disk, this can be 10^3 to 10^5.
r_resolution – The number of points between r = 0 and r = r_out. The final map will be shape (2 * r_resolution), (2 * r_resolution).
inclination_angle – The inclination of the plane of the accretion disk with respect to the observer in [degrees].
- Returns:
A 2D array of radial positions of shape ((2 * r_resolution), (2 * r_resolution)) in the projected plane of the sky.
- slsim.Util.astro_util.define_bending_power_law_psd(log_breakpoint_frequency, low_frequency_slope, high_frequency_slope, frequencies)[source]¶
This function defines the power spectrum density (PSD) of a bending power law. Note that bending power law is also sometimes referred to as a broken power law.
- Parameters:
log_breakpoint_frequency – The log_{10} of the breakpoint frequency where the power law changes slope, in units [1/days]. Typical values range between -3.5 and 1.0.
low_frequency_slope – The (negative) log-log slope of the PSD for low frequencies when the power is plotted against frequency in units [1/days]. Typically ~1.0, but can range from 0.0 to 2.0.
high_frequency_slope – the (negative) log-log slope of the PSD for high frequencies when the power is plotted against frequency in units [1/days]. Typically ranges from 2.0 to 4.0, and should be a higher power than low_frequency_slope (e.g. it should drop off with frequency rapidly).
frequencies – A numpy array or list of frequencies to calculate the PSD at. This array is well defined through the define_frequencies() function. Note that define_frequencies() will prepare minimum and maximum frequencies, and there will not be a “bend” in the PSD if the breakpoint frequency does not fall within this range.
- Returns:
The PSD of the bending power law defined through the input parameters.
- slsim.Util.astro_util.define_frequencies(length_of_light_curve, time_resolution)[source]¶
This function defines the useful frequencies for generating a power spectrum density (PSD). Frequencies below the low frequency limit will not contribute to the light curve. Frequencies above the high frequency limit (the Nyquist frequency) will not be able to be probed with the time_resolution, and will suffer from aliasing.
- Parameters:
length_of_light_curve – The total length of the light curve to simulate, in units of [days]. The generated frequencies will have a 10 times lower limit than required, as the function generate_signal_from_psd will generate extended light curves to deal with periodicity issues.
time_resolution – The time resolution to generate the light curve at, in units of [days]. This parameter defines the high frequency limit. If generating light curves takes too long, consider increasing this parameter to generate fewer frequencies.
- Returns:
A numpy array of the frequencies that are probed by the light curve in [1/days].
- slsim.Util.astro_util.downsample_passband(passband, output_delta_wavelength, wavelength_unit_input=Unit('Angstrom'), wavelength_unit_output=Unit('Angstrom'))[source]¶
Takes in a throughput at one resolution and outputs a throughput at a downsampled resolution. This will speed up calculations which must be done for multiple wavelengths, especially for objects which do not have significant changes in signal over short wavelength steps.
- Parameters:
passband – Str or List representing passband data. Either from speclite or a user defined passband represented as a list of lists or arrays. The first must be wavelengths, and the second must be the throughput of signature: [wavelength, throughput].
output_delta_wavelength – Int, this represents the desired spacing between wavelengths of the output passband.
wavelength_unit_input – Astropy unit representing the input wavelength units. Speclite filters default to units of angstroms.
wavelength_unit_output – Astropy unit representing the output wavelength units.
- Returns:
List of numpy arrays representing the downsampled passband with signature [wavelength, throughput].
- slsim.Util.astro_util.eddington_ratio_to_accretion_rate(black_hole_mass_exponent, eddington_ratio, efficiency=0.1)[source]¶
Calculates the mass that must be accreted by the accretion disk for the accretion disk to radiate at the desired Eddington ratio.
Bolometric_luminosity = mass_accreted * c^2 * efficiency
- Parameters:
black_hole_mass_exponent – The log of the black hole mass normalized by the mass of the sun; black_hole_mass_exponent = log_10(black_hole_mass / mass_sun). Typical AGN have an exponent ranging from 6 to 10.
eddington_ratio – The desired Eddington ratio defined as a fraction of bolometric luminosity / Eddington luminosity.
efficiency – The efficiency of mass-to-energy conversion in accretion disk
- Returns:
Required mass_accreted for accretion disk to radiate at the desired Eddington ratio
- slsim.Util.astro_util.extract_light_curve(convolution_array, pixel_size, effective_transverse_velocity, light_curve_time_in_years, pixel_shift=0, x_start_position=None, y_start_position=None, phi_travel_direction=None, return_track_coords=False, random_seed=None)[source]¶
Extracts a light curve from the convolution between two arrays by selecting a trajectory and calling pull_value_from_grid at each relevant point. If the light curve is too long, or the size of the object is too large, a “light curve” representing a constant magnification is returned.
- Parameters:
convolution_array – The convolution between a flux distribtion and the magnification array due to microlensing. Note coordinates on arrays have (y, x) signature.
pixel_size – Physical size of a pixel in the source plane, in meters
effective_transverse_velocity – effective transverse velocity in the source plane, in km / s
light_curve_time_in_years – duration of the light curve to generate, in years
pixel_shift – offset of the SMBH with respect to the convolved map, in pixels
x_start_position – None or the x coordinate to start pulling a light curve from, in pixels
y_start_position – None or the y coordinate to start pulling a light curve from, in pixels
phi_travel_direction – None or the angular direction of travel along the convolution, in degrees
return_track_coords – boolean toggle to return the x and y coordinates of the track in pixels
- Returns:
list representing the microlensing light curve
- slsim.Util.astro_util.generate_signal(length_of_light_curve, time_resolution, log_breakpoint_frequency=-2, low_frequency_slope=1, high_frequency_slope=3, mean_magnitude=0, standard_deviation=0.1, normal_magnitude_variance=True, zero_point_mag=0, input_freq=None, input_psd=None, seed=None)[source]¶
This function creates a stochastic signal to model AGN X-ray variability. This may be used to generate either a bending power law signal, or a signal following any input power spectrum density (psd).
- Parameters:
length_of_light_curve – The total length of the light curve to simulate, in units of [days]. The generated signal will be 10 times longer than this to deal with periodicity issues which may arise.
time_resolution – The time spacing between regularly sampled points in the light curve, in units of [days]. This parameter defines the high frequency limit of the PSD and the number of points defining the light curve. If generating light curves takes too long, consider increasing this parameter to generate fewer frequencies.
log_breakpoint_frequency – The log_{10} of the breakpoint frequency as defined in the bending power law, in units days^{-1}. Typical values range from -3.5 to 1.0.
low_frequency_slope – The (negative) log-log slope of the PSD for low frequencies when the power is plotted against frequency in units [1/days]. Typically ~1.0, but can range from 0.0 to 2.0.
high_frequency_slope – The (negative) log-log slope of the PSD for high frequencies when the power is plotted against frequency in units [1/days]. Typically ranges from 2.0 to 4.0, and should be a higher power than low_frequency_slope (e.g. it should drop off with frequency rapidly).
mean_magnitude – The mean value of the light curve to simulate. The PSD will produce a stochastic light curve with some mean and some standard deviation. This parameter will fix the mean value of the output light curve.
standard_deviation – The desired standard deviation (std) of the light curve’s variability.
normal_magnitude_variance – Bool, a toggle between whether variability is calculated in magnitude or flux units. If True, variability will be assumed to have the given standard deviation in magnitude. If False, variability will assume to have the given standard deviation in flux. Note that if False, “negative flux” becomes likely for standard deviation > 0.5 mag, and will return a ValueError. If everything is assumed to be in flux units, simply insert your mean flux for “mean_magnitude” and define “normal_magnitude_variance” = True.
zero_point_mag – The reference amplitude to calculate the zero point magnitude.
input_freq – None or an input array of frequencies in [1/days] to use to overwrite the frequencies generated by astro_util.generate_frequencies(). If none, no action will be taken. If an array of frequencies is input, this array will override the frequencies used o generate the signal. This must be equal length to input_psd. This may be useful for testing.
input_psd – None or an input array representing the PSD at input_freq. If None, no action will be taken. If an array is input, this must be of equal length to the array input_freq. Then this input_psd will override the bending power law generated using astro_util.define_bending_power_law_psd(). This may be useful for defining more complex power spectrums, or other testing.
seed – None or value. If a value is provided, the random seed may be defined within this function.
- slsim.Util.astro_util.generate_signal_from_bending_power_law(length_of_light_curve, time_resolution, log_breakpoint_frequency=-2, low_frequency_slope=1, high_frequency_slope=3, mean_magnitude=0, standard_deviation=None, normal_magnitude_variance=True, zero_point_mag=0, seed=None)[source]¶
Uses astro_util.generate_signal_from_psd() to create an intrinsic bending power law signal to use as a model for X-ray variability. Creates a light curve which can be sampled from using sample_intrinsic_signal().
- Parameters:
length_of_light_curve – Total length of desired light curve in [days].
time_resolution – The time spacing between observations in [days].
log_breakpoint_frequency – The log_{10} of the characteristic breakpoint frequency in the bending power law. Typically between -3.5 and 1.0.
low_frequency_slope – The (negative) log-log slope of the power spectrum density on the low frequency side of the breakpoint frequency. Typically between 0.0 and 2.0.
high_frequency_slope – The (negative) log-log slope of the power spectrum density on the high frequency side of the breakpoint frequency. Typically between 2.0 and 4.0, and higher than the low_frequency_slope.
mean_magnitude – The desired mean value of the light curve.
standard_deviation – The desired standard deviation of the light curve.
normal_magnitude_variance – Bool, a toggle between whether variability is calculated in magnitude or flux units. If True, variability will be assumed to have the given standard deviation in magnitude. If False, variability will assume to have the given standard deviation in flux. Note that if False, “negative flux” becomes likely for standard deviation > 0.5 mag, and will return a ValueError. If everything is assumed to be in flux units, simply insert your mean flux for “mean_magnitude” and define “normal_magnitude_variance” = True.
zero_point_mag – The reference amplitude to calculate the zero point magnitude.
seed – The random seed to be input for reproducability.
- Returns:
Two arrays, the time_array and the magnitude_array of the variability.
- slsim.Util.astro_util.generate_signal_from_generic_psd(length_of_light_curve, time_resolution, input_frequencies, input_psd, mean_magnitude=0, standard_deviation=None, normal_magnitude_variance=True, zero_point_mag=0, seed=None)[source]¶
Uses astro_util.generate_signal_from_psd() to create an intrinsic signal from any input power spectrum to use as a model for X-ray variability. Creates a light curve which can be sampled from using sample_intrinsic_signal().
- Parameters:
length_of_light_curve – Total length of desired light curve in [days].
time_resolution – The time spacing between observations in [days].
input_frequencies – The input frequencies that correspond to the input power spectrum in [1/days]. This can be generated using astro_util.define_frequencies().
input_psd – The input power spectrum. This must be the same size as input_frequencies.
mean_magnitude – The desired mean value of the light curve.
standard_deviation – The desired standard deviation of the light curve.
normal_magnitude_variance – Bool, a toggle between whether variability is calculated in magnitude or flux units. If True, variability will be assumed to have the given standard deviation in magnitude. If False, variability will assume to have the given standard deviation in flux. Note that if False, “negative flux” becomes likely for standard deviation > 0.5 mag, and will return a ValueError. If everything is assumed to be in flux units, simply insert your mean flux for “mean_magnitude” and define “normal_magnitude_variance” = True.
zero_point_mag – The reference amplitude to calculate the zero point magnitude.
seed – The random seed to be input for reproducability.
- Returns:
Two arrays, the time_array in [days] and the magnitude_array of the variability.
- slsim.Util.astro_util.get_value_if_quantity(variable)[source]¶
Extracts the numerical value from an astropy Quantity object or returns the input if not a Quantity.
This function checks if the input variable is an instance of an astropy Quantity. If it is, the function extracts and returns the numerical value of the Quantity. If the input is not a Quantity, it returns the input variable unchanged.
- Parameters:
variable (Quantity or any) – The variable to be checked and possibly converted. Can be an astropy Quantity or any other data type.
- Returns:
The numerical value of the Quantity if the input is a Quantity; otherwise, the input variable itself.
- Return type:
float or any
- slsim.Util.astro_util.normalize_light_curve(light_curve, mean_magnitude, standard_deviation=None)[source]¶
This function takes in a light curve and redefines its mean and standard deviation. It may also be used to re-normalize any time series.
- Parameters:
light_curve – A time series list or array which represents a one-dimensional light curve. This function does not require any specific units or spacings.
mean_magnitude – The new mean value of the light curve. This is done through a simple shifting of the y-axis.
standard_deviation – The new standard deviation of the light curve. Note this only makes sense for a variable signal (e.g. a constant signal cannot be given a new standard_deviation). A negative standard deviation will invert the x and y axis.
- Returns:
A rescaled version of the original light curve, with new mean and standard deviation.
- slsim.Util.astro_util.planck_law(temperature, wavelength_in_nanometers)[source]¶
This takes a temperature in Kelvin and a wavelength in nanometers, and returns the spectral radiance of the object as if it emitted black body radiation. This is the spectral radiance per wavelength as opposed to per frequency, leading to dependence as wavelength^(-5).
Planck’s law states:
B(T, lam) = (2 * h * c^2 / lam^5) * (1 / (e^(h * c / (lam * k_B * T)) - 1))
- Parameters:
temperature – Temperature of the black body, in [Kelvin]
wavelength_in_nanometers – Emitted wavelength in local rest frame in [nanometers]
- Returns:
The spectral radiance of the black body
- slsim.Util.astro_util.planck_law_derivative(temperature, wavelength_in_nanometers)[source]¶
This numerically approximates the derivative of the spectral radiance with respect to temperature in Kelvin.
Numerically calculating this derivative uses the limit definition of a derivative.
d(f(x)) ~ lim (delta_x -> 0) (f(x+delta_x) - f(x)) / delta_x
- Parameters:
temperature – Temperature of the black body, in [Kelvin].
wavelength_in_nanometers – Emitted wavelength in local rest frame in [nanometers].
- Returns:
The derivative of the spectral radiance with respect to temperature for a black body.
- slsim.Util.astro_util.pull_value_from_grid(array_2d, x_position, y_position)[source]¶
This approximates the point (x_position, y_position) in a 2d array of values. x_position and y_position may be decimals, and are assumed to be measured in pixels relative to the original grid. This uses bilinear interpolation (powered by scipy.interpolate.RegularGridInterpolator) with ‘edge’ behavior for points at or slightly beyond the original grid boundaries, by interpolating on an edge-padded version of the grid.
- Parameters:
array_2d – 2 dimensional array of values.
x_position – x coordinate in array_2d in pixels. Valid range is [0, array_2d.shape[0]].
y_position – y coordinate in array_2d in pixels. Valid range is [0, array_2d.shape[1]].
- Returns:
approximation of array_2d at point (x_position, y_position)
- slsim.Util.astro_util.spin_to_isco(spin)[source]¶
Converts dimensionless spin parameter of a black hole to the innermost stable circular orbit in gravitational radii [R_g = GM/c^2, with units length]
- Parameters:
spin – Dimensionless spin of black hole, ranging from -1 to 1. Positive values represent orbits aligned with the black hole spin.
- Returns:
Float value of innermost stable circular orbit, ranging from 1 to 9.
- slsim.Util.astro_util.theta_star_physical(z_lens: float, z_src: float, cosmo: Cosmology, m: float = 1) tuple[source]¶
Calculate the size of the Einstein radius of a point mass lens in the lens and source planes, in meters.
- Parameters:
z_lens – lens redshift
z_src – source redshift
cosmo – an astropy.cosmology instance.
m – point mass lens mass in solar mass units
- Return theta_star:
theta_star in the lens plane in arcseconds
- Return theta_star_lens:
theta_star in the lens plane in meters
- Return theta_star_src:
theta_star in the source plane in meters
- slsim.Util.astro_util.thin_disk_temperature_profile(radial_points, black_hole_spin, black_hole_mass_exponent, eddington_ratio)[source]¶
Calculates the thin disk temperature profile at all given radial positions assuming the Shakura-Sunyaev geometricly thin, optically thick accretion disk.
The formula for a thin disk temperature profile is:
- T(r) = (3 * G * black_hole_mass * accretion_rate * (1 - (r_min / r)**0.5)
/ (8 * pi * sigma_sb * r^3))^0.25
- Parameters:
radial_points – A list of the radial positions in gravitational units to calculate the temperature at.
black_hole_spin – The dimensionless spin parameter of the black hole, where the spinless case (spin = 0) corresponds to a Schwarzschild black hole. Positive spin represents the accretion disk’s angular momentum is aligned with the black hole’s spin, and negative spin represents retrograde accretion flow.
black_hole_mass_exponent – The log of the black hole mass normalized by the mass of the sun; black_hole_mass_exponent = log_10(black_hole_mass / mass_sun). Typical AGN have an exponent ranging from 6 to 10.
eddington_ratio – The fraction of the eddington limit which the black hole is accreting at.
- Returns:
The temperature of the accretion disk at all radii in units Kelvin.
slsim.Util.catalog_util module¶
- slsim.Util.catalog_util.match_cosmos_source(angular_size, physical_size, e1, e2, n_sersic, processed_cosmos_catalog, catalog_path, max_scale=1, match_n_sersic=False)[source]¶
This function matches the parameters in source_dict to find a corresponding source in the COSMOS catalog. The parameters being matched are:
physical size <= size_tol where size_tol starts at 0.5 kPc and increases by 0.2 until match
axis ratio <= q_tol where q_tol starts at 0.1 and increases by 0.05 until match
n_sersic
When many matches are found, the match with the best n_sersic is taken.
- Parameters:
angular_size – angular size of the source [arcsec]
physical_size – physical size of the source [kpc]
e1 – eccentricity modulus
e2 – eccentricity modulus
source_dict (dict or astropy.table.Table) – Source properties. May be a dictionary or an Astropy table. This dict or table should contain atleast redshift, a magnitude in any band, sersic index, angular size in arcsec, and ellipticities e1 and e2. eg: {“z”: 0.8, “mag_i”: 22, “n_sersic”: 1, “angular_size”: 0.10, “e1”: 0.002, “e2”: 0.001}. One can provide magnitudes in multiple bands.
processed_cosmos_catalog – the returned object from calling process_cosmos_catalog()
catalog_path – path to the COSMOS_23.5_training_sample directory. Example: catalog_path = “/home/data/COSMOS_23.5_training_sample”
max_scale (int or float) – The COSMOS image will be scaled to have the desired angular size. Scaling up results in a more pixelated image. This input determines what the maximum up-scale factor is.
match_n_sersic (bool) – determines whether to match based off of the sersic index as well. Since n_sersic is usually undefined and set to 1 in SLSim, this is set to False by default.
- Returns:
tuple(ndarray, float, float, int) This is the raw image matched from the catalog, the scale that the image needs to match angular size, the angle of rotation needed to match the desired e1 and e2, and the galaxy ID.
- slsim.Util.catalog_util.process_cosmos_catalog(cosmo, catalog_path)[source]¶
This function filters out sources in the catalog so that only the nearby, well-resolved galaxies with high SNR remain. Thus, we perform the following cuts: 1. redshift < 1 2. apparent magnitude < 20 3. half light radius > 10 pixels
- Parameters:
cosmo – instance of astropy cosmology
catalog_path (string) – path to the COSMOS_23.5_training_sample directory. Example: catalog_path = “/home/data/COSMOS_23.5_training_sample”
- Returns:
merged astropy table with only the well-resolved galaxies
slsim.Util.color_transformations module¶
- slsim.Util.color_transformations.LSST_to_SDSS(lsst_u, lsst_g, lsst_r, lsst_i, lsst_z)[source]¶
Converts the five bands LSST magnitudes to the SDSS magnitudes using empirically derived transformations. These transformations are only valid for red galaxies and should not be used for blue galaxies or other stellar populations. The coefficients are based on polynomial fits to color terms.
- Parameters:
lsst_u (float) – u-band LSST magnitude
lsst_g (float) – g-band LSST magnitude
lsst_r (float) – r-band LSST magnitude
lsst_i (float) – i-band LSST magnitude
lsst_z (float) – z-band LSST magnitude
- Returns:
A list of SDSS-equivalent magnitudes in the order [u, g, r, i, z].
- Return type:
list
slsim.Util.coolest_slsim_interface module¶
slsim.Util.cosmo_util module¶
- slsim.Util.cosmo_util.z_scale_factor(z_old, z_new, cosmo)[source]¶
- Parameters:
z_old (float) – The original redshift.
z_new (float) – The redshift where the object will be placed.
cosmo (astropy.cosmology.FLRW, optional) – The cosmology object. Defaults to a FlatLambdaCDM model if None.
- Returns:
The multiplicative pixel size scaling factor.
- Return type:
float
slsim.Util.k_correction module¶
- slsim.Util.k_correction.kcorr_sdss(mags_sdss, redshift, responses=['sdss_u0', 'sdss_g0', 'sdss_r0', 'sdss_i0', 'sdss_z0'], band_shift=0.0)[source]¶
Computes the astronomical K correction for galaxies on the SDSS broadband filters using the kcorrect module based on Blanton and Roweis 2007.
- Parameters:
mags_sdss – numpy.ndarray The multi-band SDSS magnitudes of all the targets. A 2D array of uncertainties.core.Variable, with bands along the rows and targets along the columns. If your magnitude is m1 and associated error is e1, uncertainties.core.Variable should be: ufloat(m1, e1).
redshift – numpy.ndarray An array of the redshifts of the deflectors. A 1D array of floats.
responses – list of str The SDSS bands for which the magnitude is provided.
responses_out – list of str The SDSS bands on which you want the K-corrections.
- Returns:
numpy.ndarray A 2-D array with K-correction for all the targets, with each row containing the K-correction for output bands for each target.
slsim.Util.mag2errors module¶
- slsim.Util.mag2errors.get_errors_Poisson(app_mag, zeropoint, exptime)[source]¶
This function provides rough photometric errors using the photometric magnitudes, assuming only the statistical error due to Poisson noise in the counts. Since, the photometric errors are not known in the LSST mock catalogs, these are just very rough estimates.
It requires the apparent magnitude, photometric zeropoint and the exposure time.
input_params:
app_mag: the apparent magnitude of the object. type: float or 1-D array.
zeropoint: the photometric zeropoint in the given band. type: float or 1-D array. Note that photometric zeropoint will be different for different bands
exptime: the exposure time for the given band (in seconds) type: float
slsim.Util.param_util module¶
- slsim.Util.param_util.additional_bkg_rms_with_rescaled_coadd(image, original_rms, degraded_rms, use_noise_diff=True)[source]¶
Computes additinal background noise based on RMS values before and after degradation.
- Parameters:
image – numpy.ndarray The input image array.
original_rms – float The original root mean square (RMS) noise.
degraded_rms – float The degraded RMS noise.
use_noise_diff – bool, optional If True, approximates noise difference using Gaussian noise, otherwise, applies new Gaussian noise directly. Default is True.
- Returns:
numpy.ndarray The additional noise to be added to the image.
- slsim.Util.param_util.additional_poisson_noise_with_rescaled_coadd(image, original_exp_time, degraded_exp_time, use_noise_diff=True)[source]¶
Computes additional Poisson noise to an image based on the change in exposure time.
- Parameters:
image – numpy.ndarray The input image array.
original_exp_time – numpy.ndarray The original exposure time per pixel.
degraded_exp_time – numpy.ndarray The degraded exposure time per pixel.
use_noise_diff – bool, optional If True, approximates noise difference using Gaussian noise, otherwise, applies Poisson sampling. Default is True.
- Returns:
numpy.ndarray The additional noise to be added to the image.
- slsim.Util.param_util.amplitude_to_magnitude(amplitude, mag_zero_point)[source]¶
Converts source amplitude to magnitude.
The inverse of magnitude_to_amplitude(). :param amplitude: source amplitude in flux :param mag_zero_point: zero point magnitude :returns: source magnitude
- slsim.Util.param_util.average_angular_size(a, b)[source]¶
Computes average angular size using semi major and minor axis.
- Parameters:
a – value of semi major axis in arcsec
b – value of semi minor axis in arcsec
- Returns:
average angular size in arcsec
- slsim.Util.param_util.axis_ratio(a, b)[source]¶
Computes axis ratio using semi major and minor axis.
- Parameters:
a – value of semi major
b – value of semi minor
- Returns:
axis ratio
- slsim.Util.param_util.catalog_with_angular_size_in_arcsec(galaxy_catalog, input_catalog_type='skypy')[source]¶
This function is written to change unit of angular size in skypy galaxy catalog to arcsec. If user is using deflector catalog other than generated from skypy pipeline, we require them to provide angular size of the galaxy in arcsec.
- Parameters:
galaxy_catalog – galaxy catalog.
input_catalog_type (str. "skypy" or None) – type of the catalog.
- Returns:
galaxy catalog with anularsize in arcsec.
- slsim.Util.param_util.convert_mjd_to_days(reference_mjd, start_point_mjd)[source]¶
Convert reference MJD(s) to days relative to a chosen zero-point MJD.
- Parameters:
reference_mjd (float, list, or numpy.ndarray) – The reference MJD(s) to convert.
start_point_mjd – The zero-point MJD to use as the reference.
- Returns:
The time(s) in days relative to the zero-point MJD.
- slsim.Util.param_util.convolved_image(image, psf_kernel, convolution_type='fft')[source]¶
Convolves an image with given psf kernel.
- Parameters:
image – image to be convolved
psf_kernel – kernel used to convolve the given image. It should be a pixel psf kernel.
convolution_type – method to be used to convolve image. currently fftconvolve and convolve2d are supported. The default type is fftconvolve and we prefer to use fftconvolve over convolve2d because it is relatively faster for our purpose.
- Returns:
convolved image.
- slsim.Util.param_util.deg2_to_cone_angle(solid_angle_deg2)[source]¶
Convert solid angle from square degrees to half cone angle in radians.
This function translates a solid angle, specified in square degrees, into the corresponding half cone angle expressed in radians. This conversion is essential for applications involving angular measurements in astronomy, particularly in lensing calculations where the geometry of observations is defined in terms of cone angles.
- Parameters:
solid_angle_deg2 (float) – Solid angle in square degrees to be converted.
- Returns:
The half cone angle in radians equivalent to the input solid angle.
- Return type:
float :note: The conversion utilizes the relationship between solid angles in steradians and the apex angle of a cone, facilitating a direct transition from square degrees to radians.
- slsim.Util.param_util.degrade_coadd_data(image, variance_map, exposure_map, original_num_years=5, degraded_num_years=1, use_noise_diff=True)[source]¶
Degrade a coadded astronomical image by reducing its effective exposure time.
- Parameters:
image – numpy.ndarray The input image array.
variance_map – numpy.ndarray The original variance map.
exposure_map – numpy.ndarray The original exposure time per pixel.
original_num_years – int, optional The original coadded number of years. Default is 5.
degraded_num_years – int, optional The new degraded number of years. Default is 1.
use_noise_diff – bool, optional If True, approximates noise difference using Gaussian noise, otherwise, applies full noise resampling. Default is True.
- Returns:
The degraded image, the new variance map, and the new exposure map.
- slsim.Util.param_util.detect_object(image, variance, pixel_scale=0.2, box_size_arcsec=3, snr_threshold=5)[source]¶
Detect whether the central region of the image contains an object based on SNR.
- Parameters:
image – The input image.
variance – The variance map of the same size as the image.
pixel_scale – Pixel scale in arcsec/pixel (default is 0.2 arcsec/pixel).
box_size_arcsec – Size of the central box in arcsec (default is 3 arcsec).
snr_threshold – SNR threshold for object detection (default is 5).
- Returns:
bool. True if the region contains an object (SNR > threshold), False otherwise.
- slsim.Util.param_util.downsample_galaxies(galaxy_pop, dN, dM, M_min, M_max, z_min, z_max)[source]¶
Downsamples a galaxy population to match the luminosity function of another population. Another population with the given redshift range is specified by the dN.
- Parameters:
galaxy_population – astropy.table.Table. Table containing the galaxy population with at least a ‘magnitude’ column.
dN – array-like. Galaxy counts per magnitude bin for the reference population.
dM – float. Magnitude bin width.
M_min – float. Minimum magnitude for binning.
M_max – float. Maximum magnitude for binning.
z_min – float. Minimum redshift for sample.
z_max – float. Maximum redshift for sample.
- Returns:
astropy.table.Table. Downsampled galaxy population.
- slsim.Util.param_util.draw_coord_in_circle(area, size=1)[source]¶
Draw realizations of points in circle.
- Parameters:
area – area (solid angle) of circle to draw uniformly in
size (int) – number of draws
- Returns:
coordinate (x, y) drawn uniformly in the area of the circle, centered at (0, 0)
- slsim.Util.param_util.e2epsilon(e)[source]¶
Translates ellipticity definitions from.
\[e = \equic \frac{1 - q}{1 + q}\]to
\[epsilon = \equic \frac{1 - q^2}{1 + q^2}\]- Parameters:
e – eccentricity
- Returns:
ellipticity
- slsim.Util.param_util.eccentricity(q)[source]¶
Computes eccentricity using axis ratio.
- Parameters:
q – axis ratio of an object
- Returns:
eccentricity
- slsim.Util.param_util.ellip_from_axis_ratio2epsilon(ellip)[source]¶
Translates ellipticity definitions from.
\[ellip = \equic \1 - q\]to
\[epsilon = \equic \frac{1 - q^2}{1 + q^2}\]- Parameters:
ellip (ndarray or float) – ellipticity in SL-Hammocks
- Returns:
epsilon. ellipticity in slsim
- slsim.Util.param_util.elliptical_distortion_product_average(x, y, e1, e2, center_x, center_y)[source]¶
Maps the coordinates x, y with eccentricities e1, e2 into a new elliptical coordinate system with same coordinate orientation.
- Parameters:
x – x-coordinate
y – y-coordinate
e1 – eccentricity
e2 – eccentricity
center_x – center of distortion
center_y – center of distortion
- Returns:
distorted coordinates x’, y’
- slsim.Util.param_util.ellipticity_slsim_to_lenstronomy(e1_slsim, e2_slsim)[source]¶
Converts ellipticity component from slsim convension to lenstronomy convention. In slsim, position angle goes from North to East. In lenstronomy, position angle goes from East to North.
- Parameters:
e1_slsim – first component of the ellipticity in slsim convension i.e position angle from north to east.
e2_slsim – second component of the ellipticity in slsim convention.
return: ellipticity components in lenstronomy convention.
- slsim.Util.param_util.epsilon2e(epsilon)[source]¶
Translates ellipticity definitions from.
\[epsilon = \equic \frac{1 - q^2}{1 + q^2}\]to
\[e = \equic \frac{1 - q}{1 + q}\]- Parameters:
epsilon – ellipticity
- Returns:
eccentricity
- slsim.Util.param_util.fits_append_table(filename, table)[source]¶
Append an Astropy Table to an existing FITS file.
- Parameters:
filename – Name of the FITS file to append to
table – Astropy Table object to append
- slsim.Util.param_util.flux_error_to_magnitude_error(flux_mean, flux_error, mag_zero_point, noise=True, symmetric=False)[source]¶
Computes mean magnitude and corresponding errors from the provided mean flux and associate error.
- Parameters:
flux_mean – mean flux of a transient.
flux_error – error in a mean flux.
mag_zero_point – magnitude zero point of the observation.
noise – Boolean. If True, a gaussian noise is added to the lightcurve flux.
symmetric – Boolean. If True, a symmetric error on magnitude is provided.
- Returns:
mean magnitude and associted errors.
- slsim.Util.param_util.galaxy_size(mapp, zsrc, cosmo)[source]¶
Calculate the half-light radius of a source using the size-luminosity relation from Bernardi et al. (2003), as given in Oguri (2006). Please see equation 15 of : https://arxiv.org/pdf/astro-ph/0508528
- Parameters:
mapp – float Apparent g-band magnitude of the source.
zsrc – float Redshift of the source.
cosmo – astropy.cosmology instance
- Returns:
Half-light radius in kpc and arcsec.
- slsim.Util.param_util.galaxy_size_redshift_evolution(z)[source]¶
This function provides a galaxy size elolution with the redshift. Provides a correction factor to the size relative to z=0. This relation is taken from Shibuya et al. (2015): https://arxiv.org/abs/1503.07481
- Parameters:
z – galaxy redshift. It can be a single galaxy redshift or list of galaxy redshifts.
- Returns:
Physical size of the galaxy.
- slsim.Util.param_util.gaussian_psf(fwhm, delta_pix=0.2, num_pix=41)[source]¶
Generate a normalized 2D Gaussian PSF array.
- Parameters:
(float) (delta_pix) – Full Width at Half Maximum (FWHM) of the PSF in arcseconds.
(float) – Pixel scale in arcsec/pixel (default: 0.2 arcsec/pixel).
(int) (num_pix) – Size of the PSF array (default: 41x41 pixels).
- Returns:
Normalized 2D PSF array.
- slsim.Util.param_util.image_separation_from_positions(image_positions)[source]¶
Calculate image separation in arc-seconds; if there are only two images, the separation between them is returned; if there are more than 2 images, the maximum separation is returned.
- Parameters:
image_positions – list of image positions in arc-seconds
- Returns:
image separation in arc-seconds
- slsim.Util.param_util.images_to_pixels(image_series)[source]¶
Converts a series of image snapshots into a list of pixel snapshots.
- Parameters:
image_series – Series of images to convert
- Returns:
List of pixel snapshots
- slsim.Util.param_util.interpolate_variability(image_series, orig_timestamps, new_timestamps)[source]¶
Interpolates between time stamps of a series of image snapshots. This will be important for future implimentation of microlensing.
- Parameters:
image_series – 3 dimensional array of shape (snapshot_index, x, y) defining snapshots of a variable object in (x, y) coordinates
orig_timestamps – List of timestamps which represent the time of each simulated observation, must be same length as np.size(image_series, 0)
new_timestamps – List of new timestamps to interpolate the series of snapshots to
- Returns:
Linearly interpolated series of snapshots at the new timestamps on a pixel- by-pixel basis
- slsim.Util.param_util.magnitude_to_amplitude(magnitude, mag_zero_point)[source]¶
Converts source magnitude to amplitude.
- Parameters:
magnitude – source magnitude
mag_zero_point – zero point magnitude for the image
- Returns:
source amplitude in counts per second
- slsim.Util.param_util.pixels_to_images(pixels, original_shape)[source]¶
Converts a string of pixel snapshots back into a series of image snapshots. This is the inverse of images_to_pixels.
- Parameters:
pixels – Series of pixel snapshots to arrange back into the original image shape
original_shape – The original output of np.shape(original_image_series) [tuple]
- Returns:
Series of image snapshots
- slsim.Util.param_util.random_ra_dec(ra_min, ra_max, dec_min, dec_max, n)[source]¶
Generates n number of random ra, dec pair with in a given limits.
- Parameters:
ra_min – minimum limit for ra
ra_max – maximum limit for ra
dec_min – minimum limit for dec
dec_max – maximum limit for dec
n – number of random sample
- Returns:
n number of ra, dec pair within given limits
- slsim.Util.param_util.random_radec_string(ra_min, ra_max, dec_min, dec_max, n)[source]¶
Generates n number of random “ra, dec” string within given limits.
- Parameters:
ra_min – minimum limit for ra
ra_max – maximum limit for ra
dec_min – minimum limit for dec
dec_max – maximum limit for dec
n – number of random sample
- Returns:
n number of “ra, dec” strings within given limits
- slsim.Util.param_util.surface_brightness_reff(angular_size, source_model_list, kwargs_extended_source)[source]¶
Calculate average surface brightness within half light radius.
- Parameters:
angular_size – effective radius of an extended source in arcsec. For double sersic profile, user can use mean angular size of two component of the douuble sersic profile.
source_model_list – list of source light models
kwargs_extended_source – dictionary of keywords for the source light model(s). Kewords used are in lenstronomy conventions.
- Returns:
average surface brightness within half light radius [mag/arcsec^2]
- slsim.Util.param_util.transformmatrix_to_pixelscale(tranform_matrix)[source]¶
Calculates pixel scale using tranform matrix.
- Parameters:
tranform_matrix – transformation matrix (2x2) of pixels into coordinate displacements
- Returns:
pixel scale
- slsim.Util.param_util.transient_event_time_mjd(min_mjd, max_mjd, random_seed=42)[source]¶
Produces a random MJD time with in the given range.
- Parameters:
min_mjd – Minimum bound for the MJD time
max_mjd – Maximum bound for the MJD time
random_seed – int. Default is 42.
- Returns:
A random MJD time between given min and max bounds.
- slsim.Util.param_util.update_cosmology_in_yaml_file(cosmo, yml_file)[source]¶
Replaces the default cosmology string in a yaml file with the parameters of a custom astropy cosmology object.
- Parameters:
cosmo – astropy.cosmology.Cosmology or None The cosmology object to insert into the content.
yml_file – A yml file containg cosmology information.
- Returns:
Updated yml_file with the new cosmology parameters.
- slsim.Util.param_util.vel_disp_from_m_star(m_star)[source]¶
Function to calculate the velocity dispersion from the staller mass using empirical relation for elliptical galaxies.
The power-law formula is given by:
\[V_{\mathrm{disp}} = 10^{2.32} \left( \frac{M_{\mathrm{star}}}{10^{11} M_\odot} \right)^{0.24}\]2.32,0.24 is the parameters from [1] table 2 [1]:Auger, M. W., et al. “The Sloan Lens ACS Survey. X. Stellar, dynamical, and total mass correlations of massive elliptical galaxies.” The Astrophysical Journal 724.1 (2010): 511.
- Parameters:
m_star – stellar mass in the unit of solar mass
- Returns:
the velocity dispersion (“km/s”)