physics/solar.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | /// @file solar.cpp | ||
| 3 | /// @brief The embedded TSIS-1 solar spectrum. | ||
| 4 | #include "ernie/physics/solar.h" | ||
| 5 | |||
| 6 | #include "ernie/physics/solar_table.h" | ||
| 7 | |||
| 8 | #include <utility> | ||
| 9 | #include <vector> | ||
| 10 | |||
| 11 | namespace ernie { | ||
| 12 | |||
| 13 | 4 | const Spectrum& SolarSpectralIrradiance() { | |
| 14 | 3 | static const Spectrum spectrum = [] { | |
| 15 | 3 | std::vector<double> wavelengths; | |
| 16 | 3 | std::vector<double> values; | |
| 17 | 3 | wavelengths.reserve(solar_table::kCount); | |
| 18 | 3 | values.reserve(solar_table::kCount); | |
| 19 | 9144 | for (int i = 0; i < solar_table::kCount; ++i) { | |
| 20 | 9141 | wavelengths.push_back(solar_table::kPairs[2 * i]); | |
| 21 | 9141 | values.push_back(solar_table::kPairs[2 * i + 1]); | |
| 22 | } | ||
| 23 | 6 | return Spectrum(std::move(wavelengths), std::move(values)); | |
| 24 | 7 | }(); | |
| 25 | 4 | return spectrum; | |
| 26 | } | ||
| 27 | |||
| 28 | 1 | double TotalSolarIrradiance() { | |
| 29 | 1 | static const double total = [] { | |
| 30 | 1 | const Spectrum& sun = SolarSpectralIrradiance(); | |
| 31 | 1 | const double low = sun.Wavelengths().front(); | |
| 32 | 1 | const double high = sun.Wavelengths().back(); | |
| 33 | 1 | return sun.Average(low, high) * (high - low); | |
| 34 | 1 | }(); | |
| 35 | 1 | return total; | |
| 36 | } | ||
| 37 | |||
| 38 | } // namespace ernie | ||
| 39 |