ICCS
/

English
climate
tztsai commited on
Commit
c9a76e6
β€’
1 Parent(s): 9fefd8c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -39
README.md CHANGED
@@ -5,62 +5,72 @@ language:
5
  tags:
6
  - climate
7
  ---
8
- # Convection Parameterization in CAM
9
 
10
- Note that this repository and code is still work in progress and undergoing significant development.
11
- Once a useable release is produced it will be tagged.
12
 
13
- ## Description
14
- This repository contains code as part of an effort to deploy machine learning (ML) models of geophysical parameterisations into the [Community Earth System Model (CESM)](https://www.cesm.ucar.edu/).
15
- This work is part of the [M<sup>2</sup>LInES](https://m2lines.github.io/) project aiming to improve performance of climate models using ML models for subgrid parameterizations.
16
 
17
- A Neural Net providing a subgrid parameterization of atmospheric convection in a [single column model](https://www.arm.gov/publications/proceedings/conf04/extended_abs/randall_da.pdf) has been developed and successfully deployed as part of an atmospheric simulation.
18
- The work is described in a [GRL paper](https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2020GL091363) with [accompanying code available](https://github.com/yaniyuval/Neural_nework_parameterization/tree/v.1.0.3). The repository contains the neural net and its implementation into a simple system for atmospheric modelling, [SAM](http://rossby.msrc.sunysb.edu/~marat/SAM.html).
19
 
20
- The aims of this repository are to:
21
- 1. develop a standalone fortran module based on this neural net that can be used elsewhere,
22
- 2. deploy the module in another atmospheric model, and
23
- 3. evaluate its performance.
24
 
25
- We may also perform an investigation into interfacing the pytorch implementation of the Neural Net using the [pytorch-fortran bridging code](https://github.com/Cambridge-ICCS/fortran-pytorch-lib) developed at the [Institute of Computing for Climate Science](https://cambridge-iccs.github.io/).
 
 
 
 
26
 
27
- The model will first be deployed into the [Single Column Atmospheric Model (SCAM)](https://www.cesm.ucar.edu/models/simple/scam) - a single column version of the CESM.
28
- We plan to evaluate performance using SCAM in the gateIII configuration for tropical convection in a similar manner described by the [SCAM6 pulication in JAMES](https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2018MS001578).
29
- This will compare model performance to data from an intense observation period (IOP) described in an [AMS publication](https://journals.ametsoc.org/view/journals/atsc/36/1/1520-0469_1979_036_0053_saposs_2_0_co_2.xml).
30
 
31
- Long term developments of this project will seek to re-deploy more complex ML parameterizations into mode complex atmospheric models such as the [Community Atmospheric Model (CAM)](https://www.cesm.ucar.edu/models/cam) part of the CESM.
32
 
33
-
34
- ## Repository structure
35
-
36
- ```
37
- β”œβ”€β”€ NN_module
38
- β”‚Β Β  └── ...
39
- └── torch_nets
40
- └── ...
41
  ```
42
 
 
43
 
 
 
 
44
 
45
- ### Contents
 
46
 
47
- ### `NN_module/`
48
- This folder contains the fortran neural net extracted from the [code referenced above](https://github.com/yaniyuval/Neural_nework_parameterization/tree/v.1.0.3), along with any dependencies, that may be compiled as a standalone fortran module.
 
 
49
 
50
- Currently there is code that can be built on CSD3 using the included shell script.
 
 
 
51
 
52
- This now needs cleaning up, testing, and a proper makefile creating (see open issues #9 and #10).
53
 
54
- ### ``torch_nets/``
55
- The directory contains the PyTorch versions of the neural networks we are interested in.
56
 
 
 
 
 
57
 
58
- ## Contributing
 
 
 
 
 
 
 
59
 
60
- This repository is currently private as it is new and work in progress.
61
- Open tickets can be viewed at ['Issues'](https://github.com/m2lines/convection-parameterization-in-CAM/issues).
62
 
63
- To contribute find a relevant issue or open a new one and assign yourself to work on it.
64
- Then create a branch in which to add your contribution and open a pull request.
65
- Once ready assign a reviewer and request a code review.
66
- Merging should _only_ be performed once a code review has taken place.
 
5
  tags:
6
  - climate
7
  ---
 
8
 
9
+ # CAM-ML-YOG-v0: Machine Learning-based Convection Parameterization
 
10
 
11
+ This repository contains a machine learning-based implementation of the convection parameterization in CAM (Community Atmosphere Model), leveraging PyTorch.
 
 
12
 
13
+ ## Model Overview
14
+ The model is a PyTorch adaptation of the original Fortran-based convection parameterization in CAM. It simulates subgrid-scale convection processes within a climate model and was developed to improve accuracy and efficiency.
15
 
16
+ ### Key Features:
17
+ - **Architecture**: The model is built with custom neural network layers as seen in [torch_nets/models.py](https://github.com/m2lines/convection-parameterization-in-CAM/blob/main/torch_nets/models.py).
18
+ - **Data Handling**: Fortran-derived model weights are seamlessly converted to PyTorch, ensuring compatibility with existing CAM configurations.
19
+ - **Training and Fine-tuning**: The model can be retrained or fine-tuned using custom climate data.
20
 
21
+ ## Model Conversion and Upload
22
+ This model was converted from the original CAM implementation by extracting the weights from Fortran and converting them into a PyTorch-compatible format. This conversion process involved the following steps:
23
+ 1. **Extract Fortran Weights**: Weights were extracted from the original CAM Fortran implementation.
24
+ 2. **Convert to PyTorch**: Using custom scripts, the weights were converted into a format compatible with PyTorch models.
25
+ 3. **Upload to Hugging Face**: The model was validated and uploaded to the Hugging Face Model Hub.
26
 
27
+ ## Usage
 
 
28
 
29
+ To use the model in PyTorch, first install the necessary dependencies:
30
 
31
+ ```bash
32
+ pip install torch huggingface_hub
 
 
 
 
 
 
33
  ```
34
 
35
+ Then, download and load the model as follows:
36
 
37
+ ```python
38
+ from huggingface_hub import hf_hub_download
39
+ import torch
40
 
41
+ # Download model weights
42
+ model_path = hf_hub_download(repo_id="ICCS/cam-ml-yog-v0", filename="model.pth")
43
 
44
+ # Load model (replace 'YourModel' with the appropriate model class from torch_nets/models.py)
45
+ model = YourModel()
46
+ model.load_state_dict(torch.load(model_path))
47
+ model.eval()
48
 
49
+ # Use the model for predictions
50
+ input_data = ... # Prepare your climate input data
51
+ output = model(input_data)
52
+ ```
53
 
54
+ ### Fine-tuning
55
 
56
+ The model is designed to be easily fine-tuned using domain-specific climate data:
 
57
 
58
+ ```python
59
+ # Fine-tune the model
60
+ optimizer = torch.optim.Adam(model.parameters(), lr=1e-4)
61
+ loss_fn = torch.nn.MSELoss()
62
 
63
+ # Example training loop
64
+ for epoch in range(epochs):
65
+ optimizer.zero_grad()
66
+ output = model(input_data)
67
+ loss = loss_fn(output, target_data)
68
+ loss.backward()
69
+ optimizer.step()
70
+ ```
71
 
72
+ ## Weight Updates
73
+ Please note that weight updates may be necessary as improvements are made to the model (see [Issue #66](https://github.com/m2lines/convection-parameterization-in-CAM/issues/66)).
74
 
75
+ ## References
76
+ For more details on the original implementation and how to contribute to the model’s development, see the [GitHub repository](https://github.com/m2lines/convection-parameterization-in-CAM).