utu.spectrum.synthesize#
- utu.spectrum.synthesize(contribution, temperature, mass, emission_measure, velocity, shift=<Quantity 0. km / s>, width_nonthermal=<Quantity 0. km / s>, axis_temperature='temperature', axis_shift=None, axis_velocity='velocity', axis='line')[source]#
Compute the spectral radiance of an optically thin plasma, line by line.
Each line is spread over a range of velocities around its rest wavelength, as a Gaussian whose center is the line-of-sight velocity of the plasma and whose width is that of the thermal motion of its ions added in quadrature to a nonthermal width. The plasma at each temperature has a profile of its own, and the spectrum is their sum,
\[L(\lambda) = \frac{1}{4 \pi} \sum_T G(T) \, \mathrm{EM}(T) \, \phi(\lambda; T),\]where \(G\) is the contribution function, \(\mathrm{EM}\) the emission measure, and \(\phi\) the profile, normalized to unit area. Its standard deviation, in velocity, is
\[\sigma^2 = \frac{k_B T}{m} + \sigma_\mathrm{nt}^2,\]with \(m\) the mass of the ion and \(\sigma_\mathrm{nt}\) the nonthermal width.
An emission measure resolved in line-of-sight velocity as well as in temperature, such as the velocity-resolved DEM of a simulation, is a sum over both, each bin of velocity \(s\) with a profile centered on its own shift,
\[L(\lambda) = \frac{1}{4 \pi} \sum_T \sum_s G(T) \, \mathrm{EM}(T, s) \, \phi(\lambda; T, s).\]The radiance of each bin of velocity is the integral of the profile across it divided by its width in wavelength, not the profile sampled at its center. So the sum of the radiance over the bins is the radiance of the line, however coarse the bins, as long as they span the line. The integral is taken from whichever tail of the profile the bin is in, so it keeps its precision far into the wings.
- Parameters:
contribution (FunctionArray) – The contribution functions of the lines, as
contribution_function()returns them: the rest wavelength of each line along axis as the inputs, and its contribution function along axis_temperature and axis as the outputs.fiascoleaves the ratio of hydrogen to electrons out of these, so the emission measure they go with is that of \(n_e n_H\).temperature (AbstractScalar) – The temperatures of the plasma, along axis_temperature: the ones contribution was computed at. They must be positive.
mass (Quantity | AbstractScalar) – The mass of the ion each line belongs to, such as
fiasco.Ion.mass. Give it along axis to synthesize the lines of several ions at once.emission_measure (Quantity | AbstractScalar) –
How much plasma there is in each bin of temperature, \(\int n_e n_H \, dh\) through the column, along axis_temperature, and in each bin of line-of-sight velocity too, along axis_shift, if it is given. Every other axis is carried through to the result, such as the two axes of a map.
This is the emission measure of each bin, not the differential emission measure: a DEM per unit \(\log_{10} T\), such as
utu.dem.plowman()returns, has the same units, and has to be converted first: multiplied by the width of each bin in \(\log_{10} T\), or, to integrate it the wayutu.dem.plowman()fits the intensities, weighted withutu.dem.emission_measure().velocity (AbstractScalar) – The vertices of the bins of velocity, along axis_velocity. Positive velocities are away from the observer, to longer wavelengths.
shift (Quantity | AbstractScalar) – The line-of-sight velocity of the plasma. It may vary along any axis of emission_measure, including axis_temperature and axis_shift, and along axis.
width_nonthermal (Quantity | AbstractScalar) – The standard deviation of the nonthermal motions of the plasma along the line of sight. Often quoted instead as the most probable speed \(\xi\), which is \(\sqrt{2}\) times larger. It may vary along the same axes as shift.
axis_temperature (str) – The name of the axis of temperature, summed over.
axis_shift (None | str) – The name of an axis of emission_measure along which the plasma is binned by line-of-sight velocity, as in a velocity-resolved DEM, summed over like axis_temperature. shift is then the velocity of each bin, and width_nonthermal can hold the spread of velocities within it. The profile of each bin is a Gaussian, so plasma spread evenly across a bin is approximated by a Gaussian of the same variance, with a nonthermal width of the width of the bin over \(\sqrt{12}\). emission_measure must have every element along this axis that the other arguments have. If
None, the default, only axis_temperature is summed over.axis_velocity (str) – The name of the axis of velocity.
axis (str) – The name of the axis along the lines of contribution. Any other argument which varies along it must have one element along it, or as many as contribution.
- Returns:
The spectral radiance of each line in each bin of velocity, along axis, axis_velocity, and every axis of the other arguments but axis_temperature and axis_shift, in the precision of emission_measure, or single precision if that is narrower. The inputs are the vertices of the bins, as wavelengths with the rest wavelength of each line beside them.
- Raises:
ValueError – If velocity has no axis axis_velocity or varies along axis_temperature or axis_shift, if temperature or the outputs of contribution have no axis axis_temperature, if axis_shift is axis_temperature, axis_velocity, or axis, if emission_measure has no axis axis_shift or fewer elements along it than another argument, if a temperature is not positive, or if an argument varies along axis differently than contribution does.
- Return type:
Notes
Nothing here is particular to an instrument: the profile is that of the plasma alone, with no instrumental width, and every line in contribution is synthesized, so choosing which lines are worth including is left to the caller. Natural and pressure broadening are left out, which in the transition region and the corona is a small fraction of a milliangstrom, and so is opacity.
The spectral radiance of each line per unit emission measure in each bin of temperature, the kernel, is computed first, and then summed with the emission measure over axis_temperature and axis_shift by
named_arrays.vecdot(). Unless the profile or the contribution function varies from pixel to pixel, the kernel has no axes of the map, and the sum is a single matrix product, so a map of many lines takes little more memory than the result itself, and is many times faster than forming the product of the two. Where one of them does vary from pixel to pixel, the kernel is as large as the map, and it and the radiance it gives are computed for as many bins of velocity and lines at a time as fit in_size_blockelements. Where the profile is the same for every line, because none of mass, shift, and width_nonthermal varies along axis, it is computed once for all of them.The kernel is computed in double precision, and rounded to the precision of emission_measure before the sum. A matrix product of two precisions would copy the emission measure into the wider one, so a map in single precision, as the emission measure of a simulation often is, is summed in single precision instead, and takes no more memory than itself, the kernel, and the result.
Examples
The \(\mathrm{Ne\,VII}\;465\,\AA\) line of plasma near half a million kelvin, at rest and moving toward the observer at \(20\,\mathrm{km\,s^{-1}}\).
import astropy.units as u import fiasco import matplotlib.pyplot as plt import named_arrays as na import numpy as np import utu fiasco.log.setLevel("ERROR") axis = "temperature" temperature = na.geomspace(1e5, 1e6, axis=axis, num=21) * u.K # a Gaussian in the logarithm of the temperature, holding # 1e27 cm^-5 of plasma in all weight = np.exp(-np.square((np.log10(temperature / u.K) - 5.7) / 0.1) / 2) emission_measure = 1e27 / u.cm**5 * weight / weight.sum(axis) ion = fiasco.Ion("Ne 7", temperature.ndarray) contribution = utu.spectrum.contribution_function( ion=ion, density=1e15 * u.K / u.cm**3 / temperature, axis_temperature=axis, ) # the strongest line of the ion brightest = np.argmax(contribution.outputs.max(axis), axis="line") contribution = contribution[brightest] shift = na.ScalarArray([0, -20] * u.km / u.s, axes="shift") result = utu.spectrum.synthesize( contribution=contribution, temperature=temperature, mass=ion.mass, emission_measure=emission_measure, velocity=na.linspace(-100, 100, axis="velocity", num=81) * u.km / u.s, shift=shift, axis_temperature=axis, ) fig, ax = plt.subplots(figsize=(6, 4), constrained_layout=True) na.plt.stairs( result.inputs.velocity, result.outputs, ax=ax, axis="velocity", label=shift, ) ax.set_xlabel(f"velocity ({u.km / u.s:latex_inline})") ax.set_ylabel(f"spectral radiance\n({result.outputs.unit:latex_inline})") ax.legend(title="shift");
The same plasma, resolved in line-of-sight velocity as well: half of it at rest and a quarter in each of two bins \(40\,\mathrm{km\,s^{-1}}\) to either side. The plasma of each bin is spread evenly across its width, which the profile approximates with a Gaussian of the same variance.
# the vertices of three bins of line-of-sight velocity vertices = na.linspace(-60, 60, axis="vdop", num=4) * u.km / u.s center = vertices.cell_centers("vdop") width = vertices.volume_cell("vdop") fraction = na.ScalarArray(np.array([0.25, 0.5, 0.25]), axes="vdop") result = utu.spectrum.synthesize( contribution=contribution, temperature=temperature, mass=ion.mass, emission_measure=emission_measure * fraction, velocity=na.linspace(-100, 100, axis="velocity", num=81) * u.km / u.s, shift=center, width_nonthermal=width / np.sqrt(12), axis_temperature=axis, axis_shift="vdop", ) fig, ax = plt.subplots(figsize=(6, 4), constrained_layout=True) na.plt.stairs( result.inputs.velocity, result.outputs, ax=ax, axis="velocity", ) ax.set_xlabel(f"velocity ({u.km / u.s:latex_inline})") ax.set_ylabel(f"spectral radiance\n({result.outputs.unit:latex_inline})");