cnit 2.1.0__py3-none-any.whl
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/__init__.py +57 -0
- cnit/configs/experiment_config.py +51 -0
- cnit/configs/model_config.py +145 -0
- cnit/physics/__init__.py +0 -0
- cnit/physics/carbon_cycle.py +1191 -0
- cnit/physics/carbon_nitrogen_cycle.py +1512 -0
- cnit/physics/effects.py +1660 -0
- cnit/physics/landuse.py +733 -0
- cnit/physics/nitrogen_cycle.py +1927 -0
- cnit/utils/__init__.py +0 -0
- cnit/utils/data_utils.py +15 -0
- cnit/utils/maths.py +88 -0
- cnit/utils/units.py +64 -0
- cnit-2.1.0.dist-info/METADATA +205 -0
- cnit-2.1.0.dist-info/RECORD +17 -0
- cnit-2.1.0.dist-info/WHEEL +5 -0
- cnit-2.1.0.dist-info/top_level.txt +1 -0
cnit/__init__.py
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
|
+
)
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
import pint
|
|
3
|
+
|
|
4
|
+
from ..physics.landuse import LanduseCalculator
|
|
5
|
+
from ..physics.effects import (
|
|
6
|
+
EffectCO2Calculator,
|
|
7
|
+
EffectTemperatureCalculator,
|
|
8
|
+
EffectCarbonNitrogenCouplingCalculator,
|
|
9
|
+
EffectLanduseCalculator
|
|
10
|
+
)
|
|
11
|
+
from ..physics.carbon_cycle import (
|
|
12
|
+
CarbonNPPLPRCalculator,
|
|
13
|
+
CarbonTurnoverCalculator,
|
|
14
|
+
CarbonCycleCalculator,
|
|
15
|
+
CarbonCycleModel
|
|
16
|
+
)
|
|
17
|
+
from ..physics.nitrogen_cycle import (
|
|
18
|
+
NitrogenPUBNFCalculator,
|
|
19
|
+
NitrogenTurnoverCalculator,
|
|
20
|
+
NitrogenCycleCalculator,
|
|
21
|
+
NitrogenCycleModel
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
from ..utils.units import Q
|
|
25
|
+
|
|
26
|
+
calc_lu = LanduseCalculator()
|
|
27
|
+
calc_eff_CO2 = EffectCO2Calculator()
|
|
28
|
+
calc_eff_dT = EffectTemperatureCalculator()
|
|
29
|
+
calc_eff_CN = EffectCarbonNitrogenCouplingCalculator()
|
|
30
|
+
calc_eff_LU = EffectLanduseCalculator()
|
|
31
|
+
calc_npp_lpr = CarbonNPPLPRCalculator()
|
|
32
|
+
calc_c_turnover = CarbonTurnoverCalculator()
|
|
33
|
+
calc_c_cycle = CarbonCycleCalculator()
|
|
34
|
+
mdl_c_cycle = CarbonCycleModel(
|
|
35
|
+
calc_c_turnover=calc_c_turnover,
|
|
36
|
+
calc_c_cycle=calc_c_cycle,
|
|
37
|
+
)
|
|
38
|
+
calc_pu_bnf = NitrogenPUBNFCalculator()
|
|
39
|
+
calc_n_turnover = NitrogenTurnoverCalculator()
|
|
40
|
+
calc_n_cycle = NitrogenCycleCalculator()
|
|
41
|
+
mdl_n_cycle = NitrogenCycleModel(
|
|
42
|
+
calc_n_turnover=calc_n_turnover,
|
|
43
|
+
calc_n_cycle=calc_n_cycle,
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@dataclass(slots=True)
|
|
48
|
+
class CarbonNitrogenCycleModelConfig:
|
|
49
|
+
frc_rgr: pint.Quantity = calc_lu.frc_rgr
|
|
50
|
+
tau_rgr: pint.Quantity = calc_lu.tau_rgr
|
|
51
|
+
method_cLU: pint.Quantity = calc_lu.method_cLU
|
|
52
|
+
method_nLU: pint.Quantity = calc_lu.method_nLU
|
|
53
|
+
|
|
54
|
+
CO2ref: pint.Quantity = calc_eff_CO2.CO2ref
|
|
55
|
+
CO2b: pint.Quantity = calc_eff_CO2.CO2b
|
|
56
|
+
sns_CO2_log: pint.Quantity = calc_eff_CO2.sns_CO2_log
|
|
57
|
+
sns_CO2_sig: pint.Quantity = calc_eff_CO2.sns_CO2_sig
|
|
58
|
+
eff_CO2_sig_max: pint.Quantity = calc_eff_CO2.eff_CO2_sig_max
|
|
59
|
+
method_CO2_NPP: pint.Quantity = calc_eff_CO2.method_CO2_NPP
|
|
60
|
+
|
|
61
|
+
sns_NPP2dT: pint.Quantity = calc_eff_dT.sns_NPP2dT
|
|
62
|
+
sns_NPP2dT_sig: pint.Quantity = calc_eff_dT.sns_NPP2dT_sig
|
|
63
|
+
method_dT_NPP: pint.Quantity = calc_eff_dT.method_dT_NPP
|
|
64
|
+
sns_LPR2dT: pint.Quantity = calc_eff_dT.sns_LPR2dT
|
|
65
|
+
sns_cLP2dT: pint.Quantity = calc_eff_dT.sns_cLP2dT
|
|
66
|
+
sns_cLD2dT: pint.Quantity = calc_eff_dT.sns_cLD2dT
|
|
67
|
+
sns_cSR2dT: pint.Quantity = calc_eff_dT.sns_cSR2dT
|
|
68
|
+
sns_PU2dT: pint.Quantity = calc_eff_dT.sns_PU2dT
|
|
69
|
+
sns_BNF2dT: pint.Quantity = calc_eff_dT.sns_BNF2dT
|
|
70
|
+
sns_nLP2dT: pint.Quantity = calc_eff_dT.sns_nLP2dT
|
|
71
|
+
sns_nLD2dT: pint.Quantity = calc_eff_dT.sns_nLD2dT
|
|
72
|
+
sns_nSR2dT: pint.Quantity = calc_eff_dT.sns_nSR2dT
|
|
73
|
+
sns_nLSgas2dT: pint.Quantity = calc_eff_dT.sns_nLSgas2dT
|
|
74
|
+
|
|
75
|
+
sns_NPP2PUdef: pint.Quantity = calc_eff_CN.sns_NPP2PUdef
|
|
76
|
+
sns_cLP2PUdef: pint.Quantity = calc_eff_CN.sns_cLP2PUdef
|
|
77
|
+
sns_cLD2PUdef: pint.Quantity = calc_eff_CN.sns_cLD2PUdef
|
|
78
|
+
sns_cSR2PUdef: pint.Quantity = calc_eff_CN.sns_cSR2PUdef
|
|
79
|
+
sns_PU2PUdef: pint.Quantity = calc_eff_CN.sns_PU2PUdef
|
|
80
|
+
sns_BNF2PUdef: pint.Quantity = calc_eff_CN.sns_BNF2PUdef
|
|
81
|
+
sns_nLP2PUdef: pint.Quantity = calc_eff_CN.sns_nLP2PUdef
|
|
82
|
+
sns_nLD2PUdef: pint.Quantity = calc_eff_CN.sns_nLD2PUdef
|
|
83
|
+
sns_nSR2PUdef: pint.Quantity = calc_eff_CN.sns_nSR2PUdef
|
|
84
|
+
eff_C_PU_max: pint.Quantity = calc_eff_CN.eff_C_PU_max
|
|
85
|
+
sns_PU2NPPrd: pint.Quantity = calc_eff_CN.sns_PU2NPPrd
|
|
86
|
+
eff_C_BNF_max: pint.Quantity = calc_eff_CN.eff_C_BNF_max
|
|
87
|
+
sns_BNF2NPPrd: pint.Quantity = calc_eff_CN.sns_BNF2NPPrd
|
|
88
|
+
|
|
89
|
+
sns_cLP2LUrgr: pint.Quantity = calc_eff_LU.sns_cLP2LUrgr
|
|
90
|
+
sns_cLD2LUrgr: pint.Quantity = calc_eff_LU.sns_cLD2LUrgr
|
|
91
|
+
sns_cSR2LUrgr: pint.Quantity = calc_eff_LU.sns_cSR2LUrgr
|
|
92
|
+
sns_nLP2LUrgr: pint.Quantity = calc_eff_LU.sns_nLP2LUrgr
|
|
93
|
+
sns_nLD2LUrgr: pint.Quantity = calc_eff_LU.sns_nLD2LUrgr
|
|
94
|
+
sns_nSR2LUrgr: pint.Quantity = calc_eff_LU.sns_nSR2LUrgr
|
|
95
|
+
|
|
96
|
+
NPP0: pint.Quantity = calc_npp_lpr.NPP0
|
|
97
|
+
LPR0: pint.Quantity = calc_npp_lpr.LPR0
|
|
98
|
+
|
|
99
|
+
frc_NPP2P: pint.Quantity = calc_c_cycle.frc_NPP2P
|
|
100
|
+
frc_NPP2L: pint.Quantity = calc_c_cycle.frc_NPP2L
|
|
101
|
+
frc_cLP2L: pint.Quantity = calc_c_cycle.frc_cLP2L
|
|
102
|
+
frc_cLD2S: pint.Quantity = calc_c_cycle.frc_cLD2S
|
|
103
|
+
frc_cLUgrs2P: pint.Quantity = calc_c_cycle.frc_cLUgrs2P
|
|
104
|
+
frc_cLUgrs2L: pint.Quantity = calc_c_cycle.frc_cLUgrs2L
|
|
105
|
+
|
|
106
|
+
tau_CplsP: pint.Quantity = calc_c_turnover.tau_CplsP
|
|
107
|
+
tau_CplsL: pint.Quantity = calc_c_turnover.tau_CplsL
|
|
108
|
+
tau_CplsS: pint.Quantity = calc_c_turnover.tau_CplsS
|
|
109
|
+
|
|
110
|
+
CplsP0: pint.Quantity = mdl_c_cycle.CplsP0
|
|
111
|
+
CplsL0: pint.Quantity = mdl_c_cycle.CplsL0
|
|
112
|
+
CplsS0: pint.Quantity = mdl_c_cycle.CplsS0
|
|
113
|
+
|
|
114
|
+
PU0: pint.Quantity = calc_pu_bnf.PU0
|
|
115
|
+
BNF0: pint.Quantity = calc_pu_bnf.BNF0
|
|
116
|
+
NCratio_PUreq: pint.Quantity = calc_pu_bnf.NCratio_PUreq
|
|
117
|
+
NetMIN0: pint.Quantity = calc_pu_bnf.NetMIN0
|
|
118
|
+
sns_NetMIN2dT: pint.Quantity = calc_pu_bnf.sns_NetMIN2dT
|
|
119
|
+
NetMINlt0: pint.Quantity = calc_pu_bnf.NetMINlt0
|
|
120
|
+
sns_NetMINlt2AD: pint.Quantity = calc_pu_bnf.sns_NetMINlt2AD
|
|
121
|
+
|
|
122
|
+
tau_NplsP: pint.Quantity = calc_n_turnover.tau_NplsP
|
|
123
|
+
tau_NplsL: pint.Quantity = calc_n_turnover.tau_NplsL
|
|
124
|
+
tau_NplsS: pint.Quantity = calc_n_turnover.tau_NplsS
|
|
125
|
+
tau_NplsM: pint.Quantity = calc_n_turnover.tau_NplsM
|
|
126
|
+
|
|
127
|
+
frc_BNF2P: pint.Quantity = calc_n_cycle.frc_BNF2P
|
|
128
|
+
frc_BNF2L: pint.Quantity = calc_n_cycle.frc_BNF2L
|
|
129
|
+
frc_PU2P: pint.Quantity = calc_n_cycle.frc_PU2P
|
|
130
|
+
frc_PU2L: pint.Quantity = calc_n_cycle.frc_PU2L
|
|
131
|
+
frc_nLP2L: pint.Quantity = calc_n_cycle.frc_nLP2L
|
|
132
|
+
frc_nLD2S: pint.Quantity = calc_n_cycle.frc_nLD2S
|
|
133
|
+
frc_nLSgas: pint.Quantity = calc_n_cycle.frc_nLSgas
|
|
134
|
+
frc_nLUgrs2P: pint.Quantity = calc_n_cycle.frc_nLUgrs2P
|
|
135
|
+
frc_nLUgrs2L: pint.Quantity = calc_n_cycle.frc_nLUgrs2L
|
|
136
|
+
|
|
137
|
+
NplsP0: pint.Quantity = mdl_n_cycle.NplsP0
|
|
138
|
+
NplsL0: pint.Quantity = mdl_n_cycle.NplsL0
|
|
139
|
+
NplsS0: pint.Quantity = mdl_n_cycle.NplsS0
|
|
140
|
+
NplsM0: pint.Quantity = mdl_n_cycle.NplsM0
|
|
141
|
+
|
|
142
|
+
time0: pint.Quantity = mdl_c_cycle.time0
|
|
143
|
+
switch_N: pint.Quantity = Q(1, "1")
|
|
144
|
+
switch_Cpls: list = field(default_factory=lambda: [1, 1, 1])
|
|
145
|
+
switch_Npls: list = field(default_factory=lambda: [1, 1, 1, 1])
|
cnit/physics/__init__.py
ADDED
|
File without changes
|