credit.ensemble.temporal#
Classes#
AR(1) temporal noise generator that leverages spatial noise patterns. |
Module Contents#
- class credit.ensemble.temporal.TemporalNoise(noise_generator: torch.Tensor, temporal_correlation: float = 0.9, perturbation_std: float | torch.Tensor | None = None, hemispheric_rescale: bool | None = False, terrain_file: str = None)#
AR(1) temporal noise generator that leverages spatial noise patterns.
Implements an autoregressive process of order 1 for temporal correlation: δ_t = ρ * δ_{t-1} + ε_t
where ρ is the temporal correlation coefficient and ε_t is generated using a Noise instance (allowing for spatially correlated innovations).
This creates perturbations that evolve smoothly over forecast steps while maintaining realistic spatial patterns at each time step.
- Parameters:
noise_generator (Noise) – Noise generator instance used to create the white noise innovations (ε_t)
temporal_correlation (float, optional) – Temporal correlation coefficient (0-1). Higher values create smoother temporal evolution, by default 0.9
perturbation_std (Union[float, torch.Tensor], optional) – Noise standard deviation scaling. Can be either: - float: uniform scaling applied to all channels - torch.Tensor: per-channel scaling with shape matching channel dimension If provided, overrides the amplitude from the noise_generator, by default None
- noise_generator#
- temporal_correlation = 0.9#
- perturbation_std = None#
- hemispheric_rescale#
- __call__(x: torch.Tensor, previous_perturbation: torch.Tensor | None = None, forecast_step: int = 1) tuple[torch.Tensor, torch.Tensor]#
Apply temporally correlated perturbation for sequential forecasting.
- Parameters:
x (torch.Tensor) – Input state tensor to perturb
previous_perturbation (torch.Tensor, optional) – Perturbation from the previous forecast step, by default None. If None or forecast_step=1, generates new initial perturbation.
forecast_step (int, optional) – Current forecast step (1-indexed), by default 1
- Returns:
Perturbed state tensor (x + perturbation)
Current perturbation tensor (for use in next step)
- Return type:
tuple[torch.Tensor, torch.Tensor]