include/terraingen/albedo/photometry.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | |||
| 3 | /// @file | ||
| 4 | /// @brief Hapke photometry of surface materials, and the mix a material map gives. | ||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "terraingen/layers/material.h" | ||
| 8 | #include "terraingen/raster/raster.h" | ||
| 9 | |||
| 10 | #include <array> | ||
| 11 | #include <optional> | ||
| 12 | #include <vector> | ||
| 13 | |||
| 14 | namespace terraingen { | ||
| 15 | |||
| 16 | /// The Hapke (1993) parameters of a surface, as fitted to Pancam photometry. | ||
| 17 | ✗ | struct HapkeParameters { | |
| 18 | double albedo = 0.0; ///< Single-scattering albedo w, in [0, 1]. | ||
| 19 | double b = 0.0; ///< Two-term Henyey-Greenstein asymmetry b, in [0, 1]. | ||
| 20 | double c = 0.0; ///< Two-term Henyey-Greenstein backscatter fraction c, in [0, 1]. | ||
| 21 | double roughness = 0.0; ///< Macroscopic roughness theta-bar (deg), in [0, 90). | ||
| 22 | |||
| 23 | 1 | bool operator==(const HapkeParameters& other) const { | |
| 24 | 1 | return albedo == other.albedo && b == other.b && c == other.c && | |
| 25 | 1 | roughness == other.roughness; | |
| 26 | } | ||
| 27 | bool operator!=(const HapkeParameters& other) const { | ||
| 28 | return !(*this == other); | ||
| 29 | } | ||
| 30 | }; | ||
| 31 | |||
| 32 | /// Hapke parameters per `MaterialClass`; a class without any cannot be mixed. | ||
| 33 | using MaterialPhotometry = std::array<std::optional<HapkeParameters>, kMaterialClasses>; | ||
| 34 | |||
| 35 | /// Hapke parameters of Martian soil, sand, dust, bedrock and rock at 753 nm from Pancam (Johnson | ||
| 36 | /// et al. 2006a, b; Fernando et al. 2013). | ||
| 37 | MaterialPhotometry MarsPancamPhotometry(); | ||
| 38 | |||
| 39 | /// Checks photometry parameters. | ||
| 40 | /// @throws std::invalid_argument naming the class and parameter outside its range, such as | ||
| 41 | /// "soil.albedo". | ||
| 42 | void ValidateMaterialPhotometry(const MaterialPhotometry& photometry); | ||
| 43 | |||
| 44 | /// The Hapke parameters of a mix of materials: each parameter the share-weighted mean of the | ||
| 45 | /// classes', an areal mix approximation. | ||
| 46 | /// @throws std::invalid_argument if a class with a share has no parameters. | ||
| 47 | HapkeParameters MixPhotometry(const MaterialShares& shares, const MaterialPhotometry& photometry); | ||
| 48 | |||
| 49 | /// Rasters of the albedo, b, c and roughness that the material rasters `materials` (one per | ||
| 50 | /// class, as `EvaluateMaterials` gives) mix to. | ||
| 51 | /// @throws std::invalid_argument for the wrong number of rasters, rasters on different grids, or | ||
| 52 | /// as `MixPhotometry`. | ||
| 53 | std::vector<Raster<float>> EvaluatePhotometry(const std::vector<Raster<float>>& materials, | ||
| 54 | const MaterialPhotometry& photometry); | ||
| 55 | |||
| 56 | } // namespace terraingen | ||
| 57 |