src/analysis/radial_spectrum.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | |||
| 3 | /// @file | ||
| 4 | /// @brief `RadialPowerSpectrum`, the radially averaged power spectrum of a raster's heights. | ||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "terraingen/raster/raster.h" | ||
| 8 | |||
| 9 | #include <cstddef> | ||
| 10 | #include <vector> | ||
| 11 | |||
| 12 | namespace terraingen { | ||
| 13 | |||
| 14 | /// One annulus of a radially averaged power spectrum. | ||
| 15 | 644 | struct SpectrumBin { | |
| 16 | double frequency = 0.0; ///< Mean radial frequency of the bin, in cycles per raster unit. | ||
| 17 | double power = 0.0; ///< Mean power spectral density, in height^2 raster units^2. | ||
| 18 | std::size_t count = 0; ///< Frequency samples averaged. | ||
| 19 | }; | ||
| 20 | |||
| 21 | /// The radially averaged power spectral density of `heights` in quarter-octave bins up to the | ||
| 22 | /// Nyquist frequency, finest last, over the centered power-of-2 window detrended and Hann-tapered. | ||
| 23 | /// @throws std::invalid_argument for a rotated raster, a window under 8 cells a side, or one with | ||
| 24 | /// no data. | ||
| 25 | std::vector<SpectrumBin> RadialPowerSpectrum(const Raster<float>& heights); | ||
| 26 | |||
| 27 | } // namespace terraingen | ||
| 28 |