tardis.spectrum.formal_integral.formal_integral_numba module¶
- class tardis.spectrum.formal_integral.formal_integral_numba.NumbaFormalIntegrator(geometry: NumbaRadial1DGeometry, time_explosion: float, plasma, n_impact_parameters: int = 1000)[source]¶
Bases:
object
Helper class for performing the formal integral with Numba.
- Parameters:
- geometryobject
Geometry object containing shell radii.
- time_explosionfloat
Time since explosion (seconds).
- plasmaobject
Plasma object containing line list frequencies.
- n_impact_parametersint, optional
Number of impact parameters
- formal_integral(inner_temperature: float, frequencies: ndarray[tuple[int, ...], dtype[float64]], att_S_ul: ndarray[tuple[int, ...], dtype[float64]], mean_intensity_red_lu: ndarray[tuple[int, ...], dtype[float64]], mean_intensity_blue_lu: ndarray[tuple[int, ...], dtype[float64]], tau_sobolev: ndarray[tuple[int, ...], dtype[float64]], electron_densities: ndarray[tuple[int, ...], dtype[float64]], n_impact_parameters: int) Tuple[ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]]] [source]¶
Wrapper for the Numba implementation of the formal integral.
- Parameters:
- inner_temperaturefloat
Inner boundary temperature.
- frequenciesndarray
Array of frequency values.
- att_S_ulndarray
Attenuated source function values.
- mean_intensity_red_lundarray
mean intensity of each line transition from upper to lower on the red side for each line and shell.
- mean_intensity_blue_lundarray
mean intensity of each line transition from upper to lower on the blue side for each line and shell.
- tau_sobolevndarray
Sobolev optical depths (2D array: lines x shells).
- electron_densitiesndarray
Electron densities per shell.
- n_impact_parametersint
Number of impact parameters
- Returns:
- luminosity_densitiesndarray
Integrated luminosities for each frequency.
- intensities_nu_pndarray
Intensities per frequency and impact parameter
- tardis.spectrum.formal_integral.formal_integral_numba.calculate_intersection_point(radius: float, impact_parameter: float, inv_t: float) float [source]¶
Calculate distance to the impact parameter at radius.
Calculate half of the length of the impact parameter inside a shell of radius in terms of unit length (c * t_exp). If shell and impact parameter do not intersect, return 0.
- Parameters:
- radiusfloat
Radius of the shell.
- impact_parameterfloat
Distance of the impact parameter to the center of the supernova.
- inv_tfloat
Inverse of the time_explosion, used to normalize to unit length.
- Returns:
- float
Half the length of the impact parameter inside the shell, or 0 if no intersection.
- tardis.spectrum.formal_integral.formal_integral_numba.get_electron_scattering_optical_depth(escat_optical_depth: float, first_contribution_flag: int, mean_intensity_red_lu_idx: int, intersection_end: float, intersection_start: float, escat_opacity: float, mean_intensity_blue_lu: float, mean_intensity_red_lu: float, intensities_nu_p: float) Tuple[float, int, int] [source]¶
Compute the electron scattering optical depth for given segment
- Parameters:
- escat_optical_depthfloat
Current electron scattering contribution.
- first_contribution_flagint
Flag indicating if this is the first contribution (1 if first, 0 otherwise).
- mean_intensity_red_lu_idxint
Index for mean_intensity_red_lu.
- intersection_endfloat
Ending intersection point value for the current segment.
- intersection_startfloat
Starting intersection point value for the current segment.
- escat_opacityfloat
Electron scattering opacity.
- mean_intensity_blue_lufloat
mean intensity of the transition on the blue side for the current segment.
- mean_intensity_red_lufloat
mean intensity of the transition on the red side for the current segment.
- intensities_nu_pfloat
Intensity at the current frequency and impact parameter.
- Returns:
- escat_optical_depthfloat
Updated electron scattering contribution.
- first_contribution_flagint
Updated flag.
- mean_intensity_red_lu_idxint
Updated mean_intensity_red_lu index.
- tardis.spectrum.formal_integral.formal_integral_numba.initialize_formal_integral_inputs(frequencies: ndarray[tuple[int, ...], dtype[float64]], inner_temperature: float, n_impact_parameters: int, geometry: NumbaRadial1DGeometry, time_explosion: float, tau_sobolev: ndarray[tuple[int, ...], dtype[float64]]) Tuple[ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[int64]], ndarray[tuple[int, ...], dtype[int64]], ndarray[tuple[int, ...], dtype[float64]]] [source]¶
Prepare all arrays and values needed for the loops inside the formal integral.
- Parameters:
- frequenciesndarray
Array of frequency values.
- inner_temperaturefloat
Inner boundary temperature.
- n_impact_parametersint
Number of impact parameters.
- geometryobject
Geometry object containing shell radii.
- time_explosionfloat
Time since explosion (seconds).
- tau_sobolevndarray
Sobolev optical depths for each line and shell.
- Returns:
- intensities_nu_pndarray
Intensities at each frequency and impact parameter.
- impact_parametersndarray
Array of impact parameters.
- intersection_pointsndarray
Array of intersection points for each impact parameter and shell.
- shell_idsndarray
Array of shell IDs for each impact parameter and shell intersection.
- n_intersectionsndarray
Number of intersections for each impact parameter.
- exp_tau_sobolevndarray
Exponential of negative Sobolev optical depths (flattened).
- tardis.spectrum.formal_integral.formal_integral_numba.line_search(nu: ndarray[tuple[int, ...], dtype[float64]], nu_insert: float, number_of_lines: int) int [source]¶
Find the index to insert a value into an array of line frequencies.
- Parameters:
- nundarray
Array of line frequencies.
- nu_insertfloat
Value of the frequency to insert.
- number_of_linesint
Number of lines in the line list.
- Returns:
- int
Index of the next line to the red. If the key value is redder than the reddest line, returns number_of_lines.
- tardis.spectrum.formal_integral.formal_integral_numba.numba_formal_integral(geometry: NumbaRadial1DGeometry, time_explosion: float, plasma, inner_temperature: float, frequencies: ndarray[tuple[int, ...], dtype[float64]], att_S_ul: ndarray[tuple[int, ...], dtype[float64]], mean_intensity_red_lu: ndarray[tuple[int, ...], dtype[float64]], mean_intensity_blue_lu: ndarray[tuple[int, ...], dtype[float64]], tau_sobolev: ndarray[tuple[int, ...], dtype[float64]], electron_densities: ndarray[tuple[int, ...], dtype[float64]], n_impact_parameters: int) Tuple[ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]]] [source]¶
Compute the formal integral.
- Parameters:
- geometryobject
Geometry object containing shell radii.
- time_explosionfloat
Time since explosion (seconds).
- plasmaobject
Plasma object containing line list frequencies.
- inner_temperaturefloat
Inner boundary temperature.
- frequenciesndarray
Array of frequencies.
- att_S_ulndarray
Attenuated source function for each line and shell.
- mean_intensity_red_lundarray
mean intensity of each line transition from upper to lower on the red side for each line and shell.
- mean_intensity_blue_lundarray
mean intensity of each line transition from upper to lower on the blue side for each line and shell.
- tau_sobolevndarray
Sobolev optical depths for each line and shell.
- electron_densitiesndarray
Electron densities per shell.
- n_impact_parametersint
Number of impact parameters.
- Returns:
- luminosity_densitiesndarray
Integrated luminosities for each frequency.
- intensities_nu_pndarray
Intensities per frequency and impact parameter
- tardis.spectrum.formal_integral.formal_integral_numba.populate_intersection_points(geometry: NumbaRadial1DGeometry, time_explosion: float, impact_parameter: float, intersection_points: ndarray[tuple[int, ...], dtype[float64]], shell_ids: ndarray[tuple[int, ...], dtype[int64]]) int [source]¶
Calculate the intersection points of the impact parameter with each shell.
- Parameters:
- geometryobject
Geometry object containing shell radii.
- time_explosionfloat
Time since explosion (seconds).
- impact_parameterfloat
Distance of the integration line to the center.
- intersection_pointsndarray
Output array to be filled with intersection_point values.
- shell_idsndarray
Output array to be filled with the corresponding shell IDs.
- Returns:
- int
Number of intersection points found.
- tardis.spectrum.formal_integral.formal_integral_numba.reverse_binary_search(x: ndarray[tuple[int, ...], dtype[float64]], x_insert: float, imin: int, imax: int) int [source]¶
Find the insertion index for a value in an inversely sorted float array.
- Parameters:
- xndarray
Inversely (largest to lowest) sorted float array.
- x_insertfloat
Value to insert.
- iminint
Lower bound index.
- imaxint
Upper bound index.
- Returns:
- int
Index of the next boundary to the left.