Views
No views yet
ClimateSpatiotemporalNet combines geometric spatial modeling with multi-horizon sequence attention:| Target / Hazard Metric | Horizon / Metric | Model Value | Baseline Skill |
|---|---|---|---|
| TMAX (Max Temperature) | 1-Day MAE | 2.397 °C | +28.4% vs Persistence |
| TMAX (Max Temperature) | 7-Day MAE | 2.734 °C | +21.2% vs Persistence |
| TMAX (Max Temperature) | Overall 14-Day MAE | 2.694 °C | +18.6% vs Persistence |
| TMAX Interval Coverage | 80% CI (P10 - P90) | 80.2% | Calibrated (Nominal: 80%) |
| TMIN (Min Temperature) | Overall 14-Day MAE | 2.475 °C | +19.4% vs Persistence |
| Heatwave Alert (EHF) | F1-Score | 0.4099 | ROC-AUC: 0.7701 |
| Frost / Freeze Alert | F1-Score | 0.8539 | ROC-AUC: 0.9638 |
| Deluge Hazard Alert | F1-Score | 0.626 | ROC-AUC: 0.8689 |
pip install torch safetensors numpy pandas pyarrow1import torch
2from safetensors.torch import load_file
3from climate_forecast.models.spatiotemporal_net import ClimateSpatiotemporalNet
4from climate_forecast.config import ModelConfig
5
6# 1. Initialize architecture and load weights
7config = ModelConfig()
8model = ClimateSpatiotemporalNet(config)
9state_dict = load_file("model.safetensors")
10model.load_state_dict(state_dict)
11model.eval()
12
13# 2. Prepare sample input tensors
14# x_seq: [Batch, 30 days, 7 features] -> [tmax, tmin, prcp, sin_doy, cos_doy, tmax_anom, tmin_anom]
15# x_spatial: [Batch, 3] -> [lat / 90.0, lon / 180.0, normalized_elevation]
16# x_future_time: [Batch, 14 days, 2] -> [sin_doy, cos_doy]
17x_seq = torch.randn(1, 30, 7)
18x_spatial = torch.tensor([[40.7128 / 90.0, -74.0060 / 180.0, 0.1]])
19x_future_time = torch.randn(1, 14, 2)
20
21# 3. Predict 14-day probabilistic forecast and extreme hazard alerts
22with torch.no_grad():
23 outputs = model(x_seq, x_spatial, x_future_time)
24 # quantiles: [1, 14, 3 targets (TMAX, TMIN, PRCP), 3 quantiles (P10, P50, P90)]
25 quantiles = outputs["quantiles"]
26 # hazard_probs: [1, 14, 3 hazards (Heatwave, Frost, Deluge)]
27 hazard_probs = outputs["hazard_probs"]
28
29print("14-Day TMAX P50:", quantiles[0, :, 0, 1].numpy())
30print("14-Day Heatwave Probability:", hazard_probs[0, :, 0].numpy())1@article{menne2012ghcnd,
2 title={An overview of the Global Historical Climatology Network-Daily Database},
3 author={Menne, Matthew J and Durre, Imke and Vose, Russell S and Gleason, Byron E and Houston, Tamara G},
4 journal={Journal of Atmospheric and Oceanic Technology},
5 volume={29},
6 number={7},
7 pages={897--910},
8 year={2012}
9}