Template Class SpecsynLib2D

Inheritance Relationships

Base Type

Derived Type

Class Documentation

template<OOBPolicy Policy>
class SpecsynLib2D : public specsyn::SpecsynLib<Policy>

A SpecsynLib specialization for a library with no first (dim1_) axis.

Some spectral libraries – e.g. the Tremblay et al. white dwarf atmosphere grids, or the Rauch et al. NLTE hot star grid – SpecsynLibWD reads have only two physical axes (log(g) and Teff), not three. Some of these (Tremblay’s) are distributed as a single, completely filled tensor over those two axes, with no unpopulated gaps at all; others (Rauch’s) are not, and have unpopulated (log(g), Teff) grid points just like a SpecsynLibNoWind/SpecsynLibWR library’s own (FeH, log(g), Teff) grid can. This class adapts SpecsynLib’s own (dim1_, dim2_, dim3_) machinery to the two-axis case by simply treating dim1_ as degenerate (left empty; grid_’s own first extent is hardcoded to 1 rather than dim1_.size(), so a derived class’s constructor never needs to populate dim1_ with a placeholder value at all – see SpecsynLibWD’s own constructor), and providing a simplified, two-argument spec() that interpolates only across dim2_ and dim3_, fixing the first tensor index to 0.

spec(double, double) itself is otherwise identical to SpecsynLib::spec(double, double, double) – same unpopulated- neighbor checking, same OOBPolicy::coerce handling – just with the leading dimension (and its 8-corner cube collapsed to a 4-corner square) removed; see that function’s own comment for the full rationale, which applies here unchanged.

Template Parameters:

Policy – See SpecsynLib.

Subclassed by specsyn::SpecsynLibWD< Policy >

Public Functions

inline explicit SpecsynLib2D(const io::SimControls &controls)

Construct an empty SpecsynLib2D.

Leaves dim1_, dim2_, dim3_, and spectra_ empty, and grid_ default-constructed, exactly as SpecsynLib’s own default constructor does. Populating dim2_, dim3_, and spectra_ (and constructing grid_ to view it, with a first extent of 1) is left entirely to a derived class’s own constructor, since this class has no way to know the grid’s shape until the derived class has read its own library file.

Parameters:

controls – Simulation controls; forwarded unchanged to SpecsynLib’s own constructor – see its comment

virtual void resample(const std::vector<double> &wlNew) override

Resample every spectrum in this library onto a new wavelength grid.

Overrides SpecsynLib::resample(const std::vector<double>&): that base implementation iterates i1 from 0 to dim1_.size() - 1, which for this class would be zero iterations at all, since dim1_ is deliberately left empty (see this class’s own comment) – silently leaving every stored spectrum on its old wavelength grid, mismatched against the wl_ the base implementation still updates unconditionally at the end. This override does the same thing the base does, but iterating over (dim2_, dim3_) alone with the degenerate first tensor index hardcoded to 0, mirroring spec(double, double)’s own hardcoding of it.

Parameters:

wlNew – The new wavelength grid, in Angstrom

Protected Functions

auto spec(double d2, double d3) const -> std::vector<double>

Compute a spectrum by bilinear interpolation at a point in the 2D grid.

Callers (i.e. a derived class’s own spec(const StarData&,

double) override) are responsible for having already checked that d2 and d3 each lie within [dim2_.front(), dim2_.back()] and [dim3_.front(), dim3_.back()] respectively. This method locates the bracketing grid cell along each axis (via

utils::findBracket

– the same cache-accelerated binary search SpecsynLib::spec(double,

double, double) itself uses, reusing dim2Cache_/dim3Cache_ rather than keeping a redundant cache of its own) and bilinearly interpolates the spectrum from the 4 neighboring grid points, with the degenerate first tensor index hardcoded to 0 – checking that those 4 neighbors are actually populated (honoring

OOBPolicy::coerce exactly as SpecsynLib::spec(double, double, double) does for its own 8 neighbors) exactly as that function does, just with the leading dimension removed. See SpecsynLib2D.cpp for the full implementation.

Parameters:
  • d2 – Query coordinate along dim2_

  • d3 – Query coordinate along dim3_

Throws:

std::runtime_error – under the same circumstances, if Policy is OOBPolicy::raise

Returns:

The interpolated spectrum, evaluated on the wavelength grid returned by wl()

, with no scaling applied beyond the interpolation itself – any further scaling (e.g. by a star’s surface area) is left entirely to the caller, exactly as SpecsynLib::spec(double, double,

double) leaves it to its own callers

Returns:

A size-0 vector if the query point falls in a gap in this library’s grid (or, under OOBPolicy::coerce, has no valid neighboring grid point to coerce to) and Policy is not OOBPolicy::raise