utu.spectrum.contribution_function_line#
- utu.spectrum.contribution_function_line(ion, wavelength, temperature, density, axis_temperature='temperature', proton_electron_ratio=None, tolerance=<Quantity 0.01 mAngstrom>, size_chunk=None, **kwargs)[source]#
Compute the contribution function of an observed line, named by its ion and its wavelength.
An observed line is every transition of its ion at its wavelength, of which there can be more than one, so the contribution functions of all the transitions within
toleranceof the wavelength are summed. This is the difference fromcontribution_function(), which returns every transition of an ion and leaves picking one out to the caller.The result is laid out as
contribution_function()lays it out, so that it can be handed tosynthesize(): the wavelength of each line as the inputs, and its contribution function alongaxis_temperatureand the axes of the lines as the outputs. A density along an axis of its own keeps the name of that axis, whichcontribution_function()calls_density. Its units are those offiasco, which leaves the ratio of the density of hydrogen to that of electrons out, so the emission measure it goes with is \(\int n_e n_H \, dh\).- Parameters:
ion (str | AbstractScalar) – The ion which emits each line, named as
fiasconames it,"O 5"for instance. It broadcasts againstwavelength, so several lines are an ion and a wavelength for each along the same axis, or one ion and several wavelengths. An ion with more than one of the lines is built once and solved once at each temperature, even if it is named two ways,"O 5"and"O V"for instance.wavelength (Quantity | AbstractScalar) – The wavelength of each line, as CHIANTI lists it.
temperature (AbstractScalar) – The temperatures of the plasma, along
axis_temperatureand no other axis.density (Quantity | AbstractScalar) – The number density of electrons. A scalar is the same density at every temperature. A density along
axis_temperatureis one density per temperature, an isobaric atmosphere for instance. A density along one axis of its own is every density at every temperature, and costs as many times more. It may not share an axis with the lines.axis_temperature (str) – The name of the axis of
temperature.proton_electron_ratio (None | Quantity | AbstractScalar) – The ratio of protons to electrons at each temperature. If
None(the default), it is computed here, once, which walks the whole database. It is given to each ion as the ion is built, and passed on by the ion to the ion it recombines from. Pass it to compute lines over one grid of temperatures more than once without paying for it again.tolerance (Quantity) – How close to
wavelengtha transition must be to belong to the line. Two transitions of an ion which CHIANTI lists at different wavelengths are at least a tenth of a milliangstrom apart, and many are only half a milliangstrom apart, so the default is a tenth of that least spacing. It gathers every transition listed at the wavelength and none beside it, as long as the wavelength is given as CHIANTI lists it.size_chunk (None | int) – How many temperatures to solve at once. If
None(the default), all of them. The level populations of an ion are solved at every temperature at once, in a matrix as wide as the ion and the ion it recombines from have levels, which for an ion with hundreds of levels on a fine grid of temperatures is tens of gigabytes. Each temperature is solved on its own, so solving a few at a time changes nothing in the result.kwargs (object) – Additional arguments passed to
fiasco.Ionfor every ion, and tofiasco.proton_electron_ratio(). They are passed unchanged to every chunk ofsize_chunktemperatures, so none of them may vary with the temperature, as anionization_fractiongiven as an array would.
- Return type:
Examples
The contribution functions of the line ESIS was built to observe and of the line of \(\mathrm{Mg\,X}\) nearest it.
import astropy.units as u import matplotlib.pyplot as plt import named_arrays as na import numpy as np import utu axis = "temperature" temperature = na.geomspace(1e4, 1e7, axis=axis, num=61) * u.K ion = na.ScalarArray(np.array(["O 5", "Mg 10"]), axes="line") wavelength = na.ScalarArray([629.732, 624.941] * u.AA, axes="line") result = utu.spectrum.contribution_function_line( ion=ion, wavelength=wavelength, temperature=temperature, density=1e15 * u.K / u.cm ** 3 / temperature, axis_temperature=axis, ) fig, ax = plt.subplots(constrained_layout=True) na.plt.plot( temperature, result.outputs, ax=ax, axis=axis, label=utu.spectrum.spectroscopic(ion), ) ax.set_xscale("log") ax.set_yscale("log") ax.set_ylim(1e-26, 1e-21) ax.set_xlabel(f"temperature ({temperature.unit:latex_inline})") ax.set_ylabel(f"$G(T)$ ({result.outputs.unit:latex_inline})") ax.legend()
<matplotlib.legend.Legend at 0x7c4bab0a7050>