WRF-ML

Model Introduction

WRF-ML bridges WRF v4.3 and Python machine-learning parameterizations. This reproduction focuses on the recommended Model D, using a bidirectional LSTM to emulate RRTMG shortwave and longwave outputs.

Paper: WRF–ML v1.0: a bridge between WRF v4.3 and machine learning parameterizations and its application to atmospheric radiative transfer
https://doi.org/10.5194/gmd-16-199-2023

Model Description

The model was proposed by researchers at Alibaba Group's Damo Academy. It was trained with atmospheric-column inputs and RRTMG outputs generated by WRF simulations, with 57 vertical levels per sample. Through layout adaptation and a synchronous request-response protocol, it supports shortwave and longwave flux and heating-rate emulation as an online WRF physical parameterization.

Use Cases

Use Case Description
Radiation emulation Emulate shortwave and longwave fluxes and heating rates.
WRF parameterization Validate atmospheric-column batching and output layout restoration.
Offline evaluation Compute RMSE for six radiation outputs.
Coupling protocol Demonstrate synchronous blocking request, inference, and response.
ModelScope/OneCode execution Validate structured data, training, inference, probabilistic precipitation metrics, and visualization in ModelScope or OneCode.
Multi-GPU training Start multi-process training through torchrun.

Usage Instructions

Download

hf download OneScience-Group/WRF-ML --local-dir ./WRF-ML
cd WRF-ML

Environment Dependencies

Hardware Requirements

  • A GPU or DCU is recommended.
  • A CPU can run the default small-sample connectivity configuration.
  • DCU users should install DTK 25.04.2 or a compatible OneScience-recommended version first.

DCU Environment

# Activate DTK and Conda first
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

# Activate Conda first
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

Synthetic Data

The paper uses a 190x170 horizontal domain, 57 vertical levels, and WRF-RRTMG columns sampled every 30 minutes. Synthetic data preserve 57 levels, WRF layout conversion, and six output semantics while reducing column count, hidden width, and epochs; the ten inputs are explicitly an engineering ledger because the paper does not enumerate all input variables. Results verify the workflow only and do not represent paper performance.

python scripts/fake_data.py

Training

python scripts/train.py
torchrun --nproc_per_node=2 --nnodes=1 --master_addr="localhost" --master_port=29500 scripts/train.py

The default synthetic run jointly optimizes 57-level radiation profiles and boundary fluxes, and both single-process and two-process DDP training have been verified. It produces one recoverable Model-D-style checkpoint and records normalized mean squared error. Training results are saved to:

result/checkpoints/wrf_ml.pt
result/training/metrics.json

Weights

The paper's code and data are archived at https://doi.org/10.5281/zenodo.7407487. This reproduction does not link a pretrained checkpoint because a separately licensed official weight artifact was not confirmed.

Inference

python scripts/inference.py

Inference restores the checkpoint, runs the synchronous layout-adapted coupler, and produces 57-level profiles and boundary fluxes. Profile and boundary output shapes are [6,57,4] and [6,2], respectively, and both have passed finite-value checks. Inference results are saved to:

result/output/predictions.npz

Evaluation

python scripts/result.py

Evaluation reports RMSE for shortwave and longwave fluxes, heating rates, and boundary shortwave fluxes and creates a vertical-profile comparison. All metrics are finite, and the PNG has passed format and non-empty-pixel checks. Evaluation results are saved to:

result/evaluation/metrics.json
result/evaluation/comparison.png

Official OneScience Information

Citation and License

This repository is an independent engineering reproduction of the public WRF-ML specifications, with code licensed under the Apache License 2.0.

The original paper is licensed under CC BY 4.0; the paper, WRF, RRTMG, ONNX Runtime, and related data remain subject to their respective licenses and terms.


中文说明

模型简介

WRF-ML 在 WRF v4.3 和 Python 机器学习参数化(parameterizations)方案之间建立桥接。本次复现侧重于推荐的 Model D,即使用双向 LSTM 模拟 RRTMG 的短波和长波输出。

论文《WRF–ML v1.0:连接 WRF v4.3 与机器学习参数化方案的桥接框架及其在大气辐射传输中的应用》
https://doi.org/10.5194/gmd-16-199-2023

模型描述

该模型由阿里巴巴集团达摩院的研究人员提出。训练使用 WRF 模拟生成的大气柱输入和 RRTMG 输出,每个样本包含 57 个垂直层。该模型通过布局适配和同步请求响应协议,实现作为 WRF 在线物理参数化方案的短波、长波通量及加热率模拟。

使用场景

使用场景 说明
辐射模拟 模拟短波和长波通量及加热率。
WRF 参数化 验证大气柱批处理和输出布局恢复。
离线评估 计算六项辐射输出的 RMSE。
耦合协议 演示同步阻塞式请求、推理(inference)和响应。
在 ModelScope/OneCode 中运行 在 ModelScope 或 OneCode 中验证结构化数据、训练、推理、概率降水指标和可视化。
多 GPU 训练 通过 torchrun 启动多进程训练。

使用说明

下载

hf download OneScience-Group/WRF-ML --local-dir ./WRF-ML
cd WRF-ML

环境依赖

硬件要求

  • 建议使用 GPU 或 DCU。
  • 可在 CPU 上以默认小样本配置运行连通性验证。
  • DCU 用户应先安装 DTK 25.04.2 或 OneScience 推荐的兼容版本。

DCU 环境

# Activate DTK and Conda first
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 环境

# Activate Conda first
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

合成数据

论文使用 190x170 的水平区域、57 个垂直层,以及每 30 分钟采样一次的 WRF-RRTMG 大气柱。合成数据保留 57 层、WRF 布局转换及六项输出的含义,同时减少柱数量、隐藏宽度和训练轮次。论文未列举所有输入变量,因此这十项输入明确作为工程记录。结果仅用于验证流程,无法代表论文性能。

python scripts/fake_data.py

训练

python scripts/train.py
torchrun --nproc_per_node=2 --nnodes=1 --master_addr="localhost" --master_port=29500 scripts/train.py

默认的合成数据运行联合优化 57 层辐射廓线和边界通量,已验证单进程和双进程 DDP 训练。运行生成一份可恢复的 Model D 风格模型权重(检查点)(checkpoint),并记录归一化均方误差。训练结果保存到以下位置。

result/checkpoints/wrf_ml.pt
result/training/metrics.json

权重

论文的代码和数据归档于 https://doi.org/10.5281/zenodo.7407487. 由于未确认有单独授权的官方权重文件,本次复现未提供预训练模型权重(检查点)的链接。

推理

python scripts/inference.py

推理恢复模型权重(检查点),运行经过布局适配的同步耦合器,并生成 57 层廓线和边界通量。廓线和边界输出的形状分别为 [6,57,4] 和 [6,2],均已通过有限值检查。推理结果保存到以下位置。

result/output/predictions.npz

评估

python scripts/result.py

评估报告短波和长波通量、加热率及边界短波通量的 RMSE,并生成垂直廓线对比图。所有指标均为有限值,PNG 已通过格式和非空像素检查。评估结果保存到以下位置。

result/evaluation/metrics.json
result/evaluation/comparison.png

OneScience 官方信息

引用与许可证

本仓库依据公开的 WRF-ML 规范进行了独立工程复现,代码采用 Apache License 2.0 授权。

原论文采用 CC BY 4.0 授权,论文、WRF、RRTMG、ONNX Runtime 及相关数据仍受各自的许可证和条款约束。

Downloads last month
6
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support