OneScience-Group/NNCAM
029
1---2license: apache-2.03language:4- en5tags:6- OneScience7- Earth Science8- Climate Parameterization9- Subgrid Processes10frameworks: PyTorch11---12 13<p align="center">14 <strong><span style="font-size: 30px;">NNCAM</span></strong>15</p>16 17# Model Introduction18 19NNCAM predicts physical tendencies and fluxes produced by cloud, convection, and radiation subgrid processes from atmospheric-column states for data-driven climate-model parameterization research.20 21Paper: Deep learning to represent subgrid processes in climate models 22https://gmd.copernicus.org/articles/11/3999/2018/23 24# Model Description25 26The method was proposed by research teams from Ludwig Maximilian University of Munich, the University of California Irvine, and Columbia University. The paper trains on approximately 140 million atmospheric-column samples from one year of SPCAM aquaplanet simulation. The model predicts 65 heating, moistening, radiative-flux, and precipitation outputs from a 94-dimensional atmospheric-column state.27 28# Use Cases29 30| Use Case | Description |31| :---: | :--- |32| Subgrid-process parameterization | Predict physical tendencies and fluxes from temperature, humidity, wind, and surface forcing. |33| Atmospheric-column diagnostics | Validate heating, moistening, radiation, and precipitation relationships over 30 levels. |34| Local engineering validation | Validate training, inference, conservation diagnostics, and visualization with structured synthetic samples. |35| ModelScope/OneCode execution | Validate structured data, training, inference, parameterization metrics, and visualization in ModelScope or OneCode environments. |36| Multi-GPU training | Validate distributed training and the checkpoint workflow through `torchrun`. |37 38# Usage Instructions39 40## 1.OneCode41 42Experience intelligent, one-click AI4S programming through the OneCode online environment:43 44[Try intelligent, one-click AI4S programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)45 46## 2. Download and Installation47 48```bash49hf download OneScience-Group/NNCAM --local-dir ./NNCAM50cd NNCAM51```52 53### Environment Dependencies54 55**Hardware Requirements**56 57- A GPU or DCU is recommended.58- A CPU can be used for connectivity validation with the default small-sample configuration.59- DCU users must install DTK in advance. DTK 25.04.2 or later, or the OneScience-recommended version matching the current cluster, is recommended.60 61**DCU Environment**62 63```bash64# Activate DTK and Conda first65conda create -n onescience311 python=3.11 -y66conda activate onescience31167pip install onescience[earth-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai68```69 70**GPU Environment**71 72```bash73# Activate Conda first74conda create -n onescience311 python=3.11 -y libstdcxx-ng=12 libgcc-ng=12 gcc_linux-64=12 gxx_linux-64=1275conda activate onescience31176pip install onescience[earth-gpu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai77```78 79### Training Data80 81The paper uses SPCAM aquaplanet simulations with a 30-minute timestep and 30 vertical levels. Inputs are `[B,94]` temperature, humidity, wind, and surface-forcing columns, and targets are `[B,65]` heating, moistening, four radiative fluxes, and precipitation. This repository uses a small structured synthetic dataset for engineering validation only and does not represent the real SPCAM distribution, training scale, or paper performance.82 83```bash84python scripts/fake_data.py85```86 87### Training88 89For single-GPU training, use:90 91```bash92python scripts/train.py93```94 95For multi-GPU training, use:96 97```bash98torchrun --nproc_per_node=8 --nnodes=1 --rdzv_id=1000 --rdzv_backend=c10d --max_restarts=0 --master_addr="localhost" --master_port=29500 scripts/train.py99```100 101The default reduces the paper's nine 256-node layers to four 32-node layers and shortens training without reducing the 94 inputs, 65 outputs, or 30-level vertical protocol. Formal experiments require real SPCAM data and the paper-scale model, with artifacts saved to:102 103```text104result/checkpoints/nncam.pt105result/training/metrics.json106```107 108### Trained Weights109 110The paper does not provide directly loadable official model weights, and this repository bundles no weights under `weight/`. The locally trained checkpoint is saved to `result/checkpoints/nncam.pt` and must not be represented as an official pretrained weight.111 112### Inference113 114```bash115python scripts/inference.py116```117 118Inference loads the training checkpoint and generates subgrid tendencies, radiative fluxes, and precipitation from complete atmospheric-column states. Complete numerical outputs are saved to:119 120```text121result/output/predictions.npz122```123 124### Evaluation and Visualization125 126```bash127python scripts/result.py128```129 130Evaluation computes grouped RMSE and R² and generates grouped-error and precipitation-prediction comparisons. Synthetic-data results validate engineering only and do not represent paper performance; outputs are saved to:131 132```text133result/evaluation/metrics.json134result/evaluation/comparison.png135```136 137# Official OneScience Information138 139| Platform | OneScience Main Repository | Skills Repository |140| --- | --- | --- |141| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |142| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |143 144# Citation and License145 146This repository is an independent engineering reproduction of the public NNCAM specifications.147 148Use of this repository's code, official model weights, and data remains subject to the licenses and terms of their respective projects.149 