Class Nebular

Class Documentation

class Nebular

Nebular emission line and continuum luminosity per ionizing photon, from a pre-computed cloudy grid.

This class looks up the “quick and dirty” nebular emission grid built by data/tools/cloudy’s own three-stage pipeline (see that directory’s own scripts) for one track set, and provides the line and continuum luminosity per ionizing photon it holds, as a function of [Fe/H] and (for a cluster) age – so that slug can add nebular emission to a stellar spectrum without running cloudy itself.

Public Types

using Grid2D = std::mdspan<double, std::dextents<std::size_t, 2>>
using Grid3D = std::mdspan<double, std::dextents<std::size_t, 3>>

Public Functions

Nebular(const std::string &tableName, const std::string &trackName, const io::SimControls &simControls, double vvcrit = tracks::defaultVVcrit)

Construct a Nebular object.

simControls is stored by reference, so the object passed in must outlive this Nebular. This constructor takes wl_ directly from simControls.specsyn()->wl() and, from it, builds ctmLumPerQCluster_/ctmLumPerQGalaxy_ (the table’s own continuum data, resampled onto wl_ via Interpolator1D) and lineLumPerQCluster_/lineLumPerQGalaxy_ (the table’s own line luminosities, read directly, for the table’s full line list in lineWl_/lineLabel_).

Parameters:
  • tableName – Path to the nebular emission table (see nebular::defaultTable) to load this track set’s own grid from; used only during construction, not retained afterward

  • trackName – Name of the track set this nebular grid is for; used only during construction (to locate this track set’s own cloudy grid data), not retained afterward

  • simControls – Simulation controls (physics and control-flow settings); also the source of the simulation wavelength grid the continuum luminosity grids should ultimately be resampled onto (simControls.specsyn()->wl()), so that grid need not be passed in separately

  • vvcrit – Rotation rate v/vcrit of the track set; like tableName and trackName, used only during construction, not retained afterward

Throws:
  • std::invalid_argument – if simControls.specsyn() is null: there would be no wavelength grid to resample onto

  • std::runtime_error – if tableName cannot be found (via utils::getFilePath), trackName has no group of its own in it, or – for any of that group’s own [Fe/H] values – no v/vcrit subgroup matches vvcrit exactly, or simControls.nebControls().logU_ falls outside the range of logU values actually tabulated for a given [Fe/H]/v/vcrit combination

~Nebular() = default
Nebular(const Nebular&) = delete
Nebular(Nebular&&) = delete
auto operator=(const Nebular&) -> Nebular& = delete
auto operator=(Nebular&&) -> Nebular& = delete
inline auto simControls() const -> const io::SimControls&

Get the SimControls this Nebular was constructed against.

Returns:

A const reference to simControls_ – see its own comment. Exposed so a caller replacing a SimControls’s own nebular emission grid (see SimControls::setNebular()) can verify it is installing a Nebular actually built against that same SimControls, rather than one whose simControls_ points somewhere else entirely.

inline auto lineLabel() const -> const std::vector<std::string>&

Get the label of each of this Nebular’s own nebular emission lines.

Returns:

lineLabel_, in the same order as lineWl() – see lineWl_’s own comment for that order’s own source

inline auto lineWl() const -> const std::vector<double>&

Get the wavelength of each of this Nebular’s own nebular emission lines.

Returns:

lineWl_, in Angstrom, in the table’s own line ordering (the same order as lineLabel())

auto getGalaxy(const std::vector<double> &spec, double feH) const -> std::pair<std::vector<double>, std::vector<double>>

Add whole-galaxy nebular emission to an input stellar spectrum.

Q(HI) (the H-ionizing photon rate) is read off spec via qhiFilter_, then discounted by simControls_.nebControls(). covFac_ (the fraction of ionizing photons actually absorbed by the nebula, rather than lost to dust grains or escaping the observational aperture); every quantity added below scales with that discounted rate. Every per-[Fe/H] quantity (lineLumPerQGalaxy_, ctmLumPerQGalaxy_) is linearly interpolated between the two tabulated [Fe/H] values bracketing feH. The continuum is added everywhere; the input spectrum itself is kept only above the H-ionization edge (wavelengths <= qhiFilter_.wlMax() are zeroed, since a real HII region reprocesses essentially all ionizing stellar flux); lines are deposited via depositLines().

Parameters:
  • spec – Input stellar spectrum, on this object’s own wl_ grid (i.e. simControls.specsyn()->wl(), see the constructor’s own comment), in erg/s/Angstrom

  • feH – [Fe/H] of the stellar population spec was computed for

Throws:

std::runtime_error – if feH falls outside feH_’s own tabulated range

Returns:

A pair whose first element is the stellar + nebular continuum + nebular line spectrum, on wl_’s own grid, in erg/s/Angstrom, and whose second element is the luminosity of each of lineWl()’s own lines, in erg/s

auto getCluster(const std::vector<double> &spec, double feH, double age) const -> std::pair<std::vector<double>, std::vector<double>>

Add one cluster’s own nebular emission to an input stellar spectrum.

Parameters:
  • spec – Input stellar spectrum, on this object’s own wl_ grid, in erg/s/Angstrom

  • feH – [Fe/H] of the cluster spec was computed for

  • age – Cluster age, in yr

Throws:

std::runtime_error – if feH falls outside feH_’s own tabulated range (age has no such failure mode: below clusterAge_’s own minimum is pinned to that minimum, and above its own maximum takes the early-return path described above)

Returns:

Same as getGalaxy(), but interpolated in cluster age as well as [Fe/H] – except that, for age above clusterAge_’s own tabulated range (this table has no data for a cluster this old), the returned line luminosities are all zero and the returned spectrum is just spec with every bin at or below the H-ionization edge zeroed (the same edge-zeroing getGalaxy() applies, with no continuum or line emission added)