tardis.spectrum.formal_integral module

exception tardis.spectrum.formal_integral.BoundsError[source]

Bases: IndexError

class tardis.spectrum.formal_integral.FormalIntegrator(simulation_state, plasma, transport, points=1000)[source]

Bases: object

Class containing the formal integrator.

If there is a NVIDIA CUDA GPU available, the formal integral will automatically run on it. If multiple GPUs are available, it will choose the first one that it sees. You can read more about selecting different GPUs on Numba’s CUDA documentation.

Parameters:
modeltardis.model.SimulationState
plasmatardis.plasma.BasePlasma
transporttardis.transport.montecarlo.MontecarloTransport
pointsint64
calculate_spectrum(frequency, points=None, interpolate_shells=0, raises=True)[source]
check(raises=True)[source]

A method that determines if the formal integral can be performed with the current configuration settings

The function returns False if the configuration conflicts with the required settings. If raises evaluates to True, then a IntegrationError is raised instead

formal_integral(nu, N)[source]

Do the formal integral with the numba routines

generate_numba_objects()[source]

instantiate the numba interface objects needed for computing the formal integral

interpolate_integrator_quantities(att_S_ul, Jredlu, Jbluelu, e_dot_u)[source]
make_source_function()[source]

Calculates the source function using the line absorption rate estimator Edotlu_estimator

Formally it calculates the expression ( 1 - exp(-tau_ul) ) S_ul but this product is what we need later, so there is no need to factor out the source function explicitly.

Parameters:
modeltardis.model.SimulationState
Returns:
Numpy array containing ( 1 - exp(-tau_ul) ) S_ul ordered by wavelength of the transition u -> l
exception tardis.spectrum.formal_integral.IntegrationError[source]

Bases: Exception

class tardis.spectrum.formal_integral.NumbaFormalIntegrator(geometry, time_explosion, plasma, points=1000)[source]

Bases: object

Helper class for performing the formal integral with numba.

formal_integral(iT, inu, inu_size, att_S_ul, Jred_lu, Jblue_lu, tau_sobolev, electron_density, N)[source]

Simple wrapper for the numba implementation of the formal integral

tardis.spectrum.formal_integral.calculate_p_values(R_max, N)[source]

This can probably be replaced with a simpler function

tardis.spectrum.formal_integral.calculate_z(r, p, inv_t)[source]

Calculate distance to p line

Calculate half of the length of the p-line inside a shell of radius r in terms of unit length (c * t_exp). If shell and p-line do not intersect, return 0.

Inputs:
r:

(double) radius of the shell

p:

(double) distance of the p-line to the center of the supernova

inv_t:

(double) inverse time_explosio is needed to norm to unit-length

tardis.spectrum.formal_integral.intensity_black_body(nu, temperature)[source]

Calculate the blackbody intensity.

Parameters:
nufloat64

frequency

temperaturefloat64

Temperature

Returns:
float64

Insert a value in to an array of line frequencies

Inputs:
nu:

(array) line frequencies

nu_insert:

(int) value of nu key

number_of_lines:

(int) number of lines in the line list

Outputs:
index of the next line ot the red.
If the key value is redder

than the reddest line returns number_of_lines.

tardis.spectrum.formal_integral.numba_formal_integral(geometry, time_explosion, plasma, iT, inu, inu_size, att_S_ul, Jred_lu, Jblue_lu, tau_sobolev, electron_density, N)[source]
Returns:
Lfloat64 array

integrated luminosities

I_nu_pfloat64 2D array

intensities at each p-ray multiplied by p frequency x p-ray grid

tardis.spectrum.formal_integral.populate_z(geometry, time_explosion, p, oz, oshell_id)[source]

Calculate p line intersections

This function calculates the intersection points of the p-line with each shell

Inputs:
p:

(double) distance of the integration line to the center

oz:

(array of doubles) will be set with z values. the array is truncated by the value 1.

oshell_id:

(int64) will be set with the corresponding shell_ids

Look for a place to insert a value in an inversely sorted float array.

Inputs:
x:

(array) an inversely (largest to lowest) sorted float array

x_insert:

(value) a value to insert

imin:

(int) lower bound

imax:

(int) upper bound

Outputs:

index of the next boundary to the left

tardis.spectrum.formal_integral.trapezoid_integration(array, h)[source]

in the future, let’s just replace this with the numpy trapz since it is numba compatable