Program Listing for File Nebular.hpp

↰ Return to documentation for file (src/nebular/Nebular.hpp)

#ifndef NEBULAR_HPP
#define NEBULAR_HPP

#include "../phot/FilterIdeal.hpp"
#include "../tracks/TrackCommons.hpp"
#include <cstddef>
#include <filesystem>
#include <mdspan> // NOLINT(misc-include-cleaner)
#include <string>
#include <utility>
#include <vector>

namespace io
{
    class SimControls;
} // namespace io

namespace nebular
{

    class Nebular
    {
    public:

        // Shorten mdspan types
        using Grid2D = std::mdspan<double, std::dextents<std::size_t, 2>>; // NOLINT(misc-include-cleaner)
        using Grid3D = std::mdspan<double, std::dextents<std::size_t, 3>>;

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

        ~Nebular() = default;

        // The mdspan members below are non-owning views into this
        // object's own backing vectors (lineLumPerQClusterData_ etc);
        // a naive copy or move would leave the copy's/moved-from's own
        // views pointing at the wrong object's data, so both are
        // disallowed for now -- mirrors utils::ThreadVec's own
        // identical reasoning for its own vector-backed member.
        Nebular(const Nebular&) = delete;
        Nebular(Nebular&&) = delete;
        auto operator=(const Nebular&) -> Nebular& = delete;
        auto operator=(Nebular&&) -> Nebular& = delete;

        // Observers

        [[nodiscard]] auto simControls() const -> const io::SimControls& { return simControls_; }

        [[nodiscard]] auto lineLabel() const -> const std::vector<std::string>& { return lineLabel_; }

        [[nodiscard]] auto lineWl() const -> const std::vector<double>& { return lineWl_; }

        // Nebular emission

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

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

    private:

        [[nodiscard]] auto stellarAboveEdge(const std::vector<double>& spec) const -> std::vector<double>;

        void depositLines(const std::vector<double>& lineLum, std::vector<double>& spec) const;

        void loadTable(const std::string& trackName, double vvcrit,
            const std::filesystem::path& tablePath);

        const io::SimControls& simControls_;
        phot::FilterIdeal qhiFilter_;

        std::vector<double> wl_;

        std::vector<std::string> lineLabel_;
        std::vector<double> lineWl_;
        std::vector<size_t> lineCenterIdx_;

        Grid2D lineDepositFrac_;
        std::vector<double> lineDepositFracData_;
        std::vector<double> feH_;
        std::vector<double> clusterAge_;
        Grid3D lineLumPerQCluster_;
        std::vector<double> lineLumPerQClusterData_;
        Grid2D lineLumPerQGalaxy_;
        std::vector<double> lineLumPerQGalaxyData_;
        Grid3D ctmLumPerQCluster_;
        std::vector<double> ctmLumPerQClusterData_;
        Grid2D ctmLumPerQGalaxy_;
        std::vector<double> ctmLumPerQGalaxyData_;
    };

} // namespace nebular

#endif // NEBULAR_HPP