cnit 2.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cnit-2.1.0/LICENSE +28 -0
- cnit-2.1.0/PKG-INFO +205 -0
- cnit-2.1.0/README.md +159 -0
- cnit-2.1.0/pyproject.toml +76 -0
- cnit-2.1.0/setup.cfg +4 -0
- cnit-2.1.0/src/cnit/__init__.py +57 -0
- cnit-2.1.0/src/cnit/configs/experiment_config.py +51 -0
- cnit-2.1.0/src/cnit/configs/model_config.py +145 -0
- cnit-2.1.0/src/cnit/physics/__init__.py +0 -0
- cnit-2.1.0/src/cnit/physics/carbon_cycle.py +1191 -0
- cnit-2.1.0/src/cnit/physics/carbon_nitrogen_cycle.py +1512 -0
- cnit-2.1.0/src/cnit/physics/effects.py +1660 -0
- cnit-2.1.0/src/cnit/physics/landuse.py +733 -0
- cnit-2.1.0/src/cnit/physics/nitrogen_cycle.py +1927 -0
- cnit-2.1.0/src/cnit/utils/__init__.py +0 -0
- cnit-2.1.0/src/cnit/utils/data_utils.py +15 -0
- cnit-2.1.0/src/cnit/utils/maths.py +88 -0
- cnit-2.1.0/src/cnit/utils/units.py +64 -0
- cnit-2.1.0/src/cnit.egg-info/PKG-INFO +205 -0
- cnit-2.1.0/src/cnit.egg-info/SOURCES.txt +21 -0
- cnit-2.1.0/src/cnit.egg-info/dependency_links.txt +1 -0
- cnit-2.1.0/src/cnit.egg-info/requires.txt +21 -0
- cnit-2.1.0/src/cnit.egg-info/top_level.txt +1 -0
cnit-2.1.0/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Gang Tang and contributors
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
cnit-2.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cnit
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: CNit: A Coupled Carbon-Nitrogen Cycle Model (Python)
|
|
5
|
+
Author-email: Gang Tang <gang.tang.au@gmail.com>, Zebedee Nicholls <zebedee.nicholls@climate-energy-college.org>, Alexander Norton <alex.norton@csiro.au>, Sönke Zaehle <szaehle@bgc-jena.mpg.de>, Malte Meinshausen <malte.meinshausen@unimelb.edu.au>
|
|
6
|
+
Maintainer-email: Gang Tang <gang.tang.au@gmail.com>
|
|
7
|
+
License: BSD-3-Clause
|
|
8
|
+
Project-URL: Homepage, https://github.com/gangtang-au/cnit
|
|
9
|
+
Project-URL: Documentation, https://cnit.readthedocs.io
|
|
10
|
+
Project-URL: Repository, https://github.com/gangtang-au/cnit
|
|
11
|
+
Project-URL: Changelog, https://cnit.readthedocs.io/en/latest/changelog.html
|
|
12
|
+
Keywords: cnit,carbon cycle,nitrogen cycle,simple climate model,magicc
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
19
|
+
Classifier: Programming Language :: Python
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
Requires-Dist: numpy
|
|
29
|
+
Requires-Dist: scipy
|
|
30
|
+
Requires-Dist: xarray==2023.6.0
|
|
31
|
+
Requires-Dist: netCDF4
|
|
32
|
+
Requires-Dist: attrs
|
|
33
|
+
Requires-Dist: openscm-units>=0.5.0
|
|
34
|
+
Requires-Dist: pint>=0.19
|
|
35
|
+
Provides-Extra: notebook
|
|
36
|
+
Requires-Dist: notebook<7,>=6; extra == "notebook"
|
|
37
|
+
Requires-Dist: matplotlib; extra == "notebook"
|
|
38
|
+
Provides-Extra: docs
|
|
39
|
+
Requires-Dist: sphinx>=1.4; extra == "docs"
|
|
40
|
+
Requires-Dist: sphinx-rtd-theme>=1.0; extra == "docs"
|
|
41
|
+
Requires-Dist: sphinx-autodoc-typehints>=1.22; extra == "docs"
|
|
42
|
+
Requires-Dist: sphinxcontrib-bibtex; extra == "docs"
|
|
43
|
+
Provides-Extra: tests
|
|
44
|
+
Requires-Dist: pytest; extra == "tests"
|
|
45
|
+
Requires-Dist: pytest-regressions[dataframe]; extra == "tests"
|
|
46
|
+
|
|
47
|
+
<p align="left">
|
|
48
|
+
<img src="docs/_static/CNit_logo.png" alt="CNit logo" width="100">
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
**CNit** (Carbon-Nitrogen Interactions in Terrestrial ecosystems) is a process-based
|
|
52
|
+
terrestrial biogeochemistry model that simulates coupled carbon and nitrogen cycles
|
|
53
|
+
in terrestrial ecosystems. It is the land component of **MAGICC** (Model for the
|
|
54
|
+
Assessment of Greenhouse Gas Induced Climate Change).
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
* Explicit carbon-nitrogen coupling with nitrogen limitation feedbacks
|
|
59
|
+
* Four nitrogen pools (plant, litter, soil, mineral) and three carbon pools
|
|
60
|
+
* Environmental modifiers: CO₂ fertilization, temperature, land use
|
|
61
|
+
* Separation of deforestation and afforestation for CDR scenarios
|
|
62
|
+
* Annual timestep with sub-annual process representation
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
**For users:**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install cnit
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**For developers:**
|
|
73
|
+
|
|
74
|
+
To set up a development environment for this project, follow these steps:
|
|
75
|
+
|
|
76
|
+
1. **Create a new conda environment** (replace `cnit` with your preferred name if desired):
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
conda create --name cnit python=3.9
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
2. **Activate your environment**:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
conda activate cnit
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
3. **Install all dependencies and set up the package**:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
make env
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
This will install all required dependencies (including notebook, docs, and testing tools) and install the package in editable mode.
|
|
95
|
+
|
|
96
|
+
> **Note:**
|
|
97
|
+
> The Makefile will check that you are not in the `base` environment and will refuse to run if you are.
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
**TL;DR:**
|
|
102
|
+
```bash
|
|
103
|
+
conda create --name cnit python=3.9
|
|
104
|
+
conda activate cnit
|
|
105
|
+
make env
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Quick Start
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import numpy as np
|
|
112
|
+
from cnit import CNitModel, CNitModelConfig, CNitExpConfig
|
|
113
|
+
from cnit import Q # Local pint.quantity class for units handling
|
|
114
|
+
|
|
115
|
+
# Create model with default parameters
|
|
116
|
+
config = CNitModelConfig()
|
|
117
|
+
model = CNitModel.from_config(config)
|
|
118
|
+
|
|
119
|
+
# Set up time axis and forcing
|
|
120
|
+
time_axis = Q(np.arange(1850, 2101), "yr")
|
|
121
|
+
n_steps = len(time_axis)
|
|
122
|
+
|
|
123
|
+
# Simple forcing (constant values for illustration)
|
|
124
|
+
dT_s = Q(np.linspace(0, 2, n_steps), "K") # 2°C warming
|
|
125
|
+
CO2_s = Q(np.linspace(280, 560, n_steps), "ppm") # CO2 doubling
|
|
126
|
+
|
|
127
|
+
# Land use emissions (zero for simplicity)
|
|
128
|
+
CemsLUnet_s = Q(np.zeros(n_steps), "GtC/yr")
|
|
129
|
+
CemsLUgrs_s = Q(np.zeros(n_steps), "GtC/yr")
|
|
130
|
+
|
|
131
|
+
# Nitrogen inputs
|
|
132
|
+
NflxAD_s = Q(np.linspace(0.05, 0.15, n_steps), "GtN/yr") # Increasing deposition
|
|
133
|
+
NflxFT_s = Q(np.linspace(0, 0.1, n_steps), "GtN/yr") # Increasing fertilizer
|
|
134
|
+
|
|
135
|
+
# Nitrogen land use emissions
|
|
136
|
+
NemsLUnet_s = Q(np.zeros(n_steps), "GtN/yr")
|
|
137
|
+
NemsLUgrs_s = Q(np.zeros(n_steps), "GtN/yr")
|
|
138
|
+
NemsLUmin_s = Q(np.zeros(n_steps), "GtN/yr")
|
|
139
|
+
|
|
140
|
+
# Run the model
|
|
141
|
+
res = model.run(
|
|
142
|
+
time_axis=time_axis,
|
|
143
|
+
dT_s=dT_s,
|
|
144
|
+
CO2_s=CO2_s,
|
|
145
|
+
CemsLUnet_s=CemsLUnet_s,
|
|
146
|
+
CemsLUgrs_s=CemsLUgrs_s,
|
|
147
|
+
NflxAD_s=NflxAD_s,
|
|
148
|
+
NflxFT_s=NflxFT_s,
|
|
149
|
+
NemsLUnet_s=NemsLUnet_s,
|
|
150
|
+
NemsLUgrs_s=NemsLUgrs_s,
|
|
151
|
+
NemsLUmin_s=NemsLUmin_s,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
# Access results
|
|
155
|
+
cveg, cveg_unit = res["CplsP"].data, res["CplsP"].units
|
|
156
|
+
nveg, nveg_unit = res["NplsP"].data, res["NplsP"].units
|
|
157
|
+
npp, npp_unit = res["CflxNPP"].data, res["CflxNPP"].units
|
|
158
|
+
|
|
159
|
+
print(f"Final plant carbon: {cveg[-1]} {cveg_unit}")
|
|
160
|
+
print(f"Final plant nitrogen: {nveg[-1]} {nveg_unit}")
|
|
161
|
+
print(f"NPP change: {npp[0]} → {npp[-1]} {npp_unit}")
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Documentation
|
|
165
|
+
The full documentation for CNit is available at
|
|
166
|
+
[https://cnit.readthedocs.io](https://cnit.readthedocs.io).
|
|
167
|
+
|
|
168
|
+
## License
|
|
169
|
+
BSD 3-Clause License. See LICENSE for details.
|
|
170
|
+
|
|
171
|
+
Copyright (c) 2026, Gang Tang and contributors.
|
|
172
|
+
|
|
173
|
+
## Authors and Contributors
|
|
174
|
+
|
|
175
|
+
**Author, Developer, and Maintainer:**
|
|
176
|
+
Gang Tang
|
|
177
|
+
- gang.tang.au@gmail.com (primary)
|
|
178
|
+
- gang.tang@student.unimelb.edu.au
|
|
179
|
+
- tgang@bgc-jena.mpg.de
|
|
180
|
+
|
|
181
|
+
**Contributors:**
|
|
182
|
+
- Zebedee Nicholls (zebedee.nicholls@climate-energy-college.org)
|
|
183
|
+
- Alexander Norton (alex.norton@csiro.au)
|
|
184
|
+
- Sönke Zaehle (szaehle@bgc-jena.mpg.de)
|
|
185
|
+
- Malte Meinshausen (malte.meinshausen@unimelb.edu.au)
|
|
186
|
+
|
|
187
|
+
## Citation
|
|
188
|
+
If you use CNit in your research, please cite:
|
|
189
|
+
|
|
190
|
+
- Tang, G., Nicholls, Z., Norton, A., Zaehle, S., and Meinshausen, M.: Synthesizing
|
|
191
|
+
global carbon–nitrogen coupling effects – the MAGICC coupled carbon–nitrogen cycle
|
|
192
|
+
model v1.0, Geosci. Model Dev., 18, 2193–2230,
|
|
193
|
+
https://doi.org/10.5194/gmd-18-2193-2025, 2025.
|
|
194
|
+
|
|
195
|
+
- Tang, G., Zaehle, S., Nicholls, Z., Norton, A., Ziehn, T., & Meinshausen,
|
|
196
|
+
M. Understanding the Drivers of Carbon-Nitrogen Cycle Variability in CMIP6 ESMs
|
|
197
|
+
with MAGICC CNit v2.0: Model and Calibration Updates. ESS Open Archive.
|
|
198
|
+
June 16, 2025. https://doi.org/10.22541/essoar.175008280.09297369/v1
|
|
199
|
+
[accepted by Journal of Advances in Modeling Earth Systems (JAMES)]
|
|
200
|
+
|
|
201
|
+
## Related Projects
|
|
202
|
+
|
|
203
|
+
MAGICC - Model for the Assessment of Greenhouse Gas Induced Climate Change,
|
|
204
|
+
- https://magicc.org/
|
|
205
|
+
- https://gitlab.com/magicc/magicc
|
cnit-2.1.0/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<p align="left">
|
|
2
|
+
<img src="docs/_static/CNit_logo.png" alt="CNit logo" width="100">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
**CNit** (Carbon-Nitrogen Interactions in Terrestrial ecosystems) is a process-based
|
|
6
|
+
terrestrial biogeochemistry model that simulates coupled carbon and nitrogen cycles
|
|
7
|
+
in terrestrial ecosystems. It is the land component of **MAGICC** (Model for the
|
|
8
|
+
Assessment of Greenhouse Gas Induced Climate Change).
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
* Explicit carbon-nitrogen coupling with nitrogen limitation feedbacks
|
|
13
|
+
* Four nitrogen pools (plant, litter, soil, mineral) and three carbon pools
|
|
14
|
+
* Environmental modifiers: CO₂ fertilization, temperature, land use
|
|
15
|
+
* Separation of deforestation and afforestation for CDR scenarios
|
|
16
|
+
* Annual timestep with sub-annual process representation
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
**For users:**
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install cnit
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**For developers:**
|
|
27
|
+
|
|
28
|
+
To set up a development environment for this project, follow these steps:
|
|
29
|
+
|
|
30
|
+
1. **Create a new conda environment** (replace `cnit` with your preferred name if desired):
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
conda create --name cnit python=3.9
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
2. **Activate your environment**:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
conda activate cnit
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
3. **Install all dependencies and set up the package**:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
make env
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This will install all required dependencies (including notebook, docs, and testing tools) and install the package in editable mode.
|
|
49
|
+
|
|
50
|
+
> **Note:**
|
|
51
|
+
> The Makefile will check that you are not in the `base` environment and will refuse to run if you are.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
**TL;DR:**
|
|
56
|
+
```bash
|
|
57
|
+
conda create --name cnit python=3.9
|
|
58
|
+
conda activate cnit
|
|
59
|
+
make env
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import numpy as np
|
|
66
|
+
from cnit import CNitModel, CNitModelConfig, CNitExpConfig
|
|
67
|
+
from cnit import Q # Local pint.quantity class for units handling
|
|
68
|
+
|
|
69
|
+
# Create model with default parameters
|
|
70
|
+
config = CNitModelConfig()
|
|
71
|
+
model = CNitModel.from_config(config)
|
|
72
|
+
|
|
73
|
+
# Set up time axis and forcing
|
|
74
|
+
time_axis = Q(np.arange(1850, 2101), "yr")
|
|
75
|
+
n_steps = len(time_axis)
|
|
76
|
+
|
|
77
|
+
# Simple forcing (constant values for illustration)
|
|
78
|
+
dT_s = Q(np.linspace(0, 2, n_steps), "K") # 2°C warming
|
|
79
|
+
CO2_s = Q(np.linspace(280, 560, n_steps), "ppm") # CO2 doubling
|
|
80
|
+
|
|
81
|
+
# Land use emissions (zero for simplicity)
|
|
82
|
+
CemsLUnet_s = Q(np.zeros(n_steps), "GtC/yr")
|
|
83
|
+
CemsLUgrs_s = Q(np.zeros(n_steps), "GtC/yr")
|
|
84
|
+
|
|
85
|
+
# Nitrogen inputs
|
|
86
|
+
NflxAD_s = Q(np.linspace(0.05, 0.15, n_steps), "GtN/yr") # Increasing deposition
|
|
87
|
+
NflxFT_s = Q(np.linspace(0, 0.1, n_steps), "GtN/yr") # Increasing fertilizer
|
|
88
|
+
|
|
89
|
+
# Nitrogen land use emissions
|
|
90
|
+
NemsLUnet_s = Q(np.zeros(n_steps), "GtN/yr")
|
|
91
|
+
NemsLUgrs_s = Q(np.zeros(n_steps), "GtN/yr")
|
|
92
|
+
NemsLUmin_s = Q(np.zeros(n_steps), "GtN/yr")
|
|
93
|
+
|
|
94
|
+
# Run the model
|
|
95
|
+
res = model.run(
|
|
96
|
+
time_axis=time_axis,
|
|
97
|
+
dT_s=dT_s,
|
|
98
|
+
CO2_s=CO2_s,
|
|
99
|
+
CemsLUnet_s=CemsLUnet_s,
|
|
100
|
+
CemsLUgrs_s=CemsLUgrs_s,
|
|
101
|
+
NflxAD_s=NflxAD_s,
|
|
102
|
+
NflxFT_s=NflxFT_s,
|
|
103
|
+
NemsLUnet_s=NemsLUnet_s,
|
|
104
|
+
NemsLUgrs_s=NemsLUgrs_s,
|
|
105
|
+
NemsLUmin_s=NemsLUmin_s,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Access results
|
|
109
|
+
cveg, cveg_unit = res["CplsP"].data, res["CplsP"].units
|
|
110
|
+
nveg, nveg_unit = res["NplsP"].data, res["NplsP"].units
|
|
111
|
+
npp, npp_unit = res["CflxNPP"].data, res["CflxNPP"].units
|
|
112
|
+
|
|
113
|
+
print(f"Final plant carbon: {cveg[-1]} {cveg_unit}")
|
|
114
|
+
print(f"Final plant nitrogen: {nveg[-1]} {nveg_unit}")
|
|
115
|
+
print(f"NPP change: {npp[0]} → {npp[-1]} {npp_unit}")
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Documentation
|
|
119
|
+
The full documentation for CNit is available at
|
|
120
|
+
[https://cnit.readthedocs.io](https://cnit.readthedocs.io).
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
BSD 3-Clause License. See LICENSE for details.
|
|
124
|
+
|
|
125
|
+
Copyright (c) 2026, Gang Tang and contributors.
|
|
126
|
+
|
|
127
|
+
## Authors and Contributors
|
|
128
|
+
|
|
129
|
+
**Author, Developer, and Maintainer:**
|
|
130
|
+
Gang Tang
|
|
131
|
+
- gang.tang.au@gmail.com (primary)
|
|
132
|
+
- gang.tang@student.unimelb.edu.au
|
|
133
|
+
- tgang@bgc-jena.mpg.de
|
|
134
|
+
|
|
135
|
+
**Contributors:**
|
|
136
|
+
- Zebedee Nicholls (zebedee.nicholls@climate-energy-college.org)
|
|
137
|
+
- Alexander Norton (alex.norton@csiro.au)
|
|
138
|
+
- Sönke Zaehle (szaehle@bgc-jena.mpg.de)
|
|
139
|
+
- Malte Meinshausen (malte.meinshausen@unimelb.edu.au)
|
|
140
|
+
|
|
141
|
+
## Citation
|
|
142
|
+
If you use CNit in your research, please cite:
|
|
143
|
+
|
|
144
|
+
- Tang, G., Nicholls, Z., Norton, A., Zaehle, S., and Meinshausen, M.: Synthesizing
|
|
145
|
+
global carbon–nitrogen coupling effects – the MAGICC coupled carbon–nitrogen cycle
|
|
146
|
+
model v1.0, Geosci. Model Dev., 18, 2193–2230,
|
|
147
|
+
https://doi.org/10.5194/gmd-18-2193-2025, 2025.
|
|
148
|
+
|
|
149
|
+
- Tang, G., Zaehle, S., Nicholls, Z., Norton, A., Ziehn, T., & Meinshausen,
|
|
150
|
+
M. Understanding the Drivers of Carbon-Nitrogen Cycle Variability in CMIP6 ESMs
|
|
151
|
+
with MAGICC CNit v2.0: Model and Calibration Updates. ESS Open Archive.
|
|
152
|
+
June 16, 2025. https://doi.org/10.22541/essoar.175008280.09297369/v1
|
|
153
|
+
[accepted by Journal of Advances in Modeling Earth Systems (JAMES)]
|
|
154
|
+
|
|
155
|
+
## Related Projects
|
|
156
|
+
|
|
157
|
+
MAGICC - Model for the Assessment of Greenhouse Gas Induced Climate Change,
|
|
158
|
+
- https://magicc.org/
|
|
159
|
+
- https://gitlab.com/magicc/magicc
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "cnit"
|
|
7
|
+
version = "2.1.0"
|
|
8
|
+
description = "CNit: A Coupled Carbon-Nitrogen Cycle Model (Python)"
|
|
9
|
+
keywords = ["cnit", "carbon cycle", "nitrogen cycle", "simple climate model", "magicc"]
|
|
10
|
+
authors = [
|
|
11
|
+
{name="Gang Tang", email="gang.tang.au@gmail.com"},
|
|
12
|
+
{name="Zebedee Nicholls", email="zebedee.nicholls@climate-energy-college.org"},
|
|
13
|
+
{name="Alexander Norton", email="alex.norton@csiro.au"},
|
|
14
|
+
{name="Sönke Zaehle", email="szaehle@bgc-jena.mpg.de"},
|
|
15
|
+
{name="Malte Meinshausen", email="malte.meinshausen@unimelb.edu.au"},
|
|
16
|
+
]
|
|
17
|
+
maintainers = [
|
|
18
|
+
{name="Gang Tang", email="gang.tang.au@gmail.com"}
|
|
19
|
+
]
|
|
20
|
+
license = {text = "BSD-3-Clause"}
|
|
21
|
+
readme = "README.md"
|
|
22
|
+
requires-python = ">=3.9"
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 4 - Beta",
|
|
25
|
+
"License :: OSI Approved :: BSD License",
|
|
26
|
+
"Operating System :: OS Independent",
|
|
27
|
+
"Intended Audience :: Developers",
|
|
28
|
+
"Intended Audience :: Science/Research",
|
|
29
|
+
"Intended Audience :: End Users/Desktop",
|
|
30
|
+
"Programming Language :: Python",
|
|
31
|
+
"Programming Language :: Python :: 3",
|
|
32
|
+
"Programming Language :: Python :: 3.9",
|
|
33
|
+
"Programming Language :: Python :: 3.10",
|
|
34
|
+
"Programming Language :: Python :: 3.11",
|
|
35
|
+
"Programming Language :: Python :: 3.12",
|
|
36
|
+
"Topic :: Scientific/Engineering"
|
|
37
|
+
]
|
|
38
|
+
dependencies = [
|
|
39
|
+
"numpy",
|
|
40
|
+
"scipy",
|
|
41
|
+
"xarray ==2023.6.0",
|
|
42
|
+
"netCDF4",
|
|
43
|
+
"attrs",
|
|
44
|
+
"openscm-units >=0.5.0",
|
|
45
|
+
"pint >=0.19"
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.optional-dependencies]
|
|
49
|
+
notebook = [
|
|
50
|
+
"notebook >=6,<7",
|
|
51
|
+
"matplotlib",
|
|
52
|
+
]
|
|
53
|
+
docs = [
|
|
54
|
+
"sphinx >=1.4",
|
|
55
|
+
"sphinx-rtd-theme >=1.0",
|
|
56
|
+
"sphinx-autodoc-typehints >=1.22",
|
|
57
|
+
"sphinxcontrib-bibtex",
|
|
58
|
+
]
|
|
59
|
+
tests = [
|
|
60
|
+
"pytest",
|
|
61
|
+
"pytest-regressions[dataframe]"
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[project.urls]
|
|
65
|
+
Homepage = "https://github.com/gangtang-au/cnit"
|
|
66
|
+
Documentation = "https://cnit.readthedocs.io"
|
|
67
|
+
Repository = "https://github.com/gangtang-au/cnit"
|
|
68
|
+
Changelog = "https://cnit.readthedocs.io/en/latest/changelog.html"
|
|
69
|
+
|
|
70
|
+
[tool.setuptools]
|
|
71
|
+
package-dir = {"" = "src"}
|
|
72
|
+
include-package-data = true
|
|
73
|
+
license-files = []
|
|
74
|
+
|
|
75
|
+
[tool.setuptools.packages.find]
|
|
76
|
+
where = ["src"]
|
cnit-2.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""
|
|
2
|
+
CNit - Carbon-Nitrogen Interactions in Terrestrial ecosystems.
|
|
3
|
+
|
|
4
|
+
CNit is a process-based terrestrial biogeochemistry model that simulates
|
|
5
|
+
coupled carbon and nitrogen cycles in terrestrial ecosystems.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Version
|
|
9
|
+
try:
|
|
10
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
11
|
+
except ImportError:
|
|
12
|
+
from importlib_metadata import version, PackageNotFoundError
|
|
13
|
+
|
|
14
|
+
try:
|
|
15
|
+
__version__ = version("cnit")
|
|
16
|
+
except PackageNotFoundError:
|
|
17
|
+
__version__ = "unknown"
|
|
18
|
+
|
|
19
|
+
# Suppress expected warnings
|
|
20
|
+
import warnings
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
from pint import UnitStrippedWarning
|
|
24
|
+
warnings.filterwarnings('ignore', category=UnitStrippedWarning)
|
|
25
|
+
except ImportError:
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
# Core model classes
|
|
29
|
+
from cnit.physics.carbon_nitrogen_cycle import (
|
|
30
|
+
CarbonNitrogenCycleModel,
|
|
31
|
+
CarbonNitrogenCycleModelConfig,
|
|
32
|
+
CarbonNitrogenCycleExperimentConfig,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# Convenient aliases
|
|
36
|
+
CNitModel = CarbonNitrogenCycleModel
|
|
37
|
+
CNitModelConfig = CarbonNitrogenCycleModelConfig
|
|
38
|
+
CNitExpConfig = CarbonNitrogenCycleExperimentConfig
|
|
39
|
+
|
|
40
|
+
# Utility imports
|
|
41
|
+
from cnit.utils.units import Q
|
|
42
|
+
|
|
43
|
+
# Define public API
|
|
44
|
+
__all__ = [
|
|
45
|
+
# Version
|
|
46
|
+
"__version__",
|
|
47
|
+
# Main classes (full names)
|
|
48
|
+
"CarbonNitrogenCycleModel",
|
|
49
|
+
"CarbonNitrogenCycleModelConfig",
|
|
50
|
+
"CarbonNitrogenCycleExperimentConfig",
|
|
51
|
+
# Convenient aliases
|
|
52
|
+
"CNitModel",
|
|
53
|
+
"CNitModelConfig",
|
|
54
|
+
"CNitExpConfig",
|
|
55
|
+
# Utilities
|
|
56
|
+
"Q",
|
|
57
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional, Dict
|
|
3
|
+
import pint
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@dataclass(slots=True)
|
|
7
|
+
class CarbonNitrogenCycleExperimentConfig:
|
|
8
|
+
"""
|
|
9
|
+
Configuration for a Carbon-Nitrogen Cycle experiment.
|
|
10
|
+
|
|
11
|
+
Attributes:
|
|
12
|
+
name: Name of the experiment.
|
|
13
|
+
time_axis: Time axis for the experiment [years].
|
|
14
|
+
dT_s: Temperature anomaly time series [K].
|
|
15
|
+
CO2_s: Atmospheric CO2 concentration time series [ppm].
|
|
16
|
+
CemsLUnet_s: Net carbon emissions from land use [PgC/yr].
|
|
17
|
+
CemsLUgrs_s: Gross carbon emissions from land use [PgC/yr].
|
|
18
|
+
NflxAD_s: Nitrogen flux from atmospheric deposition [TgN/yr].
|
|
19
|
+
NflxFT_s: Nitrogen flux from fertilizer [TgN/yr].
|
|
20
|
+
NemsLUnet_s: Net nitrogen emissions from land use [TgN/yr].
|
|
21
|
+
NemsLUgrs_s: Gross nitrogen emissions from land use [TgN/yr].
|
|
22
|
+
NemsLUmin_s: Nitrogen emissions from mineralization [TgN/yr].
|
|
23
|
+
metadata: Optional dictionary for additional metadata.
|
|
24
|
+
"""
|
|
25
|
+
name: str
|
|
26
|
+
switch_N: pint.Quantity
|
|
27
|
+
time_axis: pint.Quantity
|
|
28
|
+
dT_s: pint.Quantity
|
|
29
|
+
CO2_s: pint.Quantity
|
|
30
|
+
CemsLUnet_s: pint.Quantity
|
|
31
|
+
CemsLUgrs_s: pint.Quantity
|
|
32
|
+
NflxAD_s: pint.Quantity
|
|
33
|
+
NflxFT_s: pint.Quantity
|
|
34
|
+
NemsLUnet_s: pint.Quantity
|
|
35
|
+
NemsLUgrs_s: pint.Quantity
|
|
36
|
+
NemsLUmin_s: pint.Quantity
|
|
37
|
+
metadata: Optional[Dict[str, object]] = None
|
|
38
|
+
|
|
39
|
+
def to_input_dict(self):
|
|
40
|
+
return dict(
|
|
41
|
+
time_axis=self.time_axis,
|
|
42
|
+
dT_s=self.dT_s,
|
|
43
|
+
CO2_s=self.CO2_s,
|
|
44
|
+
CemsLUnet_s=self.CemsLUnet_s,
|
|
45
|
+
CemsLUgrs_s=self.CemsLUgrs_s,
|
|
46
|
+
NflxAD_s=self.NflxAD_s,
|
|
47
|
+
NflxFT_s=self.NflxFT_s,
|
|
48
|
+
NemsLUnet_s=self.NemsLUnet_s,
|
|
49
|
+
NemsLUgrs_s=self.NemsLUgrs_s,
|
|
50
|
+
NemsLUmin_s=self.NemsLUmin_s,
|
|
51
|
+
)
|