src/config/craters.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | |||
| 3 | /// @file | ||
| 4 | /// @brief Crater and secondary crater layers in a configuration: their densities, ages, | ||
| 5 | /// degradation and profiles, fields, checks and building. | ||
| 6 | #pragma once | ||
| 7 | |||
| 8 | #include "config/layer_context.h" | ||
| 9 | |||
| 10 | #include "terraingen/distribution/distribution_fields.h" | ||
| 11 | #include "terraingen/distribution/moore.h" | ||
| 12 | #include "terraingen/distribution/piecewise_power_law.h" | ||
| 13 | #include "terraingen/distribution/piecewise_uniform.h" | ||
| 14 | #include "terraingen/distribution/size_frequency.h" | ||
| 15 | #include "terraingen/layers/craters/crater_fields.h" | ||
| 16 | #include "terraingen/layers/craters/crater_layer.h" | ||
| 17 | #include "terraingen/layers/craters/degradation/diffusion.h" | ||
| 18 | #include "terraingen/layers/craters/profiles/fassett_thomson.h" | ||
| 19 | #include "terraingen/layers/craters/secondaries.h" | ||
| 20 | #include "terraingen/layers/craters/shaping/apply.h" | ||
| 21 | #include "terraingen/layers/craters/shaping/morphometry.h" | ||
| 22 | #include "terraingen/random/random_fields.h" | ||
| 23 | |||
| 24 | #include <array> | ||
| 25 | #include <cstddef> | ||
| 26 | #include <cstdint> | ||
| 27 | #include <memory> | ||
| 28 | #include <optional> | ||
| 29 | #include <string> | ||
| 30 | #include <string_view> | ||
| 31 | #include <variant> | ||
| 32 | #include <vector> | ||
| 33 | |||
| 34 | namespace terraingen { | ||
| 35 | |||
| 36 | /// Density "power_law": `PowerLawSfd`, N per m^2 with D in meters. | ||
| 37 | 202 | struct PowerLawSpec { | |
| 38 | double coefficient = 0.1; | ||
| 39 | double exponent = 2.0; | ||
| 40 | }; | ||
| 41 | /// Density "piecewise_power_law": `PiecewisePowerLawSfd`. | ||
| 42 | 459 | struct PiecewisePowerLawSpec { | |
| 43 | std::vector<PowerLawSegment> segments{PowerLawSegment{}}; | ||
| 44 | }; | ||
| 45 | /// Density "tabulated": `TabulatedSfd` from (D, N(>=D)) rows. | ||
| 46 | 265 | struct TabulatedSpec { | |
| 47 | std::vector<double> diameters; | ||
| 48 | std::vector<double> cumulative; | ||
| 49 | double diameterUnit = 1.0; ///< Meters per table diameter unit; 1000 for km. | ||
| 50 | double areaUnit = 1.0; ///< Square meters per table area unit; 1e6 for km^2. | ||
| 51 | }; | ||
| 52 | /// Density "piecewise_uniform": `PiecewiseUniformSfd`, bands with diameters spread uniformly. | ||
| 53 | 406 | struct PiecewiseUniformSpec { | |
| 54 | std::vector<UniformBand> bands{UniformBand{}}; | ||
| 55 | double total = 0.0; ///< Per m^2 across all bands, shared by `density`; 0 for as given. | ||
| 56 | }; | ||
| 57 | /// Crater density "trask": `TraskEquilibrium`. | ||
| 58 | struct TraskSpec {}; | ||
| 59 | /// Crater density "hartmann": `HartmannEquilibrium`. | ||
| 60 | struct HartmannSpec {}; | ||
| 61 | /// Crater density "moore": `MooreDistribution(terrain)`. | ||
| 62 | struct MooreSpec { | ||
| 63 | MooreTerrain terrain = MooreTerrain::RoughMare; | ||
| 64 | }; | ||
| 65 | /// Crater density "viper": `ViperSpecification`. | ||
| 66 | struct ViperSpec {}; | ||
| 67 | /// A published crater production function, a `ProductionRate`. | ||
| 68 | enum class ProductionFunction { | ||
| 69 | Neukum, ///< "neukum": `NeukumProductionFunction`, 10 m to 300 km. | ||
| 70 | ExtendedNeukum, ///< "extended_neukum": `ExtendedNeukumProductionFunction`, 2.5 m to 300 km. | ||
| 71 | Ivanov, ///< "ivanov": `IvanovMarsProductionFunction`, 15 m to 362 km. | ||
| 72 | }; | ||
| 73 | /// A published crater chronology, N(>=1 km) by surface age. | ||
| 74 | enum class ChronologyModel { | ||
| 75 | Neukum, ///< "neukum": `NeukumLunarChronology`. | ||
| 76 | Ivanov, ///< "ivanov": `IvanovMarsChronology`. | ||
| 77 | }; | ||
| 78 | /// Crater density "production_surface": `ProductionSurface`, the craters `production` leaves on a | ||
| 79 | /// surface `ageGyr` old by `chronology`, with no erosion. | ||
| 80 | struct ProductionSurfaceSpec { | ||
| 81 | ProductionFunction production = ProductionFunction::ExtendedNeukum; | ||
| 82 | ChronologyModel chronology = ChronologyModel::Neukum; | ||
| 83 | double ageGyr = 3.5; | ||
| 84 | }; | ||
| 85 | struct MinimumSpec; | ||
| 86 | /// A crater density, named in JSON by its "type". | ||
| 87 | using DensitySpec = | ||
| 88 | std::variant<PowerLawSpec, PiecewisePowerLawSpec, TabulatedSpec, ProductionSurfaceSpec, | ||
| 89 | MinimumSpec, TraskSpec, HartmannSpec, MooreSpec, ViperSpec, PiecewiseUniformSpec>; | ||
| 90 | /// Crater density "minimum": `MinimumSfd`, the least of `distributions` at each diameter, such as | ||
| 91 | /// a production surface capped by an equilibrium. | ||
| 92 | 6210 | struct MinimumSpec { | |
| 93 | std::vector<DensitySpec> distributions; | ||
| 94 | }; | ||
| 95 | |||
| 96 | /// Crater ages "fresh": `FreshAges`. | ||
| 97 | struct FreshAgesSpec {}; | ||
| 98 | /// Crater ages "uniform": `UniformAges(lifetimeGyr)`. | ||
| 99 | 101 | struct UniformAgesSpec { | |
| 100 | double lifetimeGyr = 1.0; | ||
| 101 | }; | ||
| 102 | /// Equilibrium densities for `SteadyStateAgesSpec`. | ||
| 103 | enum class EquilibriumModel { Trask, Hartmann }; | ||
| 104 | /// Crater ages "steady_state": `SteadyStateAges` from `production`, `equilibrium` and | ||
| 105 | /// `chronology`. | ||
| 106 | struct SteadyStateAgesSpec { | ||
| 107 | double ageGyr = 3.5; | ||
| 108 | ProductionFunction production = ProductionFunction::ExtendedNeukum; | ||
| 109 | EquilibriumModel equilibrium = EquilibriumModel::Hartmann; | ||
| 110 | ChronologyModel chronology = ChronologyModel::Neukum; | ||
| 111 | }; | ||
| 112 | /// Crater ages "freshness": `FreshnessAges(freshness, lifetimeGyr)`. | ||
| 113 | 626 | struct FreshnessAgesSpec { | |
| 114 | double lifetimeGyr = 1.0; | ||
| 115 | ValueDistribution freshness{ValueDistribution::Kind::Uniform, 0.0, 1.0, 0.0, 1.0}; | ||
| 116 | }; | ||
| 117 | /// A crater age model, named in JSON by its "type". | ||
| 118 | using AgesSpec = | ||
| 119 | std::variant<UniformAgesSpec, FreshAgesSpec, SteadyStateAgesSpec, FreshnessAgesSpec>; | ||
| 120 | |||
| 121 | /// Degradation "none": `NoDegradation`, optionally with a fixed depth-to-diameter ratio. | ||
| 122 | struct NoDegradationSpec { | ||
| 123 | std::optional<double> depthRatio; | ||
| 124 | }; | ||
| 125 | /// Degradation "freshness": `FreshnessDegradation`. | ||
| 126 | struct FreshnessDegradationSpec { | ||
| 127 | double cutoffDepthRatio = 0.04; | ||
| 128 | }; | ||
| 129 | /// Where "diffusion" degradation takes its diffusion ages from. | ||
| 130 | enum class DiffusivityModel { | ||
| 131 | /// "matched": `EquilibriumDiffusionAges` with steady-state ages, else `Fassett2022Hartmann`. | ||
| 132 | Matched, | ||
| 133 | Fassett2022Hartmann, ///< "fassett_2022_hartmann": `Fassett2022HartmannDiffusivity`. | ||
| 134 | Fassett2022Trask, ///< "fassett_2022_trask": `Fassett2022TraskDiffusivity`. | ||
| 135 | FassettThomson2014, ///< "fassett_thomson_2014": `FassettThomson2014Diffusivity`. | ||
| 136 | /// "fassett_thomson_2014_calibration": `FassettThomson2014DiffusionAge`. | ||
| 137 | FassettThomson2014Calibration, | ||
| 138 | PowerLaw, ///< "power_law": the spec's `powerLaw`. | ||
| 139 | }; | ||
| 140 | /// Degradation "diffusion": `DiffusionDegradation`, the layer's profile worn by topographic | ||
| 141 | /// diffusion (`DiffusedProfile`). | ||
| 142 | struct DiffusionDegradationSpec { | ||
| 143 | DiffusivityModel diffusivity = DiffusivityModel::Matched; | ||
| 144 | PowerLawDiffusivity powerLaw{}; ///< Used when `diffusivity` is `PowerLaw`. | ||
| 145 | double reachRadii = 3.0; ///< How far the diffused profile reaches, in crater radii. | ||
| 146 | }; | ||
| 147 | /// A degradation model, named in JSON by its "type". | ||
| 148 | using DegradationSpec = | ||
| 149 | std::variant<FreshnessDegradationSpec, NoDegradationSpec, DiffusionDegradationSpec>; | ||
| 150 | |||
| 151 | /// Crater profile "fassett_thomson": `FassettThomsonProfile(rim)`. | ||
| 152 | struct FassettThomsonSpec { | ||
| 153 | FassettThomsonRim rim = FassettThomsonRim::Original; | ||
| 154 | }; | ||
| 155 | /// Crater profile "martin_parkes_dunstan": `MartinParkesDunstanProfile`. | ||
| 156 | struct MartinParkesDunstanSpec {}; | ||
| 157 | /// A simple crater profile, named in JSON by its "type". | ||
| 158 | using SimpleProfileSpec = std::variant<FassettThomsonSpec, MartinParkesDunstanSpec>; | ||
| 159 | /// Crater profile "complex": `simple` below the simple-to-complex transition of the layer's | ||
| 160 | /// morphometry, and complex craters, with flat floors and central peaks, from it | ||
| 161 | /// (`ComplexCraterProfile` with `LunarComplexCraterShape` or `MarsComplexCraterShape`). | ||
| 162 | struct ComplexProfileSpec { | ||
| 163 | SimpleProfileSpec simple{MartinParkesDunstanSpec{}}; | ||
| 164 | }; | ||
| 165 | /// A crater profile, named in JSON by its "type". | ||
| 166 | using ProfileSpec = std::variant<FassettThomsonSpec, MartinParkesDunstanSpec, ComplexProfileSpec>; | ||
| 167 | |||
| 168 | /// The published fits of fresh crater depth, rim height and complex crater shape that a crater | ||
| 169 | /// layer shapes its craters with. | ||
| 170 | enum class CraterMorphometryFit { | ||
| 171 | Lunar, ///< "lunar": `LunarFreshCraterMorphometry` and `LunarComplexCraterShape`. | ||
| 172 | Mars, ///< "mars": `MarsFreshCraterMorphometry` and `MarsComplexCraterShape`. | ||
| 173 | }; | ||
| 174 | |||
| 175 | /// Gives `CraterLayerOptions::inherited`: `inherited` with the craters of a coarser level read | ||
| 176 | /// from the crater list `path`. | ||
| 177 | 167 | struct InheritedCratersSpec { | |
| 178 | /// A crater list (`ReadCraterList`), relative to the configuration's folder. | ||
| 179 | std::string path{}; | ||
| 180 | InheritedCraters inherited{}; ///< Its `craters` are left empty; `path` gives them. | ||
| 181 | }; | ||
| 182 | |||
| 183 | /// Layer "craters": craters generated over the grid and applied to it (`CraterLayer`). | ||
| 184 | struct CraterLayerSpec { | ||
| 185 | /// The layer's options; the specs below give its manual craters, density map, completeness | ||
| 186 | /// and inherited craters, and the secondary layers after it its secondaries. | ||
| 187 | CraterLayerOptions options{}; | ||
| 188 | CraterMorphometryFit morphometry = CraterMorphometryFit::Lunar; | ||
| 189 | /// By default a 3.5 Gyr extended Neukum production surface capped by Hartmann equilibrium | ||
| 190 | /// (Fassett 2022, https://doi.org/10.1029/2022JE007510). | ||
| 191 | DensitySpec density{MinimumSpec{{ProductionSurfaceSpec{}, HartmannSpec{}}}}; | ||
| 192 | /// Unset gives steady-state ages matching the density (`LayerAges`). | ||
| 193 | std::optional<AgesSpec> ages{}; | ||
| 194 | /// Manual craters, in the surface's coordinates; parsing sets their `manual` flag. | ||
| 195 | std::vector<Crater> manual{}; | ||
| 196 | ProfileSpec profile{MartinParkesDunstanSpec{}}; | ||
| 197 | /// By default diffusion matched to those ages. | ||
| 198 | DegradationSpec degradation{DiffusionDegradationSpec{}}; | ||
| 199 | std::optional<DensityMapSpec> densityMap{}; ///< Gives `CraterLayerOptions::densityMap`. | ||
| 200 | /// Gives `generation.completeness`: where `manual` is a complete catalog, from which diameter. | ||
| 201 | std::optional<FieldSpec> completeness{}; | ||
| 202 | /// Gives `CraterLayerOptions::inherited`. | ||
| 203 | std::optional<InheritedCratersSpec> replaceInheritedCraters{}; | ||
| 204 | }; | ||
| 205 | |||
| 206 | /// Layer "secondaries": secondary craters around the craters of the last crater layer before this | ||
| 207 | /// one (`SecondaryCraterLayer`), shaped with that layer's profile at a fixed depth ratio and the | ||
| 208 | /// fresh rim of `morphometry`. `secondaries.onsetCount` must be given. | ||
| 209 | 313 | struct SecondaryLayerSpec { | |
| 210 | SecondaryCraterOptions secondaries{}; | ||
| 211 | double depthRatio = 0.11; ///< Depth-to-diameter ratio. | ||
| 212 | CraterMorphometryFit morphometry = CraterMorphometryFit::Lunar; | ||
| 213 | }; | ||
| 214 | |||
| 215 | template <> struct EnumNames<EquilibriumModel> { | ||
| 216 | static constexpr std::array<EnumEntry<EquilibriumModel>, 2> kValues{{ | ||
| 217 | {"trask", EquilibriumModel::Trask, | ||
| 218 | "Trask (1966) lunar equilibrium, N(>=D) = 10^-1.1 D^-2, as the DSNE uses."}, | ||
| 219 | {"hartmann", EquilibriumModel::Hartmann, | ||
| 220 | "Hartmann (1984) lunar equilibrium, N(>=D) = 10^-1.14 D^-1.83 per km^2 with D in km."}, | ||
| 221 | }}; | ||
| 222 | }; | ||
| 223 | |||
| 224 | template <> struct EnumNames<ProductionFunction> { | ||
| 225 | static constexpr std::array<EnumEntry<ProductionFunction>, 3> kValues{{ | ||
| 226 | {"neukum", ProductionFunction::Neukum, | ||
| 227 | "Neukum et al. (2001) lunar production function, valid from 10 m to 300 km."}, | ||
| 228 | {"extended_neukum", ProductionFunction::ExtendedNeukum, | ||
| 229 | "The Neukum production function continued below 10 m as a power law of slope -2.85, " | ||
| 230 | "valid from 2.5 m to 300 km."}, | ||
| 231 | {"ivanov", ProductionFunction::Ivanov, | ||
| 232 | "Ivanov (2001) Martian production function, valid from 15 m to 362 km."}, | ||
| 233 | }}; | ||
| 234 | }; | ||
| 235 | |||
| 236 | template <> struct EnumNames<ChronologyModel> { | ||
| 237 | static constexpr std::array<EnumEntry<ChronologyModel>, 2> kValues{{ | ||
| 238 | {"neukum", ChronologyModel::Neukum, | ||
| 239 | "Neukum et al. (2001) lunar chronology, for surfaces 0 to 4.6 Gyr old."}, | ||
| 240 | {"ivanov", ChronologyModel::Ivanov, | ||
| 241 | "Ivanov (2001) Martian chronology, for surfaces 0 to 4.6 Gyr old."}, | ||
| 242 | }}; | ||
| 243 | }; | ||
| 244 | |||
| 245 | template <> struct EnumNames<DiffusivityModel> { | ||
| 246 | static constexpr std::array<EnumEntry<DiffusivityModel>, 6> kValues{{ | ||
| 247 | {"matched", DiffusivityModel::Matched, | ||
| 248 | "With steady-state ages, the diffusivity that wears each crater to Fassett et al.'s " | ||
| 249 | "(2022) visibility cutoff, depth 0.04 of the diameter, at the end of its equilibrium " | ||
| 250 | "lifetime, as they derive it, for the layer's own profile; fassett_2022_hartmann for " | ||
| 251 | "other ages."}, | ||
| 252 | {"fassett_2022_hartmann", DiffusivityModel::Fassett2022Hartmann, | ||
| 253 | "Lunar size-dependent diffusivity of Fassett et al. (2022) for the Hartmann equilibrium, " | ||
| 254 | "3.6 D^0.87 m^2/Myr with D in km."}, | ||
| 255 | {"fassett_2022_trask", DiffusivityModel::Fassett2022Trask, | ||
| 256 | "Lunar size-dependent diffusivity of Fassett et al. (2022) for the Trask equilibrium, " | ||
| 257 | "3.1 D^1.05 m^2/Myr with D in km."}, | ||
| 258 | {"fassett_thomson_2014", DiffusivityModel::FassettThomson2014, | ||
| 259 | "Lunar diffusivity of Fassett and Thomson (2014), 5.5 m^2/Myr for every crater size; it " | ||
| 260 | "erases craters below a few hundred meters within a small share of their lifetimes."}, | ||
| 261 | {"fassett_thomson_2014_calibration", DiffusivityModel::FassettThomson2014Calibration, | ||
| 262 | "Fassett and Thomson's (2014) lunar diffusion age against crater age, independent of " | ||
| 263 | "size; suits kilometer-scale craters."}, | ||
| 264 | {"power_law", DiffusivityModel::PowerLaw, | ||
| 265 | "A diffusivity of your own, coefficient (D / 1 km)^exponent m^2/Myr, from the power_law " | ||
| 266 | "settings."}, | ||
| 267 | }}; | ||
| 268 | }; | ||
| 269 | |||
| 270 | template <> struct EnumNames<CraterMorphometryFit> { | ||
| 271 | static constexpr std::array<EnumEntry<CraterMorphometryFit>, 2> kValues{{ | ||
| 272 | {"lunar", CraterMorphometryFit::Lunar, | ||
| 273 | "Fresh lunar craters: Fassett et al. (2022) depth and rim height below 15 km, Pike's " | ||
| 274 | "(1977) complex crater fits above."}, | ||
| 275 | {"mars", CraterMorphometryFit::Mars, | ||
| 276 | "Fresh Martian craters: depth and rim height capped for small craters, Garvin et al.'s " | ||
| 277 | "(2003) fits for large and complex craters from 7 km."}, | ||
| 278 | }}; | ||
| 279 | }; | ||
| 280 | |||
| 281 | template <> struct SpecName<PowerLawSpec> { | ||
| 282 | static constexpr std::string_view kName = "power_law"; | ||
| 283 | static constexpr std::string_view kDescription = | ||
| 284 | "A cumulative power law, N(>=D) = coefficient D^-exponent per m^2 with D in meters."; | ||
| 285 | }; | ||
| 286 | 121 | template <typename IO> void Fields(IO& io, PowerLawSpec& spec) { | |
| 287 | 121 | io("coefficient", spec.coefficient, | |
| 288 | "Coefficient of N(>=D) = coefficient D^-exponent, the cumulative count per m^2 with D in " | ||
| 289 | "meters; scales how many there are.", | ||
| 290 | 121 | "", Above(0.0)); | |
| 291 | 121 | io("exponent", spec.exponent, | |
| 292 | "Exponent of the power law; larger values give relatively more small craters or boulders.", | ||
| 293 | 121 | "", Above(0.0)); | |
| 294 | 121 | } | |
| 295 | |||
| 296 | template <> struct SpecName<PiecewisePowerLawSpec> { | ||
| 297 | static constexpr std::string_view kName = "piecewise_power_law"; | ||
| 298 | static constexpr std::string_view kDescription = | ||
| 299 | "A cumulative distribution made of power-law segments over diameter ranges."; | ||
| 300 | }; | ||
| 301 | 97 | template <typename IO> void Fields(IO& io, PiecewisePowerLawSpec& spec) { | |
| 302 | 97 | io("segments", spec.segments, | |
| 303 | "Power-law segments in strictly increasing order of start, each running to the next one's " | ||
| 304 | "start; they must meet at their joins."); | ||
| 305 | 97 | } | |
| 306 | |||
| 307 | template <> struct SpecName<TabulatedSpec> { | ||
| 308 | static constexpr std::string_view kName = "tabulated"; | ||
| 309 | static constexpr std::string_view kDescription = | ||
| 310 | "A cumulative distribution from a table of diameters and counts N(>=D), in units you " | ||
| 311 | "choose."; | ||
| 312 | }; | ||
| 313 | 93 | template <typename IO> void Fields(IO& io, TabulatedSpec& spec) { | |
| 314 | 93 | io("diameters", spec.diameters, | |
| 315 | "Table diameters in diameter units, strictly increasing; counts " | ||
| 316 | "are interpolated linearly in log D and log N between them.", | ||
| 317 | 93 | "", Above(0.0).MinLength(2)); | |
| 318 | 89 | io("cumulative", spec.cumulative, | |
| 319 | 89 | "Cumulative count N(>=D) at each diameter, per area unit; not increasing.", "", Above(0.0)); | |
| 320 | 89 | io("diameter_unit", spec.diameterUnit, | |
| 321 | 89 | "Meters per table diameter unit: 1 for meters, 1000 for km.", "m/unit", Above(0.0)); | |
| 322 | 89 | io("area_unit", spec.areaUnit, "Square meters per table area unit: 1 for m^2, 1e6 for km^2.", | |
| 323 | 89 | "m^2", Above(0.0)); | |
| 324 | 89 | } | |
| 325 | |||
| 326 | template <> struct SpecName<PiecewiseUniformSpec> { | ||
| 327 | static constexpr std::string_view kName = "piecewise_uniform"; | ||
| 328 | static constexpr std::string_view kDescription = | ||
| 329 | "Counts per m^2 in diameter bands, each with diameters spread uniformly across it; none " | ||
| 330 | "outside the bands."; | ||
| 331 | }; | ||
| 332 | 90 | template <typename IO> void Fields(IO& io, PiecewiseUniformSpec& spec) { | |
| 333 | 90 | io("bands", spec.bands, | |
| 334 | "Diameter bands with their counts; overlapping bands add, and gaps between them hold " | ||
| 335 | "none."); | ||
| 336 | 90 | io("total", spec.total, | |
| 337 | "Count per m^2 of all bands together, shared in proportion to each band's density; 0 uses " | ||
| 338 | "the densities as given.", | ||
| 339 | 90 | "1/m^2", AtLeast(0.0)); | |
| 340 | 90 | } | |
| 341 | |||
| 342 | template <> struct SpecName<ProductionSurfaceSpec> { | ||
| 343 | static constexpr std::string_view kName = "production_surface"; | ||
| 344 | static constexpr std::string_view kDescription = | ||
| 345 | "The craters a production function leaves on a surface of a given age, scaled by a " | ||
| 346 | "chronology, with no erosion; cap it with an equilibrium in a minimum."; | ||
| 347 | }; | ||
| 348 | 714 | template <typename IO> void Fields(IO& io, ProductionSurfaceSpec& spec) { | |
| 349 | 714 | io("production", spec.production, "Production function that gives the craters' sizes."); | |
| 350 | 1103 | io("chronology", spec.chronology, | |
| 351 | "Chronology that gives how many craters at least 1 km across the surface holds."); | ||
| 352 | 712 | io("age_gyr", spec.ageGyr, "Age of the surface in Gyr; older surfaces hold more craters.", | |
| 353 | 712 | "Gyr", Between(0.0, 4.6)); | |
| 354 | 710 | } | |
| 355 | |||
| 356 | template <> struct SpecName<MinimumSpec> { | ||
| 357 | static constexpr std::string_view kName = "minimum"; | ||
| 358 | static constexpr std::string_view kDescription = | ||
| 359 | "The least of several densities at each diameter, such as a production surface capped " | ||
| 360 | "by an equilibrium."; | ||
| 361 | }; | ||
| 362 | 706 | template <typename IO> void Fields(IO& io, MinimumSpec& spec) { | |
| 363 | 706 | io("distributions", spec.distributions, | |
| 364 | "Densities whose least cumulative count at each diameter is used; at least one."); | ||
| 365 | 704 | } | |
| 366 | |||
| 367 | template <> struct SpecName<TraskSpec> { | ||
| 368 | static constexpr std::string_view kName = "trask"; | ||
| 369 | static constexpr std::string_view kDescription = | ||
| 370 | "The Trask (1966) lunar equilibrium density, N(>=D) = 10^-1.1 D^-2."; | ||
| 371 | }; | ||
| 372 | template <typename IO> void Fields(IO& /*io*/, TraskSpec& /*spec*/) {} | ||
| 373 | |||
| 374 | template <> struct SpecName<HartmannSpec> { | ||
| 375 | static constexpr std::string_view kName = "hartmann"; | ||
| 376 | static constexpr std::string_view kDescription = | ||
| 377 | "The Hartmann (1984) lunar equilibrium density, N(>=D) = 10^-1.14 D^-1.83 per km^2 with D " | ||
| 378 | "in km."; | ||
| 379 | }; | ||
| 380 | template <typename IO> void Fields(IO& /*io*/, HartmannSpec& /*spec*/) {} | ||
| 381 | |||
| 382 | template <> struct SpecName<MooreSpec> { | ||
| 383 | static constexpr std::string_view kName = "moore"; | ||
| 384 | static constexpr std::string_view kDescription = | ||
| 385 | "Moore's terrain-specific crater distributions for Lunar Roving Vehicle trafficability."; | ||
| 386 | }; | ||
| 387 | 41 | template <typename IO> void Fields(IO& io, MooreSpec& spec) { | |
| 388 | 41 | io("terrain", spec.terrain, "Terrain type whose crater distribution of Moore's to use."); | |
| 389 | 41 | } | |
| 390 | |||
| 391 | template <> struct SpecName<ViperSpec> { | ||
| 392 | static constexpr std::string_view kName = "viper"; | ||
| 393 | static constexpr std::string_view kDescription = | ||
| 394 | "The VIPER environmental specification crater density, as synthterrain uses it; kept for " | ||
| 395 | "comparison with synthterrain."; | ||
| 396 | }; | ||
| 397 | template <typename IO> void Fields(IO& /*io*/, ViperSpec& /*spec*/) {} | ||
| 398 | |||
| 399 | template <> struct SpecName<FreshAgesSpec> { | ||
| 400 | static constexpr std::string_view kName = "fresh"; | ||
| 401 | static constexpr std::string_view kDescription = | ||
| 402 | "Every crater is fresh, with age and lifetime zero."; | ||
| 403 | }; | ||
| 404 | template <typename IO> void Fields(IO& /*io*/, FreshAgesSpec& /*spec*/) {} | ||
| 405 | |||
| 406 | template <> struct SpecName<UniformAgesSpec> { | ||
| 407 | static constexpr std::string_view kName = "uniform"; | ||
| 408 | static constexpr std::string_view kDescription = | ||
| 409 | "Ages uniform over one lifetime for every diameter, so freshness is uniform between 0 " | ||
| 410 | "and 1."; | ||
| 411 | }; | ||
| 412 | 58 | template <typename IO> void Fields(IO& io, UniformAgesSpec& spec) { | |
| 413 | 58 | io("lifetime_gyr", spec.lifetimeGyr, | |
| 414 | "Lifetime in Gyr that every crater's age is drawn uniformly within; with " | ||
| 415 | "degradation, a crater this old is fully worn.", | ||
| 416 | 58 | "Gyr", Above(0.0)); | |
| 417 | 57 | } | |
| 418 | |||
| 419 | template <> struct SpecName<SteadyStateAgesSpec> { | ||
| 420 | static constexpr std::string_view kName = "steady_state"; | ||
| 421 | static constexpr std::string_view kDescription = | ||
| 422 | "Crater ages where small craters are in equilibrium: a crater lasts until the production " | ||
| 423 | "rate replaces the equilibrium density, or the surface's age, with ages drawn from the " | ||
| 424 | "chronology's formation rate."; | ||
| 425 | }; | ||
| 426 | 531 | template <typename IO> void Fields(IO& io, SteadyStateAgesSpec& spec) { | |
| 427 | 531 | io("age_gyr", spec.ageGyr, | |
| 428 | "Age of the surface in Gyr; it caps every crater's lifetime, so larger " | ||
| 429 | "craters on an older surface can be older.", | ||
| 430 | 531 | "Gyr", Between(0.0, 4.6)); | |
| 431 | 530 | io("production", spec.production, | |
| 432 | "Production function whose rate, with the equilibrium, sets how long small craters last."); | ||
| 433 | 530 | io("equilibrium", spec.equilibrium, | |
| 434 | "Equilibrium density that, with the production rate, sets how long small craters last " | ||
| 435 | "before they are erased."); | ||
| 436 | 530 | io("chronology", spec.chronology, | |
| 437 | "Chronology whose formation rate the craters' ages are drawn from."); | ||
| 438 | 529 | } | |
| 439 | |||
| 440 | template <> struct SpecName<FreshnessAgesSpec> { | ||
| 441 | static constexpr std::string_view kName = "freshness"; | ||
| 442 | static constexpr std::string_view kDescription = | ||
| 443 | "Ages from a freshness f between 0 and 1 drawn per crater, age = (1 - f) lifetime, with " | ||
| 444 | "one lifetime for every diameter; freshness stands for age as in degree-of-freshness " | ||
| 445 | "dating (Pohn and Offield 1970; Trang et al. 2015)."; | ||
| 446 | }; | ||
| 447 | 72 | template <typename IO> void Fields(IO& io, FreshnessAgesSpec& spec) { | |
| 448 | 72 | io("lifetime_gyr", spec.lifetimeGyr, | |
| 449 | "Lifetime in Gyr of every crater: freshness 0 is this old, 1 is new; crater " | ||
| 450 | "albedo such as ray fading reads these ages.", | ||
| 451 | 72 | "Gyr", Above(0.0)); | |
| 452 | 71 | io("freshness", spec.freshness, | |
| 453 | "Distribution each crater's freshness is drawn from, also clamped to 0 to 1: 1 is fresh, " | ||
| 454 | "0 at the end of its lifetime; with freshness degradation, depth and rim scale with it."); | ||
| 455 | 70 | } | |
| 456 | |||
| 457 | template <> struct SpecName<FreshnessDegradationSpec> { | ||
| 458 | static constexpr std::string_view kName = "freshness"; | ||
| 459 | static constexpr std::string_view kDescription = | ||
| 460 | "Scales depth and rim height linearly with freshness, down to a cutoff depth ratio at the " | ||
| 461 | "end of a crater's lifetime."; | ||
| 462 | }; | ||
| 463 | 331 | template <typename IO> void Fields(IO& io, FreshnessDegradationSpec& spec) { | |
| 464 | 331 | io("cutoff_depth_ratio", spec.cutoffDepthRatio, | |
| 465 | "Depth over diameter of a crater at the end of its lifetime; lower values " | ||
| 466 | "let old craters wear shallower.", | ||
| 467 | 331 | "", Inside(0.0, 0.1)); | |
| 468 | 330 | } | |
| 469 | |||
| 470 | template <> struct SpecName<NoDegradationSpec> { | ||
| 471 | static constexpr std::string_view kName = "none"; | ||
| 472 | static constexpr std::string_view kDescription = | ||
| 473 | "Craters stay fresh, optionally all with one depth to diameter ratio."; | ||
| 474 | }; | ||
| 475 | 61 | template <typename IO> void Fields(IO& io, NoDegradationSpec& spec) { | |
| 476 | 61 | io("depth_ratio", spec.depthRatio, | |
| 477 | "Depth over diameter given to every crater; unset keeps each crater's fresh " | ||
| 478 | "depth for the body.", | ||
| 479 | 61 | "", Above(0.0)); | |
| 480 | 61 | } | |
| 481 | |||
| 482 | template <> struct SpecName<DiffusionDegradationSpec> { | ||
| 483 | static constexpr std::string_view kName = "diffusion"; | ||
| 484 | static constexpr std::string_view kDescription = | ||
| 485 | "Wears craters down by topographic diffusion, from each crater's diameter and age."; | ||
| 486 | }; | ||
| 487 | 392 | template <typename IO> void Fields(IO& io, DiffusionDegradationSpec& spec) { | |
| 488 | 392 | io("diffusivity", spec.diffusivity, | |
| 489 | "Model of the diffusion age each crater has from its diameter and age. The named fits are " | ||
| 490 | "lunar; matched follows any steady-state ages, such as Martian ones from Ivanov's " | ||
| 491 | "production function."); | ||
| 492 | 391 | io("power_law", spec.powerLaw, "The diffusivity used when the diffusivity model is power_law."); | |
| 493 | 390 | io("reach_radii", spec.reachRadii, | |
| 494 | "Distance from the center, in crater radii, out to which the diffused profile is solved " | ||
| 495 | "and held at 0; at least the fresh profile's reach."); | ||
| 496 | 390 | } | |
| 497 | |||
| 498 | template <> struct SpecName<FassettThomsonSpec> { | ||
| 499 | static constexpr std::string_view kName = "fassett_thomson"; | ||
| 500 | static constexpr std::string_view kDescription = | ||
| 501 | "Fresh simple-crater profile of Fassett and Thomson (2014), with synthterrain's variants."; | ||
| 502 | }; | ||
| 503 | 97 | template <typename IO> void Fields(IO& io, FassettThomsonSpec& spec) { | |
| 504 | 97 | io("rim", spec.rim, "How the profile's interior and exterior fits are joined at the rim."); | |
| 505 | 97 | } | |
| 506 | |||
| 507 | template <> struct SpecName<MartinParkesDunstanSpec> { | ||
| 508 | static constexpr std::string_view kName = "martin_parkes_dunstan"; | ||
| 509 | static constexpr std::string_view kDescription = | ||
| 510 | "Simple-crater profile of Martin, Parkes and Dunstan (2014), developed for the PANGU " | ||
| 511 | "simulator; degradation rounds its rim."; | ||
| 512 | }; | ||
| 513 | template <typename IO> void Fields(IO& /*io*/, MartinParkesDunstanSpec& /*spec*/) {} | ||
| 514 | |||
| 515 | template <> struct SpecName<ComplexProfileSpec> { | ||
| 516 | static constexpr std::string_view kName = "complex"; | ||
| 517 | static constexpr std::string_view kDescription = | ||
| 518 | "A simple profile below the body's simple-to-complex transition, and complex craters " | ||
| 519 | "with flat floors and central peaks above it."; | ||
| 520 | }; | ||
| 521 | 60 | template <typename IO> void Fields(IO& io, ComplexProfileSpec& spec) { | |
| 522 | 60 | io("simple", spec.simple, | |
| 523 | "Profile of the simple craters, those below the body's simple-to-complex transition " | ||
| 524 | "diameter."); | ||
| 525 | 60 | } | |
| 526 | |||
| 527 | 53 | template <typename IO> void Fields(IO& io, InheritedCratersSpec& spec) { | |
| 528 | 55 | io("path", spec.path, | |
| 529 | 53 | config::InputPathHelp( | |
| 530 | "Crater list of the coarser level, CSV or JSON as a crater_list output writes it " | ||
| 531 | "(with attributes for the realized depths and rims), or a catalog of the craters a DEM " | ||
| 532 | "holds"), | ||
| 533 | 53 | "", Required()); | |
| 534 | 53 | Fields(io, spec.inherited); | |
| 535 | 53 | } | |
| 536 | |||
| 537 | template <> struct SpecName<CraterLayerSpec> { | ||
| 538 | static constexpr std::string_view kName = "craters"; | ||
| 539 | static constexpr std::string_view kDescription = | ||
| 540 | "Impact craters generated from a density and age model, or placed by hand, and cut into " | ||
| 541 | "the terrain."; | ||
| 542 | }; | ||
| 543 | /// The fields of which craters a crater layer generates: its seed, density, ages and range. | ||
| 544 | 802 | template <typename IO> void CraterDrawFields(IO& io, CraterLayerSpec& craters) { | |
| 545 | 802 | io("generate_random", craters.options.generateRandom, | |
| 546 | "Draws random craters from the size distribution; off places only the manual craters."); | ||
| 547 | 802 | io("seed", craters.options.seed, | |
| 548 | "Seed the craters are generated with; changing it gives a different crater field of the " | ||
| 549 | "same statistics."); | ||
| 550 | 802 | io("density", craters.density, | |
| 551 | "Size-frequency distribution of the generated craters: how many of each diameter per unit " | ||
| 552 | "area."); | ||
| 553 | 792 | io("ages", craters.ages, | |
| 554 | "How generated craters are given ages, which the degradation model wears them down by; " | ||
| 555 | "unset gives steady-state ages on the density's production surface and equilibrium."); | ||
| 556 | 777 | CraterRangeFields(io, craters.options.generation); | |
| 557 | 779 | } | |
| 558 | |||
| 559 | /// The fields of how a crater layer's craters are shaped and cut into the terrain. | ||
| 560 | 765 | template <typename IO> void CraterShapeFields(IO& io, CraterLayerSpec& craters) { | |
| 561 | 765 | io("profile", craters.profile, | |
| 562 | "Shape of a fresh crater's cross-section, scaled to each crater's diameter."); | ||
| 563 | 764 | io("degradation", craters.degradation, | |
| 564 | "How craters wear down from their fresh shape with age."); | ||
| 565 | 761 | io("apply", craters.options.apply, | |
| 566 | "How craters are cut into the terrain: their order, datum, blending, fading and irregular " | ||
| 567 | "outlines."); | ||
| 568 | 755 | } | |
| 569 | |||
| 570 | /// The fields of the maps, catalogs and source a crater layer reads. | ||
| 571 | 763 | template <typename IO> void CraterInputFields(IO& io, CraterLayerSpec& craters) { | |
| 572 | 763 | io("density_map", craters.densityMap, | |
| 573 | "Map that sets the crater density point by point, scaling the density's size distribution " | ||
| 574 | "to what it measures; unset keeps the density the same everywhere."); | ||
| 575 | 763 | io("completeness", craters.completeness, | |
| 576 | "Where the manual craters are a complete catalog: the diameter in meters from which they " | ||
| 577 | "stand in for generated craters, infinite or no value where there is no catalog. Unset " | ||
| 578 | "keeps every generated crater."); | ||
| 579 | 763 | SourceResolvesField(io, craters.options.sourceResolvesPixels, | |
| 580 | "craters (the smaller of this and completeness when both are set)", | ||
| 581 | "diameter"); | ||
| 582 | 757 | io("replace_inherited_craters", craters.replaceInheritedCraters, | |
| 583 | "Craters of a coarser level, such as a coarser run whose heights are the source, stamped " | ||
| 584 | "again sharp with their IDs, ages, depths and rims where the source's upsampling softened " | ||
| 585 | "them; null for none."); | ||
| 586 | 757 | } | |
| 587 | |||
| 588 | 803 | template <typename IO> void Fields(IO& io, CraterLayerSpec& craters) { | |
| 589 | 803 | io("morphometry", craters.morphometry, | |
| 590 | "Published fits of fresh crater depth, rim height and complex crater shape the craters " | ||
| 591 | "are shaped with."); | ||
| 592 | 802 | CraterDrawFields(io, craters); | |
| 593 | 779 | io("manual", craters.manual, | |
| 594 | "Craters placed by hand in the surface's coordinates, added to any generated ones."); | ||
| 595 | 765 | CraterShapeFields(io, craters); | |
| 596 | 763 | CraterInputFields(io, craters); | |
| 597 | 757 | } | |
| 598 | |||
| 599 | template <> struct SpecName<SecondaryLayerSpec> { | ||
| 600 | static constexpr std::string_view kName = "secondaries"; | ||
| 601 | static constexpr std::string_view kDescription = | ||
| 602 | "Secondary craters around the craters of the last crater layer before this one, after " | ||
| 603 | "Singer et al. (2020)."; | ||
| 604 | }; | ||
| 605 | 66 | template <typename IO> void Fields(IO& io, SecondaryLayerSpec& spec) { | |
| 606 | 66 | Fields(io, spec.secondaries); | |
| 607 | 61 | io("depth_ratio", spec.depthRatio, | |
| 608 | "Depth over diameter every secondary is given, with no wear by age; lower values give " | ||
| 609 | "shallower secondaries.", | ||
| 610 | 61 | "", Above(0.0)); | |
| 611 | 60 | io("morphometry", spec.morphometry, | |
| 612 | "Published fits whose fresh crater rim the secondaries are shaped with."); | ||
| 613 | 60 | } | |
| 614 | |||
| 615 | /// The density, ages, profile and degradation models a crater layer selects. | ||
| 616 | /// @param path The layer's JSON path, which errors are reported under. | ||
| 617 | /// @throws ConfigError at `path`.density, .ages, .profile or .degradation for a model whose | ||
| 618 | /// constructor rejects its parameters. | ||
| 619 | CraterModels BuildCraterModels(const CraterLayerSpec& craters, const std::string& path = {}); | ||
| 620 | |||
| 621 | namespace config { | ||
| 622 | |||
| 623 | /// The crater production function a configuration names. | ||
| 624 | std::shared_ptr<const SizeFrequencyDistribution> BuildProduction(ProductionFunction production); | ||
| 625 | |||
| 626 | /// The size-frequency distribution a density spec describes. | ||
| 627 | std::shared_ptr<const SizeFrequencyDistribution> BuildDensity(const DensitySpec& spec); | ||
| 628 | |||
| 629 | /// The fresh crater fits `fit` names. | ||
| 630 | FreshMorphometry BuildMorphometry(CraterMorphometryFit fit); | ||
| 631 | |||
| 632 | /// Steady-state ages on the production surface and equilibrium `density` is the minimum of; none | ||
| 633 | /// for another density. | ||
| 634 | std::optional<SteadyStateAgesSpec> MatchingAges(const DensitySpec& density); | ||
| 635 | |||
| 636 | /// The ages a crater layer gives its craters: its `ages`, or when unset `MatchingAges` of its | ||
| 637 | /// density, else `SteadyStateAgesSpec`'s. | ||
| 638 | AgesSpec LayerAges(const CraterLayerSpec& craters); | ||
| 639 | |||
| 640 | /// @name Crater layers | ||
| 641 | /// Checks a crater or secondary layer spec before building, builds it, and checks the crater | ||
| 642 | /// layer built: its manual shapes and the craters expected over each output. | ||
| 643 | /// @throws ConfigError under `path` for what the checks or the layer reject. | ||
| 644 | /// @{ | ||
| 645 | void CheckSpec(const CraterLayerSpec& spec, const std::string& path, LayerChecks& checks); | ||
| 646 | void CheckSpec(const SecondaryLayerSpec& spec, const std::string& path, LayerChecks& checks); | ||
| 647 | LayerPtr BuildSpec(const CraterLayerSpec& spec, const std::string& path, const LayerInputs& inputs); | ||
| 648 | LayerPtr BuildSpec(const SecondaryLayerSpec& spec, const std::string& path, | ||
| 649 | const LayerInputs& inputs); | ||
| 650 | void CheckBuilt(const CraterLayerSpec& spec, const Layer& built, const std::string& path, | ||
| 651 | LayerChecks& checks); | ||
| 652 | /// @} | ||
| 653 | |||
| 654 | } // namespace config | ||
| 655 | |||
| 656 | } // namespace terraingen | ||
| 657 |