credit.ensemble.color#
Classes#
2D spatially correlated noise generator for lat/lon grids. |
Functions#
|
Red noise perturbation in physical units, with per-channel control. |
Module Contents#
- class credit.ensemble.color.ColorNoise(amplitude: float = 0.05, reddening: int = 2)#
2D spatially correlated noise generator for lat/lon grids.
Generates colored noise with controllable spatial correlation using power-law scaling in the frequency domain. The noise characteristics are determined by the reddening parameter:
reddening = 0: White noise (uncorrelated, flat power spectrum)
reddening = 1: Pink noise (1/f power spectrum)
reddening = 2: Brown/Brownian/Red noise (1/f² power spectrum)
reddening > 2: Higher-order red noise (1/f^n power spectrum)
Higher reddening values produce smoother, more spatially coherent patterns, which are often more realistic for geophysical applications.
- Parameters:
amplitude (float, optional) – Scaling factor for the generated noise. Defaults to 0.05.
reddening (int, optional) – Power-law exponent controlling spatial correlation. Higher values create smoother, more correlated noise patterns. Defaults to 2 (Brown noise).
- amplitude = 0.05#
- reddening = 2#
- __call__(x: torch.Tensor) torch.Tensor#
Generate spatially correlated noise matching input tensor dimensions.
- Parameters:
x (torch.Tensor) – Reference tensor whose shape determines the output noise dimensions. The last two dimensions are treated as the spatial lat/lon grid.
- Returns:
Spatially correlated noise tensor with the same shape as the input, scaled by the amplitude parameter.
- Return type:
torch.Tensor
Generate spatially correlated noise using frequency domain filtering.
Creates colored noise by: 1. Starting with white noise (uniform power spectrum). 2. Transforming to frequency domain. 3. Applying power-law scaling (1/f^reddening). 4. Transforming back to spatial domain.
- Parameters:
shape (tuple[int, ...]) – Shape of the output noise tensor.
device (torch.device) – Device to generate tensors on.
- Returns:
Spatially correlated noise with unit variance (before amplitude scaling).
- Return type:
torch.Tensor
- __repr__() str#
- credit.ensemble.color.apply_noise_perturbation_step(x: torch.Tensor, delta_prev: torch.Tensor | None, forecast_step: int, rho: float = 0.9, perturbation_std: float | torch.Tensor = 0.05) Tuple[torch.Tensor, torch.Tensor]#
Red noise perturbation in physical units, with per-channel control.