RF-ClimParam / README.md
zhangrenchao's picture
Upload folder using huggingface_hub
c059069 verified
|
Raw
History Blame Contribute Delete
6.72 kB
---
license: apache-2.0
language:
- en
tags:
- OneScience
- Earth Science
- Climate Parameterization
- Random Forest
frameworks: PyTorch
---
<p align="center">
<strong><span style="font-size: 30px;">RF-ClimParam</span></strong>
</p>
# Model Introduction
RF-ClimParam learns unresolved convection, cloud microphysics, radiation, turbulent diffusion, and surface-flux processes from high-resolution atmospheric simulations and provides stable subgrid parameterizations for coarse climate models at multiple horizontal resolutions. Its primary uses are multi-resolution climate simulation, analysis of parameterization scale dependence, and reconstruction of precipitation climate statistics.
Paper: Stable machine-learning parameterization of subgrid processes for climate modeling at a range of resolutions
https://arxiv.org/abs/2001.03151
# Model Description
The method reproduced by RF-ClimParam was proposed by Janni Yuval and Paul A. O'Gorman at the Massachusetts Institute of Technology. The paper trains random forests with coarse-grained states, instantaneous physical tendencies, turbulent diffusivity, and surface fluxes from a three-dimensional high-resolution System for Atmospheric Modeling aquaplanet simulation. The model is suitable for multi-resolution atmospheric subgrid parameterization, coarse-resolution climate simulation, and evaluation of mean and extreme precipitation statistics.
# Use Cases
| Use Case | Description |
| :---: | :--- |
| Multi-resolution parameterization | Predict column tendencies and diffusion quantities separately at x4/x8/x16/x32. |
| Joint multi-output regression | Preserve cross-variable and cross-level output means in one tree leaf without splitting outputs. |
| Offline engineering evaluation | Compute per-scale, per-output R2 and RMSE over all four complete coarse-grid fields. |
| Online-coupling proxy | Evaluate zonal-mean 3 h precipitation and extremes on an additional native x32 `18×48` coarse grid. |
| ModelScope/OneCode execution | Validate data generation, training, inference, evaluation, visualization, and checkpoint workflows in ModelScope or OneCode. |
| Multi-GPU training | Launch distributed data-parallel training with `torchrun`. |
# Usage Instructions
## 1.OneCode
Experience intelligent, one-click AI4S programming through the OneCode online environment:
[Try intelligent, one-click AI4S programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
## 2. Download and Installation
```bash
hf download OneScience-Group/RF-ClimParam --local-dir ./RF-ClimParam
cd RF-ClimParam
```
### Environment Dependencies
**Hardware Requirements**
- A GPU or DCU is recommended; the random forest itself runs on CPU with NumPy.
- A CPU supports the complete default small-sample connectivity test.
- DCU users must install DTK first. DTK 25.04.2 or later, or the OneScience-recommended version matching the cluster, is recommended.
**DCU Environment**
```bash
# 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**
```bash
# 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
```
### Training Data
```bash
python scripts/fake_data.py
```
This repository uses a small number of structured synthetic atmospheric-column samples to validate the engineering workflow and retains complete `144×360`, `72×180`, `36×90`, and `18×45` coarse-grid snapshots for x4, x8, x16, and x32. The data preserve all 48 levels and the real `145→144` and `62→17` random-forest interfaces while reducing only the number of snapshots, sampled training columns, and trees. Synthetic temperature, moisture, condensate, wind, and flux fields contain spatial and vertical relationships and validate multi-resolution parameterization, training, inference, and evaluation only; they do not represent the official SAM distribution or paper performance.
### Training
For single-device training, use:
```bash
python scripts/train.py
```
For multi-GPU training, use:
```bash
torchrun --nproc_per_node=8 --nnodes=1 --rdzv_id=1000 --rdzv_backend=c10d --max_restarts=0 --master_addr="localhost" --master_port=29500 scripts/train.py
```
Training samples a small number of atmospheric columns from the complete spatial field at each resolution and fits the two joint multi-output random forests separately. It produces model parameters and training-sample statistics for all four resolutions, saved to:
```text
result/checkpoints/rf_climparam.pt
result/training/metrics.json
```
### Trained Weights
This repository does not include weights under `weight/`. The original paper provides random-forest estimators at different resolutions; refer to the authors' OSF archive for the released weights and model artifacts: https://doi.org/10.17605/OSF.IO/36YPT.
### Inference
```bash
python scripts/inference.py
```
Inference results include reference targets and subgrid-process predictions at the x4, x8, x16, and x32 resolutions. They also contain complete spatial fields, diagnosed precipitation, grid-location information for each scale, and native x32-grid results. All numerical results are saved to `result/output/predictions.npz`.
### Evaluation and Visualization
```bash
python scripts/result.py
```
Evaluation results include subgrid-process prediction performance at all four resolutions and an online proxy for coarse-grid precipitation. The visualization compares results across resolutions and shows the zonal distributions of target and predicted precipitation. Structured results and the auxiliary figure are saved to `result/evaluation/metrics.json` and `result/evaluation/comparison.png`. Synthetic-data results validate the engineering workflow only and do not represent the paper's formal SAM online performance.
# Official OneScience 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 and License
This repository is an independent engineering reproduction of the public RF-ClimParam specifications.
Use of this repository's code, official model weights, and data remains subject to the licenses and terms of their respective projects.