hestia-earth-models 0.74.16__py3-none-any.whl → 0.74.17__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.
Potentially problematic release.
This version of hestia-earth-models might be problematic. Click here for more details.
- hestia_earth/models/ipcc2019/burning_utils.py +37 -0
- hestia_earth/models/ipcc2019/nonCo2EmissionsToAirNaturalVegetationBurning.py +84 -108
- hestia_earth/models/ipcc2019/pastureGrass_utils.py +1 -1
- hestia_earth/models/mocking/search-results.json +1 -1
- hestia_earth/models/utils/property.py +8 -6
- hestia_earth/models/version.py +1 -1
- {hestia_earth_models-0.74.16.dist-info → hestia_earth_models-0.74.17.dist-info}/METADATA +1 -1
- {hestia_earth_models-0.74.16.dist-info → hestia_earth_models-0.74.17.dist-info}/RECORD +11 -10
- {hestia_earth_models-0.74.16.dist-info → hestia_earth_models-0.74.17.dist-info}/WHEEL +0 -0
- {hestia_earth_models-0.74.16.dist-info → hestia_earth_models-0.74.17.dist-info}/licenses/LICENSE +0 -0
- {hestia_earth_models-0.74.16.dist-info → hestia_earth_models-0.74.17.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class FuelCategory(Enum):
|
|
5
|
+
"""
|
|
6
|
+
Natural vegetation fuel categories from IPCC (2019).
|
|
7
|
+
"""
|
|
8
|
+
BOREAL_FOREST = "boreal-forest"
|
|
9
|
+
DRAINED_EXTRATROPICAL_ORGANIC_SOILS_WILDFIRE = "drained-extratropical-organic-soils-wildfire"
|
|
10
|
+
DRAINED_TROPICAL_ORGANIC_SOILS_WILDFIRE = "drained-tropical-organic-soils-wildfire"
|
|
11
|
+
EUCALYPT_FOREST = "eucalypt-forest"
|
|
12
|
+
NATURAL_TROPICAL_FOREST = "natural-tropical-forest" # mean of primary and secondary tropical forest
|
|
13
|
+
PEATLAND_VEGETATION = "peatland-vegetation"
|
|
14
|
+
PRIMARY_TROPICAL_FOREST = "primary-tropical-forest"
|
|
15
|
+
SAVANNA_GRASSLAND_EARLY_DRY_SEASON_BURNS = "savanna-grassland-early-dry-season-burns"
|
|
16
|
+
SAVANNA_GRASSLAND_MID_TO_LATE_DRY_SEASON_BURNS = "savanna-grassland-mid-to-late-dry-season-burns"
|
|
17
|
+
SAVANNA_WOODLAND_EARLY_DRY_SEASON_BURNS = "savanna-woodland-early-dry-season-burns"
|
|
18
|
+
SAVANNA_WOODLAND_MID_TO_LATE_DRY_SEASON_BURNS = "savanna-woodland-mid-to-late-dry-season-burns"
|
|
19
|
+
SECONDARY_TROPICAL_FOREST = "secondary-tropical-forest"
|
|
20
|
+
SHRUBLAND = "shrubland"
|
|
21
|
+
TEMPERATE_FOREST = "temperate-forest"
|
|
22
|
+
TERTIARY_TROPICAL_FOREST = "tertiary-tropical-forest"
|
|
23
|
+
TROPICAL_ORGANIC_SOILS_PRESCRIBED_FIRE = "tropical-organic-soils-prescribed-fire"
|
|
24
|
+
TUNDRA = "tundra"
|
|
25
|
+
UNDRAINED_EXTRATROPICAL_ORGANIC_SOILS_WILDFIRE = "undrained-extratropical-organic-soils-wildfire"
|
|
26
|
+
UNKNOWN_TROPICAL_FOREST = "unknown-tropical-forest" # mean of primary, secondary and tertiary tropical forest
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class EmissionCategory(Enum):
|
|
30
|
+
"""
|
|
31
|
+
Natural vegetation burning emission categories from IPCC (2019).
|
|
32
|
+
"""
|
|
33
|
+
AGRICULTURAL_RESIDUES = "agricultural-residues"
|
|
34
|
+
BIOFUEL_BURNING = "biofuel-burning"
|
|
35
|
+
OTHER_FOREST = "other-forest"
|
|
36
|
+
SAVANNA_AND_GRASSLAND = "savanna-and-grassland"
|
|
37
|
+
TROPICAL_FOREST = "tropical-forest"
|
|
@@ -19,9 +19,12 @@ from hestia_earth.models.utils.ecoClimateZone import EcoClimateZone, get_eco_cli
|
|
|
19
19
|
from hestia_earth.models.utils.emission import _new_emission
|
|
20
20
|
from hestia_earth.models.utils.lookup import get_region_lookup_value
|
|
21
21
|
from hestia_earth.models.utils.site import related_cycles
|
|
22
|
+
from hestia_earth.models.utils.term import get_lookup_value
|
|
22
23
|
|
|
23
24
|
from . import MODEL
|
|
24
25
|
from .biomass_utils import BiomassCategory, get_valid_management_nodes, summarise_land_cover_nodes
|
|
26
|
+
from .burning_utils import EmissionCategory, FuelCategory
|
|
27
|
+
|
|
25
28
|
|
|
26
29
|
REQUIREMENTS = {
|
|
27
30
|
"Cycle": {
|
|
@@ -55,9 +58,17 @@ REQUIREMENTS = {
|
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
LOOKUPS = {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
+
"emission": [
|
|
62
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_BOREAL_FOREST_sd",
|
|
63
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_BOREAL_FOREST_value",
|
|
64
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_NATURAL_TROPICAL_FOREST_sd",
|
|
65
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_NATURAL_TROPICAL_FOREST_value",
|
|
66
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_TEMPERATE_FOREST_sd",
|
|
67
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_TEMPERATE_FOREST_value",
|
|
68
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_TERTIARY_TROPICAL_FOREST_sd",
|
|
69
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_TERTIARY_TROPICAL_FOREST_value",
|
|
70
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_UNKNOWN_TROPICAL_FOREST_sd",
|
|
71
|
+
"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_UNKNOWN_TROPICAL_FOREST_value"
|
|
61
72
|
],
|
|
62
73
|
"ipcc2019FuelCategory_tonnesDryMatterCombustedPerHaBurned": "value",
|
|
63
74
|
"landCover": "BIOMASS_CATEGORY",
|
|
@@ -95,36 +106,6 @@ _DEFAULT_FACTOR = {"value": 0}
|
|
|
95
106
|
_DEFAULT_PERCENT_BURNED = 0
|
|
96
107
|
|
|
97
108
|
|
|
98
|
-
class _FuelCategory(Enum):
|
|
99
|
-
"""
|
|
100
|
-
Natural vegetation fuel categories from IPCC (2019).
|
|
101
|
-
"""
|
|
102
|
-
BOREAL_FOREST = "boreal-forest"
|
|
103
|
-
EUCALYPT_FOREST = "eucalypt-forest"
|
|
104
|
-
NATURAL_TROPICAL_FOREST = "natural-tropical-forest" # mean of primary and secondary tropical forest
|
|
105
|
-
PRIMARY_TROPICAL_FOREST = "primary-tropical-forest"
|
|
106
|
-
SAVANNA_GRASSLAND_EARLY_DRY_SEASON_BURNS = "savanna-grassland-early-dry-season-burns"
|
|
107
|
-
SAVANNA_GRASSLAND_MID_TO_LATE_DRY_SEASON_BURNS = "savanna-grassland-mid-to-late-dry-season-burns"
|
|
108
|
-
SAVANNA_WOODLAND_EARLY_DRY_SEASON_BURNS = "savanna-woodland-early-dry-season-burns"
|
|
109
|
-
SAVANNA_WOODLAND_MID_TO_LATE_DRY_SEASON_BURNS = "savanna-woodland-mid-to-late-dry-season-burns"
|
|
110
|
-
SECONDARY_TROPICAL_FOREST = "secondary-tropical-forest"
|
|
111
|
-
SHRUBLAND = "shrubland"
|
|
112
|
-
TEMPERATE_FOREST = "temperate-forest"
|
|
113
|
-
TERTIARY_TROPICAL_FOREST = "tertiary-tropical-forest"
|
|
114
|
-
UNKNOWN_TROPICAL_FOREST = "unknown-tropical-forest" # mean of primary, secondary and tertiary tropical forest
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
class _EmissionCategory(Enum):
|
|
118
|
-
"""
|
|
119
|
-
Natural vegetation burning emission categories from IPCC (2019).
|
|
120
|
-
"""
|
|
121
|
-
AGRICULTURAL_RESIDUES = "agricultural-residues"
|
|
122
|
-
BIOFUEL_BURNING = "biofuel-burning"
|
|
123
|
-
OTHER_FOREST = "other-forest"
|
|
124
|
-
SAVANNA_AND_GRASSLAND = "savanna-and-grassland"
|
|
125
|
-
TROPICAL_FOREST = "tropical-forest"
|
|
126
|
-
|
|
127
|
-
|
|
128
109
|
_EmissionTermId = Literal[
|
|
129
110
|
"ch4ToAirNaturalVegetationBurning",
|
|
130
111
|
"coToAirNaturalVegetationBurning",
|
|
@@ -136,7 +117,7 @@ _EmissionTermId = Literal[
|
|
|
136
117
|
class _InventoryYear(TypedDict, total=False):
|
|
137
118
|
biomass_category_summary: dict[BiomassCategory, float]
|
|
138
119
|
natural_vegetation_delta: dict[BiomassCategory, float]
|
|
139
|
-
fuel_burnt_per_category: dict[
|
|
120
|
+
fuel_burnt_per_category: dict[FuelCategory, npt.NDArray]
|
|
140
121
|
annual_emissions: dict[_EmissionTermId, npt.NDArray]
|
|
141
122
|
amortised_emissions: dict[_EmissionTermId, npt.NDArray]
|
|
142
123
|
share_of_emissions: dict[str, float] # {cycle_id (str): value, ...}
|
|
@@ -161,40 +142,40 @@ _Inventory = dict[int, _InventoryYear]
|
|
|
161
142
|
|
|
162
143
|
_BIOMASS_CATEGORY_TO_FUEL_CATEGORY = {
|
|
163
144
|
BiomassCategory.FOREST: {
|
|
164
|
-
EcoClimateZone.WARM_TEMPERATE_MOIST:
|
|
165
|
-
EcoClimateZone.WARM_TEMPERATE_DRY:
|
|
166
|
-
EcoClimateZone.COOL_TEMPERATE_MOIST:
|
|
167
|
-
EcoClimateZone.COOL_TEMPERATE_DRY:
|
|
168
|
-
EcoClimateZone.BOREAL_MOIST:
|
|
169
|
-
EcoClimateZone.BOREAL_DRY:
|
|
170
|
-
EcoClimateZone.TROPICAL_MONTANE:
|
|
171
|
-
EcoClimateZone.TROPICAL_WET:
|
|
172
|
-
EcoClimateZone.TROPICAL_MOIST:
|
|
173
|
-
EcoClimateZone.TROPICAL_DRY:
|
|
145
|
+
EcoClimateZone.WARM_TEMPERATE_MOIST: FuelCategory.TEMPERATE_FOREST,
|
|
146
|
+
EcoClimateZone.WARM_TEMPERATE_DRY: FuelCategory.TEMPERATE_FOREST,
|
|
147
|
+
EcoClimateZone.COOL_TEMPERATE_MOIST: FuelCategory.TEMPERATE_FOREST,
|
|
148
|
+
EcoClimateZone.COOL_TEMPERATE_DRY: FuelCategory.TEMPERATE_FOREST,
|
|
149
|
+
EcoClimateZone.BOREAL_MOIST: FuelCategory.BOREAL_FOREST,
|
|
150
|
+
EcoClimateZone.BOREAL_DRY: FuelCategory.BOREAL_FOREST,
|
|
151
|
+
EcoClimateZone.TROPICAL_MONTANE: FuelCategory.UNKNOWN_TROPICAL_FOREST,
|
|
152
|
+
EcoClimateZone.TROPICAL_WET: FuelCategory.UNKNOWN_TROPICAL_FOREST,
|
|
153
|
+
EcoClimateZone.TROPICAL_MOIST: FuelCategory.UNKNOWN_TROPICAL_FOREST,
|
|
154
|
+
EcoClimateZone.TROPICAL_DRY: FuelCategory.UNKNOWN_TROPICAL_FOREST
|
|
174
155
|
},
|
|
175
156
|
BiomassCategory.NATURAL_FOREST: {
|
|
176
|
-
EcoClimateZone.WARM_TEMPERATE_MOIST:
|
|
177
|
-
EcoClimateZone.WARM_TEMPERATE_DRY:
|
|
178
|
-
EcoClimateZone.COOL_TEMPERATE_MOIST:
|
|
179
|
-
EcoClimateZone.COOL_TEMPERATE_DRY:
|
|
180
|
-
EcoClimateZone.BOREAL_MOIST:
|
|
181
|
-
EcoClimateZone.BOREAL_DRY:
|
|
182
|
-
EcoClimateZone.TROPICAL_MONTANE:
|
|
183
|
-
EcoClimateZone.TROPICAL_WET:
|
|
184
|
-
EcoClimateZone.TROPICAL_MOIST:
|
|
185
|
-
EcoClimateZone.TROPICAL_DRY:
|
|
157
|
+
EcoClimateZone.WARM_TEMPERATE_MOIST: FuelCategory.TEMPERATE_FOREST,
|
|
158
|
+
EcoClimateZone.WARM_TEMPERATE_DRY: FuelCategory.TEMPERATE_FOREST,
|
|
159
|
+
EcoClimateZone.COOL_TEMPERATE_MOIST: FuelCategory.TEMPERATE_FOREST,
|
|
160
|
+
EcoClimateZone.COOL_TEMPERATE_DRY: FuelCategory.TEMPERATE_FOREST,
|
|
161
|
+
EcoClimateZone.BOREAL_MOIST: FuelCategory.BOREAL_FOREST,
|
|
162
|
+
EcoClimateZone.BOREAL_DRY: FuelCategory.BOREAL_FOREST,
|
|
163
|
+
EcoClimateZone.TROPICAL_MONTANE: FuelCategory.NATURAL_TROPICAL_FOREST,
|
|
164
|
+
EcoClimateZone.TROPICAL_WET: FuelCategory.NATURAL_TROPICAL_FOREST,
|
|
165
|
+
EcoClimateZone.TROPICAL_MOIST: FuelCategory.NATURAL_TROPICAL_FOREST,
|
|
166
|
+
EcoClimateZone.TROPICAL_DRY: FuelCategory.NATURAL_TROPICAL_FOREST
|
|
186
167
|
},
|
|
187
168
|
BiomassCategory.PLANTATION_FOREST: {
|
|
188
|
-
EcoClimateZone.WARM_TEMPERATE_MOIST:
|
|
189
|
-
EcoClimateZone.WARM_TEMPERATE_DRY:
|
|
190
|
-
EcoClimateZone.COOL_TEMPERATE_MOIST:
|
|
191
|
-
EcoClimateZone.COOL_TEMPERATE_DRY:
|
|
192
|
-
EcoClimateZone.BOREAL_MOIST:
|
|
193
|
-
EcoClimateZone.BOREAL_DRY:
|
|
194
|
-
EcoClimateZone.TROPICAL_MONTANE:
|
|
195
|
-
EcoClimateZone.TROPICAL_WET:
|
|
196
|
-
EcoClimateZone.TROPICAL_MOIST:
|
|
197
|
-
EcoClimateZone.TROPICAL_DRY:
|
|
169
|
+
EcoClimateZone.WARM_TEMPERATE_MOIST: FuelCategory.TEMPERATE_FOREST,
|
|
170
|
+
EcoClimateZone.WARM_TEMPERATE_DRY: FuelCategory.TEMPERATE_FOREST,
|
|
171
|
+
EcoClimateZone.COOL_TEMPERATE_MOIST: FuelCategory.TEMPERATE_FOREST,
|
|
172
|
+
EcoClimateZone.COOL_TEMPERATE_DRY: FuelCategory.TEMPERATE_FOREST,
|
|
173
|
+
EcoClimateZone.BOREAL_MOIST: FuelCategory.BOREAL_FOREST,
|
|
174
|
+
EcoClimateZone.BOREAL_DRY: FuelCategory.BOREAL_FOREST,
|
|
175
|
+
EcoClimateZone.TROPICAL_MONTANE: FuelCategory.TERTIARY_TROPICAL_FOREST,
|
|
176
|
+
EcoClimateZone.TROPICAL_WET: FuelCategory.TERTIARY_TROPICAL_FOREST,
|
|
177
|
+
EcoClimateZone.TROPICAL_MOIST: FuelCategory.TERTIARY_TROPICAL_FOREST,
|
|
178
|
+
EcoClimateZone.TROPICAL_DRY: FuelCategory.TERTIARY_TROPICAL_FOREST
|
|
198
179
|
}
|
|
199
180
|
}
|
|
200
181
|
"""
|
|
@@ -202,26 +183,26 @@ Mapping from IPCC biomass category and eco-climate zone to natural vegetation fu
|
|
|
202
183
|
"""
|
|
203
184
|
|
|
204
185
|
_FUEL_CATEGORY_TO_EMISSION_CATEGORY = {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
186
|
+
FuelCategory.BOREAL_FOREST: EmissionCategory.OTHER_FOREST,
|
|
187
|
+
FuelCategory.EUCALYPT_FOREST: EmissionCategory.OTHER_FOREST,
|
|
188
|
+
FuelCategory.NATURAL_TROPICAL_FOREST: EmissionCategory.TROPICAL_FOREST,
|
|
189
|
+
FuelCategory.PRIMARY_TROPICAL_FOREST: EmissionCategory.TROPICAL_FOREST,
|
|
190
|
+
FuelCategory.SAVANNA_GRASSLAND_EARLY_DRY_SEASON_BURNS: EmissionCategory.SAVANNA_AND_GRASSLAND,
|
|
191
|
+
FuelCategory.SAVANNA_GRASSLAND_MID_TO_LATE_DRY_SEASON_BURNS: EmissionCategory.SAVANNA_AND_GRASSLAND,
|
|
192
|
+
FuelCategory.SAVANNA_WOODLAND_EARLY_DRY_SEASON_BURNS: EmissionCategory.SAVANNA_AND_GRASSLAND,
|
|
193
|
+
FuelCategory.SAVANNA_WOODLAND_MID_TO_LATE_DRY_SEASON_BURNS: EmissionCategory.SAVANNA_AND_GRASSLAND,
|
|
194
|
+
FuelCategory.SECONDARY_TROPICAL_FOREST: EmissionCategory.TROPICAL_FOREST,
|
|
195
|
+
FuelCategory.SHRUBLAND: EmissionCategory.SAVANNA_AND_GRASSLAND,
|
|
196
|
+
FuelCategory.TEMPERATE_FOREST: EmissionCategory.OTHER_FOREST,
|
|
197
|
+
FuelCategory.TERTIARY_TROPICAL_FOREST: EmissionCategory.TROPICAL_FOREST,
|
|
198
|
+
FuelCategory.UNKNOWN_TROPICAL_FOREST: EmissionCategory.TROPICAL_FOREST
|
|
218
199
|
}
|
|
219
200
|
"""
|
|
220
201
|
Mapping from natural vegetation fuel category to natural vegetation burning emission category.
|
|
221
202
|
"""
|
|
222
203
|
|
|
223
204
|
|
|
224
|
-
def _get_fuel_category(biomass_category: BiomassCategory, eco_climate_zone: EcoClimateZone) ->
|
|
205
|
+
def _get_fuel_category(biomass_category: BiomassCategory, eco_climate_zone: EcoClimateZone) -> FuelCategory:
|
|
225
206
|
"""
|
|
226
207
|
Get the IPCC (2019) natural vegetation fuel category that corresponds to a specific combination of biomass category
|
|
227
208
|
and eco-climate zone.
|
|
@@ -229,7 +210,7 @@ def _get_fuel_category(biomass_category: BiomassCategory, eco_climate_zone: EcoC
|
|
|
229
210
|
return _BIOMASS_CATEGORY_TO_FUEL_CATEGORY.get(biomass_category, {}).get(eco_climate_zone)
|
|
230
211
|
|
|
231
212
|
|
|
232
|
-
def
|
|
213
|
+
def get_emission_category(fuel_category: FuelCategory) -> EmissionCategory:
|
|
233
214
|
"""
|
|
234
215
|
Get the IPCC (2019) emission category that corresponds to a fuel category.
|
|
235
216
|
"""
|
|
@@ -291,7 +272,7 @@ def _get_sample_func(kwargs: dict) -> Callable:
|
|
|
291
272
|
)
|
|
292
273
|
|
|
293
274
|
|
|
294
|
-
def _get_fuel_factor(fuel_category:
|
|
275
|
+
def _get_fuel_factor(fuel_category: FuelCategory) -> dict:
|
|
295
276
|
"""
|
|
296
277
|
Retrieve distribution data for a specific fuel category.
|
|
297
278
|
"""
|
|
@@ -323,29 +304,24 @@ def _get_fuel_factor(fuel_category: _FuelCategory) -> dict:
|
|
|
323
304
|
)
|
|
324
305
|
|
|
325
306
|
|
|
326
|
-
def _get_emission_factor(term_id: _EmissionTermId, emission_category:
|
|
307
|
+
def _get_emission_factor(term_id: _EmissionTermId, emission_category: EmissionCategory) -> dict:
|
|
327
308
|
"""
|
|
328
309
|
Retrieve distribution data for a specific emission and emission category.
|
|
329
310
|
"""
|
|
330
|
-
|
|
331
|
-
LOOKUP_FILENAME = f"{LOOKUP_KEY}.csv"
|
|
311
|
+
TERM_TYPE = "emission"
|
|
332
312
|
TARGET_DATA = ("value", "sd")
|
|
333
313
|
|
|
334
|
-
row = term_id
|
|
335
314
|
column_root = f"IPCC_2019_G_EMITTED_PER_KG_DRY_MATTER_COMBUSTED_{emission_category.name}"
|
|
336
315
|
|
|
337
|
-
lookup = download_lookup(LOOKUP_FILENAME)
|
|
338
|
-
|
|
339
316
|
data = {
|
|
340
|
-
target:
|
|
341
|
-
|
|
317
|
+
target: get_lookup_value(
|
|
318
|
+
{"@id": term_id, "termType": TERM_TYPE},
|
|
319
|
+
f"{column_root}_{target}",
|
|
320
|
+
model=MODEL,
|
|
321
|
+
term=term_id
|
|
322
|
+
) for target in TARGET_DATA
|
|
342
323
|
}
|
|
343
324
|
|
|
344
|
-
for target in TARGET_DATA:
|
|
345
|
-
debugMissingLookup(
|
|
346
|
-
LOOKUP_FILENAME, "term.id", row, f"{column_root}_{target}", data.get(target), model=MODEL, term=term_id
|
|
347
|
-
)
|
|
348
|
-
|
|
349
325
|
return (
|
|
350
326
|
{
|
|
351
327
|
k: parsed for k, v in data.items() if (parsed := safe_parse_float(v, default=None)) is not None
|
|
@@ -355,7 +331,7 @@ def _get_emission_factor(term_id: _EmissionTermId, emission_category: _EmissionC
|
|
|
355
331
|
|
|
356
332
|
|
|
357
333
|
def _sample_fuel_factor(
|
|
358
|
-
fuel_category:
|
|
334
|
+
fuel_category: FuelCategory, *, seed: Union[int, np.random.Generator, None] = None
|
|
359
335
|
) -> npt.NDArray:
|
|
360
336
|
"""
|
|
361
337
|
Generate random samples from a fuel factor's distribution data.
|
|
@@ -367,7 +343,7 @@ def _sample_fuel_factor(
|
|
|
367
343
|
|
|
368
344
|
def _sample_emission_factor(
|
|
369
345
|
term_id: _EmissionTermId,
|
|
370
|
-
emission_category:
|
|
346
|
+
emission_category: EmissionCategory,
|
|
371
347
|
*,
|
|
372
348
|
seed: Union[int, np.random.Generator, None] = None
|
|
373
349
|
) -> npt.NDArray:
|
|
@@ -432,11 +408,11 @@ def _calc_burnt_fuel(area_converted: npt.NDArray, fuel_factor: npt.NDArray, frac
|
|
|
432
408
|
def _build_fuel_burnt_accumulator(
|
|
433
409
|
percent_burned: npt.ArrayLike,
|
|
434
410
|
eco_climate_zone: EcoClimateZone,
|
|
435
|
-
sample_fuel_factor_func: Callable[[
|
|
411
|
+
sample_fuel_factor_func: Callable[[FuelCategory], npt.NDArray]
|
|
436
412
|
):
|
|
437
413
|
"""
|
|
438
414
|
Build an `accumulate_fuel_burnt` function to reduce natural vegetation deltas into mass of fuel burnt per
|
|
439
|
-
`
|
|
415
|
+
`FuelCategory`.
|
|
440
416
|
|
|
441
417
|
Parameters
|
|
442
418
|
----------
|
|
@@ -444,7 +420,7 @@ def _build_fuel_burnt_accumulator(
|
|
|
444
420
|
The percentage of land converted using burning during a land use change event (percentage, 0-100%).
|
|
445
421
|
eco_climate_zone : EcoClimateZone
|
|
446
422
|
The eco-climate zone of the Site.
|
|
447
|
-
sample_fuel_factor_func : Callable[[
|
|
423
|
+
sample_fuel_factor_func : Callable[[FuelCategory], npt.NDArray]
|
|
448
424
|
Function to sample fuel factor parameter.
|
|
449
425
|
|
|
450
426
|
Returns
|
|
@@ -455,15 +431,15 @@ def _build_fuel_burnt_accumulator(
|
|
|
455
431
|
frac_burnt = percent_burned / 100
|
|
456
432
|
|
|
457
433
|
def accumulate_fuel_burnt(
|
|
458
|
-
result: dict[
|
|
459
|
-
) -> dict[
|
|
434
|
+
result: dict[FuelCategory, npt.NDArray], biomass_category: BiomassCategory, delta: float
|
|
435
|
+
) -> dict[FuelCategory, npt.NDArray]:
|
|
460
436
|
"""
|
|
461
|
-
Calculate the amount of fuel burnt when natural vegetation is lost. Accumulate fuel burnt by `
|
|
437
|
+
Calculate the amount of fuel burnt when natural vegetation is lost. Accumulate fuel burnt by `FuelCategory`.
|
|
462
438
|
|
|
463
439
|
Parameters
|
|
464
440
|
----------
|
|
465
|
-
result : dict[
|
|
466
|
-
A dict with the format `{
|
|
441
|
+
result : dict[FuelCategory, npt.NDArray]
|
|
442
|
+
A dict with the format `{FuelCategory: kg_fuel_burnt (npt.NDArray)}`.
|
|
467
443
|
biomass_category : BiomassCategory
|
|
468
444
|
A biomass category undergoing change during a LUC event.
|
|
469
445
|
delta : float
|
|
@@ -471,7 +447,7 @@ def _build_fuel_burnt_accumulator(
|
|
|
471
447
|
|
|
472
448
|
Returns
|
|
473
449
|
-------
|
|
474
|
-
dict[
|
|
450
|
+
dict[FuelCategory, npt.NDArray]
|
|
475
451
|
"""
|
|
476
452
|
|
|
477
453
|
fuel_category = _get_fuel_category(biomass_category, eco_climate_zone)
|
|
@@ -560,12 +536,12 @@ def _compile_inventory(
|
|
|
560
536
|
land_cover_grouped = group_nodes_by_year(land_cover_nodes)
|
|
561
537
|
percent_burned = get_percent_burned(site)
|
|
562
538
|
|
|
563
|
-
@lru_cache(maxsize=len(
|
|
539
|
+
@lru_cache(maxsize=len(FuelCategory))
|
|
564
540
|
def sample_fuel_factor(*args):
|
|
565
541
|
"""Fuel factors should not be re-sampled between years, so cache results."""
|
|
566
542
|
return _sample_fuel_factor(*args, seed=rng)
|
|
567
543
|
|
|
568
|
-
@lru_cache(maxsize=len(EMISSION_TERM_IDS)*len(
|
|
544
|
+
@lru_cache(maxsize=len(EMISSION_TERM_IDS)*len(EmissionCategory))
|
|
569
545
|
def sample_emission_factor(*args):
|
|
570
546
|
"""Emission factors should not be re-sampled between years, so cache results."""
|
|
571
547
|
return _sample_emission_factor(*args, seed=rng)
|
|
@@ -610,7 +586,7 @@ def _compile_inventory(
|
|
|
610
586
|
|
|
611
587
|
annual_emissions = {
|
|
612
588
|
term_id: sum(
|
|
613
|
-
_calc_emission(amount, sample_emission_factor(term_id,
|
|
589
|
+
_calc_emission(amount, sample_emission_factor(term_id, get_emission_category(fuel_category)))
|
|
614
590
|
for fuel_category, amount in fuel_burnt_per_category.items()
|
|
615
591
|
) for term_id in EMISSION_TERM_IDS
|
|
616
592
|
}
|
|
@@ -890,7 +866,7 @@ def run(cycle: dict):
|
|
|
890
866
|
Returns
|
|
891
867
|
-------
|
|
892
868
|
list[dict]
|
|
893
|
-
A list of HESTIA [Emission](https://www.hestia.earth/schema/Emission) nodes with `term
|
|
869
|
+
A list of HESTIA [Emission](https://www.hestia.earth/schema/Emission) nodes with `term.@id` =
|
|
894
870
|
`ch4ToAirNaturalVegetationBurning` **OR** `coToAirNaturalVegetationBurning` **OR**
|
|
895
871
|
`n2OToAirNaturalVegetationBurningDirect` **OR** `noxToAirNaturalVegetationBurning`.
|
|
896
872
|
"""
|
|
@@ -219,7 +219,7 @@ def _pastureGrass_key_property_value(column: dict, **log_args):
|
|
|
219
219
|
term_id = practice_input_id(practice)
|
|
220
220
|
term = download_hestia(term_id)
|
|
221
221
|
value = list_sum(practice.get('value', [0]))
|
|
222
|
-
lookup_value = node_property_lookup_value(MODEL, term, column, default=0, **log_args)
|
|
222
|
+
lookup_value = node_property_lookup_value(MODEL, term_id, term.get('termType'), column, default=0, **log_args)
|
|
223
223
|
return (lookup_value, value)
|
|
224
224
|
return get_value
|
|
225
225
|
|