Class FilterCollection
Defined in File FilterCollection.hpp
Class Documentation
-
class FilterCollection
Holds all the filters for which photometry will be computed in a simulation.
Constructed from a list of filter names, each of which is parsed to determine whether it names a tabulated filter (a facility.filter or facility.instrument.filter name, resolved against a filter registry – see FilterTabulated) or an idealized filter (one of FilterIdeal’s own naming conventions), and builds the corresponding Filter for each. phot() then evaluates every filter in the collection against a spectrum in one call, converting each energy-flux filter’s result to the requested photometric system.
Public Functions
-
FilterCollection(const std::vector<std::string> &filterNames, PhotSystem photSystem, const std::string ®istryName = defaultRegistry)
Construct a FilterCollection from a list of filter names.
If photSystem is PhotSystem::Vega, each non-photCount() filter’s Vega zero point is computed lazily, from the global Vega reference spectrum, the first time it is actually needed – see Filter::fluxVega() and phot::vegaSpectrum().
- Parameters:
filterNames – Names of the filters to include; each must be either a tabulated-filter name (facility.filter or facility.instrument.filter, the latter’s instrument omitted only for a facility with exactly one instrument in the registry – see FilterTabulated) or an idealized- filter name (ideal_energy_X_Y, ideal_phot_X_Y, or Q(…) – see FilterIdeal)
photSystem – The photometric system phot() converts energy-flux (photCount() == false) filters’ results into
registryName – Name of the filter registry file to resolve tabulated filter names against
- Throws:
std::runtime_error – if any entry of filterNames does not match a recognized tabulated- or idealized-filter naming convention, or if constructing the corresponding Filter itself throws (e.g. an unknown facility/instrument/ filter, an ambiguous instrument-omitted facility, or an unparseable idealized-filter name)
-
virtual ~FilterCollection() = default
-
FilterCollection(const FilterCollection&) = delete
-
auto operator=(const FilterCollection&) -> FilterCollection& = delete
-
FilterCollection(FilterCollection&&) = default
-
auto operator=(FilterCollection&&) -> FilterCollection& = default
-
void addFilter(const std::string &name, const std::string ®istryName = defaultRegistry)
Parse a filter name and add the resulting filter to this collection.
Used by the constructor to build each filter named in filterNames, one at a time; also public so a caller (e.g. from Python, where a FilterCollection can be built up incrementally rather than from a single up-front list of names) can add filters to an already-constructed FilterCollection one name at a time.
- Parameters:
name – Name of the filter to add; see the constructor’s own filterNames parameter for the recognized naming conventions
registryName – Name of the filter registry file to resolve a tabulated filter name against; unused for an idealized filter name
- Throws:
std::runtime_error – if name does not match a recognized tabulated- or idealized-filter naming convention, or if constructing the corresponding Filter itself throws
-
inline void addFilter(std::unique_ptr<Filter> filter)
Add an already-constructed filter to this collection.
Lets a caller (e.g. from Python, where FilterIdeal and FilterTabulated both have their own accessible constructors) add a filter it built directly, rather than by name via the other addFilter() overload.
- Parameters:
filter – The filter to add; ownership is transferred to this FilterCollection
-
inline auto phot(const std::vector<double> &wl, const std::vector<double> &spec) const -> std::vector<double>
Compute the photometric response of every filter in this collection to a spectrum.
Equivalent to phot(wl, spec, wl): wl is taken to be the full wavelength grid, so no filter is treated as truncated.
- Parameters:
wl – The wavelength grid, in Angstrom, on which spec is computed
spec – The spectrum to which to compute the photometric response
- Returns:
One value per filter, in the same order as filterNames()/filterUnits(): for a photCount() filter, Filter::phot()’s own photon-count value, unconverted (PhotSystem conversions apply only to energy fluxes); for an energy-flux filter, Filter::phot()’s F_lambda value, converted to this collection’s photSystem via PhotConvert (left as-is if photSystem is already Flambda; for Vega, using this filter’s own fluxVega() – lazily computed the first time it is needed, see Filter::fluxVega() – as the zero point)
-
auto phot(const std::vector<double> &wl, const std::vector<double> &spec, const std::vector<double> &wlFull) const -> std::vector<double>
Compute the photometric response of every filter in this collection to a spectrum on a truncated wavelength grid.
A filter whose response lies entirely outside wlFull is not set to NaN: there the spectrum is genuinely absent from the full grid as well, and is handled the same way as by the two-argument phot(). If wl is empty, every filter that overlaps wlFull is NaN.
- Parameters:
wl – The wavelength grid, in Angstrom, on which spec is computed – a contiguous, ascending sub-range of wlFull (e.g. wlFull chopped to an extinction curve’s own coverage)
spec – The spectrum to which to compute the photometric response
wlFull – The full wavelength grid, in Angstrom, of which wl is a sub-range; only its first and last elements are used
- Returns:
As for the two-argument phot(), except that a filter is NaN if its response (see Filter::wlSupport()) overlaps any part of [wlFull.front(), wlFull.back()] that lies outside [wl.front(), wl.back()] – i.e. if part of its passband falls where the spectrum is unknown, rather than zero, because the grid was truncated there
-
auto filterNames() const -> std::vector<std::string>
Get the names of every filter in this collection.
- Returns:
The name() of every filter, in the same order as phot()/filterUnits()
-
auto filterUnits() const -> std::vector<std::string>
Get the units of every filter’s phot() value.
- Returns:
For a photCount() filter: “photon/s”; for an energy-flux filter: “erg/(s Angstrom)” (Flambda), “erg/(s Hz)” (Fnu), “mag(ST)” (ST), “mag(AB)” (AB), or “mag” (Vega – astropy has no dedicated Vega-magnitude unit) matching this collection’s photSystem – in the same order as phot()/filterNames()
-
inline auto filters() const -> const std::vector<std::unique_ptr<Filter>>&
Get const access to the filters in this collection.
- Returns:
A const reference to the underlying filters, in the same order as phot()/filterNames()/filterUnits()
-
FilterCollection(const std::vector<std::string> &filterNames, PhotSystem photSystem, const std::string ®istryName = defaultRegistry)