slsim.Util package¶
Submodules¶
slsim.Util.astro_util module¶
- slsim.Util.astro_util.calculate_eddington_luminosity(black_hole_mass_exponent)[source]¶
Calculates the Eddington luminosity for a black hole mass exponent.
- Eddington_luminosity = 4 * pi * G * black_hole_mass * mass_proton
c / sigma_thompson
- Parameters:
black_hole_mass_exponent – 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_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 – 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_time_delays_on_disk(r_out, r_resolution, inclination_angle, black_hole_mass_exponent, corona_height)[source]¶
This calculates the light travel time lags from a point source corona 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:
r_out – maximum radial value. 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 tilt of the accretion disk with respect to the observer. Zero degrees is face on, 90 degrees is edge on.
black_hole_mass_exponent – 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.
corona_height – height of the corona in gravitational_radii. Typical values range from 10 to 100 gravitational radii.
- Returns:
A 2-dimensional array of time delays between the corona and the accretion disk.
- 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 – 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:
mass of the black hole in astropy units
- 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 – maximum radial value. 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 – maximum radial value. 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 radial positions of shape ((2 * r_resolution), (2 * r_resolution)) in the projected plane of the sky
- 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 – 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 – 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.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.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.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 – 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.param_util module¶
- 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.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.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.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