File size: 12,328 Bytes
f1d3656 ab98816 f1d3656 9491227 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | ---
license: other
language:
- en
- zh
tags:
- OneScience
- Earth Science
- Weather Forecasting
- ERA5
- Representation Learning
frameworks: PyTorch
datasets:
- OneScience/ERA5
---
<p align="center">
<strong><span style="font-size: 30px;">AtmoRep</span></strong>
</p>
# Model Overview
AtmoRep is a stochastic atmospheric dynamics model based on large-scale representation learning that captures the distribution of atmospheric states through masked-token training and ensemble outputs.
Paper: *AtmoRep: A stochastic model of atmosphere dynamics using large scale representation learning*
https://arxiv.org/abs/2308.13280
# Model Description
This directory retains the official vorticity single-field model weights, configuration, and normalization, and provides a tiny AtmoRep-style model for local training and inference verification.
# Use Cases
| Scenario | Description |
| :---: | :--- |
| Official Resource Validation | Load official `.mod` weights and verify configuration. |
| Local Rapid Verification | Run masked-token training and inference with the tiny model. |
| ERA5 Atmospheric Representation Learning | Subsequently interface with official GRIB or Zarr data. |
# Usage
## 1. OneCode
[Click to experience intelligent one-click AI4S programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
## 2. Manual Installation & Usage
**Hardware Requirements**
- The tiny model runs on CPU.
- GPU is recommended for the official model and real-data inference.
### Download the Model Package
```bash
hf download OneScience-Group/AtmoRep --local-dir ./AtmoRep
cd AtmoRep
```
### Set Up the Runtime Environment
**DCU Environment**
```bash
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```
**GPU Environment**
```bash
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```
If dependencies are missing from the official paths, install them with:
```bash
pip install zarr wandb cfgrib xarray dask netCDF4 torchinfo
```
### Weights & Data
The current directory preserves:
```text
resources/id4nvwbetz/AtmoRep_id4nvwbetz.mod
resources/id4nvwbetz/model_id4nvwbetz.json
resources/data/normalization/vorticity/
```
Before re-downloading official resources please note: the current vendor snapshot is not a Git checkout, and the existing download script cannot re-clone into a non-empty `vendor/atmorep-official`. The resources bundled with this package do not require re-downloading; the script is only suitable for an empty target directory.
```bash
bash scripts/download_official_resources.sh .
```
### Tiny Training
```bash
python scripts/train.py
```
This command performs multi-epoch masked-token training using independent train/validation fake Datasets, including DataLoader, AdamW, validation, learning rate scheduling, early stopping, best/latest checkpointing, and training history. Default parameters reside in `conf/config.yaml`.
Resuming training:
```bash
python scripts/train.py --resume weight/training/latest.pth --epochs 20
```
Training artifacts are `weight/training/latest.pth`, `best.pth`, and `history.json`; the inference-compatible weights `weight/tiny_atmorep.pth` are also updated. Each Dataset sample consists of `fields [T,V,H,W]` and a non-empty `mask [N]`; train/validation use different seeds. This is a complete training pipeline for the tiny model, not a reproduction of the paper's 3.5-billion-parameter official model training.
### Tiny Inference
```bash
python scripts/inference.py
```
Inference results are saved as:
```text
result/prediction.pt
result/target.pt
```
These include the ensemble, ensemble mean, ensemble std, and mask.
### Result Inspection
```bash
python scripts/result.py
```
This command generates `result/metrics.json` and `result/comparison.png`. The reported metrics are ensemble/mean/spread RMSE in normalized token space, not the paper's physical-unit RMSE, ACC, CRPS, or spread-skill.
### Paper vs. Current Implementation I/O
| Item | Paper / Official Model | Tiny Smoke Model |
| --- | --- | --- |
| Input | ERA5 local 4D neighborhoods, 5 mode levels, multiple physical fields | `[B,4,1,8,8]` single-field random tensor |
| Token | Variable-correlated 4D tokens with absolute space-time and level conditioning | `1×4×4` patches, 16 tokens, relative coordinates with single-level conditioning |
| Output | Multi-head ensembles supporting reconstruction, nowcasting, and interpolation | 4-member masked-token ensemble |
| Training | Large-scale masked-token distribution learning | Multi-epoch Dataset training with independent validation and checkpoint resumption |
| Weights | `resources/id4nvwbetz` official vorticity weights | `weight/tiny_atmorep.pth`; the two are mutually incompatible |
The complete tiny execution flow is `train.py -> inference.py -> result.py`. The result analysis reads `weight/training/history.json` when present; inference output includes `ensemble`, `ensemble_mean`, `ensemble_std`, `mask`, and `target`. Random data is generated by the Dataset by index; there is currently no independent fake dataset that can be used with the official Zarr sampler. The model package is distributed without local training weights or `result/` artifacts — these are created at the paths described above after running the commands.
### Official Real-Data Inference
A directly runnable official real-data inference command is not yet available. It further requires ERA5 vorticity GRIB/Zarr data, the ecCodes environment, and parameterization of the file paths in the official `evaluate.py`.
### Real Data
The official vorticity model requires ERA5 vorticity, model levels 96/105/114/123/137, hourly temporal axes, and 0.25° global GRIB/Zarr data.
# OneScience Official Information
| Platform | OneScience Main Repository | Skills Repository |
| --- | --- | --- |
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
# Citation & License
- Official code is MIT License.
- Official model weights are declared CC BY 4.0.
- ERA5 is subject to Copernicus/ECMWF data terms.
---
# 中文说明
## 模型概览
AtmoRep 是一种基于大规模表征学习的随机大气动力学模型,通过掩码 token 训练和集合输出来捕获大气状态分布。
论文:*AtmoRep:基于大规模表征学习的随机大气动力学模型*
https://arxiv.org/abs/2308.13280
## 模型描述
本目录保留官方涡度单场模型权重、配置和归一化统计量,并提供一个 AtmoRep 风格的小型模型,用于验证本地训练和推理(inference)。
## 使用场景
| 场景 | 说明 |
| :---: | :--- |
| 官方资源验证 | 加载官方 `.mod` 权重并验证配置。 |
| 本地快速验证 | 使用小型模型运行掩码 token 训练和推理。 |
| ERA5 大气表征学习 | 后续与官方 GRIB 或 Zarr 数据对接。 |
## 使用指南
### 1. OneCode
[点击体验智能一键 AI4S 编程](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
### 2. 手动安装与使用
**硬件要求**
- 小型模型可在 CPU 上运行。
- 运行官方模型或进行真实数据推理时,建议使用 GPU。
#### 下载模型包
```bash
hf download OneScience-Group/AtmoRep --local-dir ./AtmoRep
cd AtmoRep
```
#### 配置运行环境
**DCU 环境**
```bash
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```
**GPU 环境**
```bash
conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=12
conda activate onescience311
pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
```
如果官方路径缺少依赖,可使用以下命令安装。
```bash
pip install zarr wandb cfgrib xarray dask netCDF4 torchinfo
```
#### 权重与数据
当前目录保留以下内容。
```text
resources/id4nvwbetz/AtmoRep_id4nvwbetz.mod
resources/id4nvwbetz/model_id4nvwbetz.json
resources/data/normalization/vorticity/
```
重新下载官方资源前请注意,当前随包提供的快照未通过 Git 检出,现有下载脚本无法重新克隆到非空的 `vendor/atmorep-official` 目录。本包附带的资源无需重新下载。该脚本仅适用于空目标目录。
```bash
bash scripts/download_official_resources.sh .
```
#### 小型模型训练
```bash
python scripts/train.py
```
此命令使用独立的训练和验证合成 Dataset,进行多轮掩码 token 训练,包括 DataLoader、AdamW、验证、学习率调度、早停、最佳及最新模型权重(检查点)(checkpoint)保存和训练历史记录。默认参数位于 `conf/config.yaml`。
恢复训练
```bash
python scripts/train.py --resume weight/training/latest.pth --epochs 20
```
训练产物为 `weight/training/latest.pth`、`best.pth` 和 `history.json`,同时也会更新可用于推理的权重 `weight/tiny_atmorep.pth`。每个 Dataset 样本由 `fields [T,V,H,W]` 和非空的 `mask [N]` 组成,训练和验证使用不同随机种子。这是小型模型的完整训练流程,未复现论文中 3.5-billion-parameter 官方模型的训练。
#### 小型模型推理
```bash
python scripts/inference.py
```
推理结果保存到以下位置。
```text
result/prediction.pt
result/target.pt
```
这些结果包括集合、集合均值、集合标准差和掩码。
#### 结果检查
```bash
python scripts/result.py
```
此命令生成 `result/metrics.json` 和 `result/comparison.png`。报告的指标为归一化 token 空间中的集合、集合均值及离散度 RMSE,区别于论文中使用物理单位的 RMSE、ACC、CRPS 或离散度与预报技巧指标。
#### 论文与当前实现的输入输出对比
| 项目 | 论文 / 官方模型 | 小型冒烟测试模型 |
| --- | --- | --- |
| 输入 | ERA5 局部 4D 邻域、5 个模态层级、多个物理场 | `[B,4,1,8,8]` 单场随机张量 |
| Token | 变量相关的 4D token,以绝对时空位置和层级为条件 | `1×4×4` 分块、16 个 token、以单层级为条件的相对坐标 |
| 输出 | 支持重建、临近预报(nowcasting)和插值的多头集合 | 4 个成员的掩码 token 集合 |
| 训练 | 大规模掩码 token 分布学习 | 多轮 Dataset 训练,支持独立验证并从模型权重(检查点)恢复训练 |
| 权重 | `resources/id4nvwbetz` 官方涡度权重 | `weight/tiny_atmorep.pth`,二者互不兼容 |
小型模型的完整运行流程为 `train.py -> inference.py -> result.py`。结果分析会在 `weight/training/history.json` 存在时读取该文件。推理输出包括 `ensemble`、`ensemble_mean`、`ensemble_std`、`mask` 和 `target`。随机数据由 Dataset 按索引生成,目前没有可与官方 Zarr 采样器配合使用的独立合成数据集。模型包发布时未附带本地训练权重或 `result/` 产物,运行命令后会在上述路径生成。
#### 官方真实数据推理
目前尚无可直接运行的官方真实数据推理命令。该流程还需要 ERA5 涡度 GRIB/Zarr 数据和 ecCodes 环境,并需对官方 `evaluate.py` 中的文件路径进行参数化(parameterization)。
#### 真实数据
官方涡度模型需要 ERA5 涡度、模式层 96/105/114/123/137、逐小时时间轴以及 0.25° 全球 GRIB/Zarr 数据。
## OneScience 官方信息
| 平台 | OneScience 主仓库 | Skills 仓库 |
| --- | --- | --- |
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
## 引用与许可证
- 官方代码采用 MIT 许可证。
- 官方模型权重声明采用 CC BY 4.0 许可。
- ERA5 受 Copernicus/ECMWF 数据条款约束。
|