hestia-earth-models 0.64.11__py3-none-any.whl → 0.64.12__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.

Files changed (25) hide show
  1. hestia_earth/models/cycle/concentrateFeed.py +31 -19
  2. hestia_earth/models/faostat2018/utils.py +72 -12
  3. hestia_earth/models/hestia/__init__.py +13 -0
  4. hestia_earth/models/hestia/landCover.py +725 -0
  5. hestia_earth/models/ipcc2019/animal/fatContent.py +1 -1
  6. hestia_earth/models/ipcc2019/animal/milkYieldPerAnimal.py +91 -0
  7. hestia_earth/models/ipcc2019/animal/trueProteinContent.py +1 -1
  8. hestia_earth/models/ipcc2019/animal/utils.py +17 -12
  9. hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py +8 -4
  10. hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py +7 -3
  11. hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py +45 -3
  12. hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py +7 -3
  13. hestia_earth/models/mocking/search-results.json +914 -914
  14. hestia_earth/models/utils/lookup.py +2 -1
  15. hestia_earth/models/version.py +1 -1
  16. {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.12.dist-info}/METADATA +1 -1
  17. {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.12.dist-info}/RECORD +25 -18
  18. tests/models/faostat2018/test_faostat_utils.py +84 -0
  19. tests/models/hestia/__init__.py +0 -0
  20. tests/models/hestia/test_landCover.py +209 -0
  21. tests/models/ipcc2019/animal/test_milkYieldPerAnimal.py +21 -0
  22. tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py +48 -1
  23. {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.12.dist-info}/LICENSE +0 -0
  24. {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.12.dist-info}/WHEEL +0 -0
  25. {hestia_earth_models-0.64.11.dist-info → hestia_earth_models-0.64.12.dist-info}/top_level.txt +0 -0
@@ -104,7 +104,8 @@ def _aware_factor_value(model: str, term_id: str, lookup_name: str, aware_id: st
104
104
  _ALLOW_ALL = 'all'
105
105
 
106
106
 
107
- def _is_site(site: dict): return site.get('@type', site.get('type')) == SchemaType.SITE.value
107
+ def _is_site(site: dict):
108
+ return site.get('@type', site.get('type')) == SchemaType.SITE.value if site else None
108
109
 
109
110
 
110
111
  def _get_sites(node: dict):
@@ -1 +1 @@
1
- VERSION = '0.64.11'
1
+ VERSION = '0.64.12'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-models
3
- Version: 0.64.11
3
+ Version: 0.64.12
4
4
  Summary: HESTIA's set of modules for filling gaps in the activity data using external datasets (e.g. populating soil properties with a geospatial dataset using provided coordinates) and internal lookups (e.g. populating machinery use from fuel use). Includes rules for when gaps should be filled versus not (e.g. never gap fill yield, gap fill crop residue if yield provided etc.).
5
5
  Home-page: https://gitlab.com/hestia-earth/hestia-engine-models
6
6
  Author: HESTIA Team
@@ -4,7 +4,7 @@ hestia_earth/models/cache_sites.py,sha256=KQp9cUKE-aIcYJoMWEtKFYS8gBFfsx5LKQhqoW
4
4
  hestia_earth/models/log.py,sha256=DbfNcGzaC5hzkuMDxQqW6XYoNBI4Uxw4SIoOYoZA6og,3474
5
5
  hestia_earth/models/preload_requests.py,sha256=Ds7eJqKfbiiaKqpRr69Z_GKUpYtP1j7XZKZX4Y9z7lE,1348
6
6
  hestia_earth/models/requirements.py,sha256=eU4yT443fx7BnaokhrLB_PCizJI7Y6m4auyo8vQauNg,17363
7
- hestia_earth/models/version.py,sha256=mmvF4B2rPzCJ3IxZSO6jAz7xoK7q4-z-FZYTiigDRm4,20
7
+ hestia_earth/models/version.py,sha256=gqX4DFm9GQhSbAelUK8yrfNUHfEeS-Id8fI9wY0Op4Q,20
8
8
  hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
9
9
  hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=tnGxBmJdPfPFfehLUQcefEqy1lHvzsSpx_s7O8nf3Zs,4412
10
10
  hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=BPjnWmg73i_OxM2ouCdMTWZtPIqyoUAXrvutntyteE0,3390
@@ -39,7 +39,7 @@ hestia_earth/models/cycle/__init__.py,sha256=VowO3kOHb0LpURsljNaJsYO7s6vgjhul6bF
39
39
  hestia_earth/models/cycle/aboveGroundCropResidueTotal.py,sha256=9swq4YEeJQ2YjVOmghgBYWkMZWdNU4MKCUBY5FsmBSU,3088
40
40
  hestia_earth/models/cycle/coldCarcassWeightPerHead.py,sha256=fQ7huuxyS5PQkRmR_tRCOz9rV3LJwLfLQJjH_TcTz6k,2955
41
41
  hestia_earth/models/cycle/coldDressedCarcassWeightPerHead.py,sha256=k0xg5SIfJGwEKteFr2Fh-lh8yDC_sqQw_lBnnfwl9zU,3069
42
- hestia_earth/models/cycle/concentrateFeed.py,sha256=ly7TyEnw46D7AmFCftO8GWFDu-4_lFnqeDcoqLZCCRA,6219
42
+ hestia_earth/models/cycle/concentrateFeed.py,sha256=e9oaCoRNfEZEDbalxq7L2Z5rYXpyUdR84sGHi4efm2M,6701
43
43
  hestia_earth/models/cycle/cropResidueManagement.py,sha256=QTRCCFu9VvD_a3_8aAj216vsuhAJEhlAwTJH7ifMkDo,2237
44
44
  hestia_earth/models/cycle/croppingIntensity.py,sha256=44CgDqXg9CBRfTPYTyOleQT-M4_tsQgPba-0vjjk_C4,1770
45
45
  hestia_earth/models/cycle/cycleDuration.py,sha256=ccODF5CJBEd55-CMttCr0eI4uH7OoRvYJZjcth09QMg,3193
@@ -157,7 +157,7 @@ hestia_earth/models/faostat2018/landTransformationFromCropland20YearAverage.py,s
157
157
  hestia_earth/models/faostat2018/liveweightPerHead.py,sha256=flI3_TyG-7xoWp6cU6pZAFiXyHyFkfRz7Lmb7cQAffI,5140
158
158
  hestia_earth/models/faostat2018/readyToCookWeightPerHead.py,sha256=b1_GZQ3oFl88w6TY5DqLSqXNaYX6TcRBK4R9M2cWSjM,3165
159
159
  hestia_earth/models/faostat2018/seed.py,sha256=ts9PKs9UnZnJ9nPFlL7etL1Qb9uIWIES8Mz8W7FWbOw,2917
160
- hestia_earth/models/faostat2018/utils.py,sha256=Ud2vu_8ze5VFfeBFBzUKdJTWRfxVJO4VUTdgwaLJU-w,3715
160
+ hestia_earth/models/faostat2018/utils.py,sha256=gxs7tULyBDhkvB2NuI3RnYTYzm75vEw1B2dDf48D_R8,5741
161
161
  hestia_earth/models/faostat2018/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
162
162
  hestia_earth/models/faostat2018/product/price.py,sha256=X7Zxa-rXthzYdgw2lzybbHc-oKGE5nyXpBn-BfZC_7w,7753
163
163
  hestia_earth/models/frischknechtEtAl2000/__init__.py,sha256=Fixyy9UwoCGP5-MHyJu_ctS40SQ2imfvZo8a547029U,421
@@ -199,6 +199,8 @@ hestia_earth/models/globalCropWaterModel2008/rootingDepth.py,sha256=pajS-6UWxqIq
199
199
  hestia_earth/models/haversineFormula/__init__.py,sha256=o155nR-XI67iCSBVNYIu4sPRIF3C2Y1NnUZ6lfpi0Do,417
200
200
  hestia_earth/models/haversineFormula/transport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
201
201
  hestia_earth/models/haversineFormula/transport/distance.py,sha256=163KrmKzlEQuKYT1ZvpPgmKlv_-mmvxp0A1_uKya99w,4203
202
+ hestia_earth/models/hestia/__init__.py,sha256=o5vAmPzSaK9XPgL8GCne3-lugfCOgZhHELYolNgqyyY,407
203
+ hestia_earth/models/hestia/landCover.py,sha256=PRQ4-7-EvDrhngvwtxHoNOfE4oY7zlfqsZMVI6Wzaes,28336
202
204
  hestia_earth/models/hyde32/__init__.py,sha256=hSOwDiK0M0NfmQbW_J7O_SZa8IsJMgITSHSVMsDS4KI,407
203
205
  hestia_earth/models/hyde32/landTransformationFromCropland100YearAverageDuringCycle.py,sha256=7ZqhExZORiYIzvkQhLhPdTPzyY2NnSKrat76poGn5tc,2392
204
206
  hestia_earth/models/hyde32/landTransformationFromCropland20YearAverageDuringCycle.py,sha256=RDMzmxz236nMSd5IYASXFMk8wL4HyeMi2zNdhhjkTs0,2388
@@ -253,11 +255,11 @@ hestia_earth/models/ipcc2019/ch4ToAirAquacultureSystems.py,sha256=q6yyEiYQhHJ2Vy
253
255
  hestia_earth/models/ipcc2019/ch4ToAirEntericFermentation.py,sha256=7rA9thwYXbJkSFTEl71AbFVQfBz0CaJfblpJpO9s6D8,11611
254
256
  hestia_earth/models/ipcc2019/ch4ToAirExcreta.py,sha256=eY_yb7ncTb_2HoUUgXZnnRHiybTXYj_DTe3CmDzD3fY,6717
255
257
  hestia_earth/models/ipcc2019/ch4ToAirFloodedRice.py,sha256=TJ4J7VA5n4RPrJYZQeR3lc3ZoCw7T1E5Cb1XJewr834,7331
256
- hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py,sha256=8dy_earC86duElYWv2Tmlzc20NodNADjXjV6Wto_nys,6466
257
- hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py,sha256=1IImP8z9tYHp8WUawceKW4gAN0ajm36wtD6h0wxTOzI,6517
258
- hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py,sha256=8f8hm4JYsV6mmRI-lSwkca874N_h7JxxdY7nQNS_Z1A,53872
258
+ hestia_earth/models/ipcc2019/co2ToAirAboveGroundBiomassStockChange.py,sha256=fefPcxy7TTG-33dgZecDppMroUAmKoluhomyLuRqQiU,6545
259
+ hestia_earth/models/ipcc2019/co2ToAirBelowGroundBiomassStockChange.py,sha256=l5Mrb8non9JjQhpWMzqHHK7FAjYPuWUzIwa08zdBUpo,6595
260
+ hestia_earth/models/ipcc2019/co2ToAirCarbonStockChange_utils.py,sha256=7A4wqVDmzVWaBjxG02TP8MMnqP_IQ0p8XX82nTE8XQE,55461
259
261
  hestia_earth/models/ipcc2019/co2ToAirLimeHydrolysis.py,sha256=7z0zdqiiWQwkyJCgSNMoK2mft3cJkTRlqwKrMuSKdWI,2454
260
- hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py,sha256=Ptmritqlmgl_16PpcxzOMU_CXr3uOnc-myuBPFrBpIo,6535
262
+ hestia_earth/models/ipcc2019/co2ToAirSoilOrganicCarbonStockChange.py,sha256=1yC99dH3ZQC3PX_ppLhDxzECTTvGwiRSGxkFudEzKBw,6613
261
263
  hestia_earth/models/ipcc2019/co2ToAirUreaHydrolysis.py,sha256=Ofld5SuRKndcKB3FFFoUdzSgNq-gc4kmiNyyrPKQ3Io,3580
262
264
  hestia_earth/models/ipcc2019/croppingDuration.py,sha256=-CesZ2cNDOQoU3QyVFnSWYO-6-JXxuhRDQoHoxTawDA,3228
263
265
  hestia_earth/models/ipcc2019/ligninContent.py,sha256=Qh-UH4lv1TIf7wWlbAPwIZZHxzbbmQgND3m15pt5Si8,7285
@@ -286,13 +288,14 @@ hestia_earth/models/ipcc2019/pastureGrass.py,sha256=Hhm9szzsL3otuo-V6fQ_cNyDbG0d
286
288
  hestia_earth/models/ipcc2019/pastureGrass_utils.py,sha256=nL31uS3c77PH_5nA2E2MvB1NS2mMvhD341taGl5YWNE,13842
287
289
  hestia_earth/models/ipcc2019/utils.py,sha256=MSDMu15D9DnilFUgi4_6jYXC0FaKso3OODauGTMB6hs,6229
288
290
  hestia_earth/models/ipcc2019/animal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
289
- hestia_earth/models/ipcc2019/animal/fatContent.py,sha256=iVDMPjuy_-oGhmWaylsoCMw0qdkI5jDdqn4uzbq4D4Q,999
291
+ hestia_earth/models/ipcc2019/animal/fatContent.py,sha256=T-wWzxzPdy4pexS8ivQSeH9Z6U6qRGYfCiEwQDujcww,1003
290
292
  hestia_earth/models/ipcc2019/animal/liveweightGain.py,sha256=UElmAdB4yQEFAOT5RrURn0Yt7U3gB2qiCWvNXyLk8Hw,971
291
293
  hestia_earth/models/ipcc2019/animal/liveweightPerHead.py,sha256=cq88VTxPYVPyEr2NLPb0Zmmppn_eMp9Xtw6Nxnta4-M,984
294
+ hestia_earth/models/ipcc2019/animal/milkYieldPerAnimal.py,sha256=WknnXH2BmY4PFmYdF0ZAb_vl74da4DkObR7Q5dnkhRo,2752
292
295
  hestia_earth/models/ipcc2019/animal/pastureGrass.py,sha256=4vs-KIlCKQhU1EpX0BFlVAQrh1szm154AnrPDs13oE4,12212
293
296
  hestia_earth/models/ipcc2019/animal/pregnancyRateTotal.py,sha256=MWPnuT4WeKJCGjJ_DAJnYelsX2Ld0C5e8eN__0Ws0E0,982
294
- hestia_earth/models/ipcc2019/animal/trueProteinContent.py,sha256=0VYI2Yg_GF5qvuxazZ3KUa03vAYcbpNLnzCOjUaG5ZI,1019
295
- hestia_earth/models/ipcc2019/animal/utils.py,sha256=9EyLCOpBGkpa97VVcFbl1tRlDdJHHiy8lI7tLc_y5BE,4439
297
+ hestia_earth/models/ipcc2019/animal/trueProteinContent.py,sha256=9hOg5KAFQ6Q-2_5h8pduYiYg9QBr22UnHdJYmkh8qi0,1023
298
+ hestia_earth/models/ipcc2019/animal/utils.py,sha256=HPOjdJGUxn4Ls4jnr0kD5_w-JrzG1C7_cwdMpCCA1kk,4514
296
299
  hestia_earth/models/ipcc2019/animal/weightAtMaturity.py,sha256=4Pp14_40NYcPqqBUnkqYVkpJLcDzZ70tlM-stte7JsQ,3055
297
300
  hestia_earth/models/ipcc2021/__init__.py,sha256=VTgGFKhwMmk_nuI1RRq0in27fHYVPBonlXlPK00K8no,409
298
301
  hestia_earth/models/ipcc2021/gwp100.py,sha256=EQ-OBQrahSgMBFtGregiNlbm3DHVwr67o4e29Z5Gns8,1039
@@ -407,7 +410,7 @@ hestia_earth/models/linkedImpactAssessment/utils.py,sha256=dGwGc2d-8_WQElTpfyPmz
407
410
  hestia_earth/models/mocking/__init__.py,sha256=n3Fkkrvh8zHNWiJZmnfQ7WZ91JRzAO9P6pSG1JpwtXo,687
408
411
  hestia_earth/models/mocking/build_mock_search.py,sha256=p15ccEUmkmLp1RiGNznxMz3OFHbI8P1-29ExuohiQN8,1355
409
412
  hestia_earth/models/mocking/mock_search.py,sha256=ccFe_WrI73JElFmxp4hPNLCX7eeU--lBC1JFR901KJY,1069
410
- hestia_earth/models/mocking/search-results.json,sha256=NPkaq_ZNRSrVbLRkXkPWP5skxL8Ycwx1lJE92O02Z84,101693
413
+ hestia_earth/models/mocking/search-results.json,sha256=Acsrm2K9NBM4ESH-qFAy_5BY6jRWC_OKiMuZFktOCnc,101690
411
414
  hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
412
415
  hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=Qt-mel4dkhK6N5uUOutNOinCTFjbjtGzITaaI0LvYc4,2396
413
416
  hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=JT0RybbvWVlo01FO8K0Yj41HrEaJT3Kj1xfayr2X-xw,2315
@@ -593,7 +596,7 @@ hestia_earth/models/utils/inorganicFertiliser.py,sha256=_dLBY-otGkLr8PobR5dQ89bF
593
596
  hestia_earth/models/utils/input.py,sha256=gsVFKTC9WF8dO6YAg_-H_GAOQTnvAr49Ox5-eTH8zf8,5145
594
597
  hestia_earth/models/utils/landCover.py,sha256=8-nfynzCx9gf9YfhpuoH6Cn4kQwWFpYA5RmoGW-0ETE,300
595
598
  hestia_earth/models/utils/liveAnimal.py,sha256=GnajBPZw5d94raf80KtLloaOqlfqGAPwUtP9bRlGWeE,1754
596
- hestia_earth/models/utils/lookup.py,sha256=xZPIaRYWBI4qXw8cGOFqYCXOR5h_sHaU-CdBoiHvkpg,8495
599
+ hestia_earth/models/utils/lookup.py,sha256=uEP5v4atNkY5FLMopsuBncALOmsyhFe4lNtZvUhcQRM,8517
597
600
  hestia_earth/models/utils/measurement.py,sha256=izEiPszUcPA22zaIc0OuF7Yk82JWu5cxi0Sbz_9YgBo,11142
598
601
  hestia_earth/models/utils/organicFertiliser.py,sha256=2HY-a0EBzUw4DkEAXClLMXVCEZTKYf0BwFHBo7lQ5Tg,363
599
602
  hestia_earth/models/utils/pesticideAI.py,sha256=eK3HTfu5-I-HAQ0UV3ikpbZgtdA3s99RX2h9u77diFA,2361
@@ -749,6 +752,7 @@ tests/models/fantkeEtAl2016/test_damageToHumanHealthParticulateMatterFormation.p
749
752
  tests/models/faostat2018/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
750
753
  tests/models/faostat2018/test_coldCarcassWeightPerHead.py,sha256=RImhLygwrJ2RoEHjDwhuymvLEitOtNleP_lLoBhiNOs,1736
751
754
  tests/models/faostat2018/test_coldDressedCarcassWeightPerHead.py,sha256=hZVKMtf-F5Iz7igZVahDJoqzfm2VtcIlwWBPCry7kqw,1594
755
+ tests/models/faostat2018/test_faostat_utils.py,sha256=DFVQHPhOmD0dsv9bNjv-zAHXpYJeJYpJsffy7MmXkh4,2301
752
756
  tests/models/faostat2018/test_landTransformationFromCropland100YearAverage.py,sha256=AkDXj4qNKgbu5xRbw9u_cUibnVSnAK1CN8pc4IjK9fk,1263
753
757
  tests/models/faostat2018/test_landTransformationFromCropland20YearAverage.py,sha256=L03Xh1QbbXc9yGdMoHGNmyCpu9WKANNiEE73NoBSqxk,1260
754
758
  tests/models/faostat2018/test_liveweightPerHead.py,sha256=5Z0Fw7iT3-REg8QjK8tUpWs5bUIG4fjWDM7SEOSYBcw,4799
@@ -795,6 +799,8 @@ tests/models/globalCropWaterModel2008/test_rootingDepth.py,sha256=CkRDlsDqWtTNwA
795
799
  tests/models/haversineFormula/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
796
800
  tests/models/haversineFormula/transport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
797
801
  tests/models/haversineFormula/transport/test_distance.py,sha256=hqzIOA1nGao8uiBE16J0ou52McwV4w30ZLpEAqtfi9k,970
802
+ tests/models/hestia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
803
+ tests/models/hestia/test_landCover.py,sha256=nFaDQI6JzfgvSZhTmI-4f1bfm1Mi1G7E17C5CgLvSgI,5931
798
804
  tests/models/hyde32/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
799
805
  tests/models/hyde32/test_landTransformationFromCropland100YearAverageDuringCycle.py,sha256=tOwcToAZLgIvVEx0i3S67EDaTBi_gXKy-XZCnw1Akl8,797
800
806
  tests/models/hyde32/test_landTransformationFromCropland20YearAverageDuringCycle.py,sha256=Fw1goOLe6xPUA7J65MojAyvuEBWnsypHzfjopER9wWo,796
@@ -853,7 +859,7 @@ tests/models/ipcc2019/test_co2ToAirAboveGroundBiomassStockChange.py,sha256=R4dRh
853
859
  tests/models/ipcc2019/test_co2ToAirBelowGroundBiomassStockChange.py,sha256=rnwuLr77uZmQX4AxFU9lN1IGUwEcVceZ1YQ9Xg-tOyA,2982
854
860
  tests/models/ipcc2019/test_co2ToAirCarbonStockChange_utils.py,sha256=wCEtrbMl6zef8V-n_Ci_rtlQAlfuKm3khUVltr8eAcc,2173
855
861
  tests/models/ipcc2019/test_co2ToAirLimeHydrolysis.py,sha256=e5iuZ-kQNEVih0ZRgRPWqaUtXcLpfkoU7sQypbqA9_Y,1345
856
- tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py,sha256=30NGC8OKlH_1l0Zy7aMNkaywTx-g0zGsga0nDFOmUmw,2993
862
+ tests/models/ipcc2019/test_co2ToAirSoilOrganicCarbonStockChange.py,sha256=BxIV_T_o-m2w4rdrcCZDjzP2eV8xNOAPN__4FxdzZYY,4432
857
863
  tests/models/ipcc2019/test_co2ToAirUreaHydrolysis.py,sha256=MmtEME0xjsa3KojFk_fxOLK6RZM_6p5HIpY2DOFHVu4,1530
858
864
  tests/models/ipcc2019/test_croppingDuration.py,sha256=gLRXeR6Tqa7ciD9KTRfsIflSeIIWT2iOpZMdcxAQla4,1871
859
865
  tests/models/ipcc2019/test_ligninContent.py,sha256=eIKEN__ab-0R52EhlhPSBiHnmTl6xOf1XbI33O-W9A4,4146
@@ -883,6 +889,7 @@ tests/models/ipcc2019/animal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
883
889
  tests/models/ipcc2019/animal/test_fatContent.py,sha256=Emp8jGudRGA_dJaLMR5Jxsv3Gc57rMAnP0CDqswrmlM,775
884
890
  tests/models/ipcc2019/animal/test_liveweightGain.py,sha256=KmRZyrjrXZcgff1QFtfu1WphNuJW_nHx1GguD8xB2ls,779
885
891
  tests/models/ipcc2019/animal/test_liveweightPerHead.py,sha256=nfNAcUEIPQeKyjKYttI5W6hiHBMXLZ9Vbz0nfj81ZvA,782
892
+ tests/models/ipcc2019/animal/test_milkYieldPerAnimal.py,sha256=98rslTxLk92smiUfxRfxB6kjmQAm6085GV9NqWCGpVo,713
886
893
  tests/models/ipcc2019/animal/test_pastureGrass.py,sha256=vuwd7WPUKIWaYREv_UmEa8m9llZSr0OclDsmnSDtHOQ,1987
887
894
  tests/models/ipcc2019/animal/test_pregnancyRateTotal.py,sha256=3M4cpH0rM0fLR86bwtBQbkUhuflj0ebaQpPgHtAFZxo,783
888
895
  tests/models/ipcc2019/animal/test_trueProteinContent.py,sha256=3O2w_PsVEki_piIHO-Wa6m28f5SAHWHsSk27nYDQDuM,783
@@ -1177,8 +1184,8 @@ tests/models/utils/test_term.py,sha256=M5Sa26v2gzQYbZ4H_fo7DspnaCx__-WtL-MULGapC
1177
1184
  tests/models/utils/test_time_series.py,sha256=LMhRPf8rp3nAriKAC-2K3FDkrMWntRTUUCERw7Lt68g,2686
1178
1185
  tests/models/webbEtAl2012AndSintermannEtAl2012/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1179
1186
  tests/models/webbEtAl2012AndSintermannEtAl2012/test_nh3ToAirOrganicFertiliser.py,sha256=qi2FNXS5Af2WDtm7nq_FsprH3BfCF0XxnE0XHmC4aIY,2244
1180
- hestia_earth_models-0.64.11.dist-info/LICENSE,sha256=AC7h7GAgCZGJK_Tzh6LUCrML9gQEfowWwecEw2w54QM,1154
1181
- hestia_earth_models-0.64.11.dist-info/METADATA,sha256=dHqLbhRCLo0yEMPj7QmdMzk5k4G1mjGNeJc4kCf32l0,3345
1182
- hestia_earth_models-0.64.11.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
1183
- hestia_earth_models-0.64.11.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
1184
- hestia_earth_models-0.64.11.dist-info/RECORD,,
1187
+ hestia_earth_models-0.64.12.dist-info/LICENSE,sha256=AC7h7GAgCZGJK_Tzh6LUCrML9gQEfowWwecEw2w54QM,1154
1188
+ hestia_earth_models-0.64.12.dist-info/METADATA,sha256=_BsGHskrQW34lz3Y_Q3NQVbMREseBV4Ea5Oof4UzefA,3345
1189
+ hestia_earth_models-0.64.12.dist-info/WHEEL,sha256=bFJAMchF8aTQGUgMZzHJyDDMPTO3ToJ7x23SLJa1SVo,92
1190
+ hestia_earth_models-0.64.12.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
1191
+ hestia_earth_models-0.64.12.dist-info/RECORD,,
@@ -0,0 +1,84 @@
1
+ from unittest.mock import patch
2
+
3
+ import numpy
4
+
5
+ from hestia_earth.models.faostat2018.utils import (get_sum_of_columns, MODEL, get_land_ratio,
6
+ get_change_in_harvested_area_for_crop)
7
+ from tests.utils import fixtures_path
8
+
9
+ CLASS_PATH = f"hestia_earth.models.{MODEL}.utils"
10
+ fixtures_folder = f"{fixtures_path}/{MODEL}/utils"
11
+
12
+
13
+ def _afg_download_fixture():
14
+ with open(f"{fixtures_folder}/gadm-afg.csv") as f:
15
+ afg_lookup = numpy.recfromcsv(
16
+ fname=f,
17
+ missing_values="",
18
+ filling_values="",
19
+ delimiter=",",
20
+ encoding="utf-8"
21
+ )
22
+ return afg_lookup
23
+
24
+
25
+ def test_get_sum_of_columns():
26
+ result = get_sum_of_columns(
27
+ lookup=_afg_download_fixture(),
28
+ country="GADM-AFG",
29
+ year=1975,
30
+ columns_list=["Arable land", "Permanent crops"]
31
+ )
32
+ assert result == 8050.3
33
+
34
+
35
+ def test_check_sums_for_columns():
36
+ """
37
+ Check that the values of Arable and Permanent add up to Cropland, at least for AFG
38
+ """
39
+ for year in range(1961, 2021):
40
+ sum_arab_perm = get_sum_of_columns(
41
+ lookup=_afg_download_fixture(),
42
+ country="GADM-AFG",
43
+ year=year,
44
+ columns_list=["Arable land", "Permanent crops"]
45
+ )
46
+
47
+ cropland_value = get_sum_of_columns(
48
+ lookup=_afg_download_fixture(),
49
+ country="GADM-AFG",
50
+ year=year,
51
+ columns_list=["Cropland"]
52
+ )
53
+ assert sum_arab_perm == cropland_value
54
+
55
+
56
+ @patch(f"{CLASS_PATH}.download_lookup")
57
+ def test_get_land_ratio(mock_lookup):
58
+ mock_lookup.return_value = _afg_download_fixture()
59
+ result = get_land_ratio(
60
+ country="GADM-AFG",
61
+ start_year=1990,
62
+ end_year=2010,
63
+ first_column="Forest land",
64
+ second_column="Cropland"
65
+ )
66
+
67
+ assert result == (-123.0, 0.0, -123.0)
68
+
69
+
70
+ def test_get_harvested_area_for_crop():
71
+ result = get_change_in_harvested_area_for_crop(
72
+ country_id="GADM-AFG",
73
+ start_year=1990,
74
+ end_year=1992,
75
+ crop_name="Wheat"
76
+ )
77
+ assert result == 30000.0
78
+
79
+ result = get_change_in_harvested_area_for_crop(
80
+ country_id="GADM-AFG",
81
+ start_year=2019,
82
+ crop_name="Wheat"
83
+ )
84
+ assert result == 2334000
File without changes
@@ -0,0 +1,209 @@
1
+ import csv
2
+ import json
3
+ import numpy as np
4
+ import pytest
5
+ from unittest.mock import patch
6
+
7
+ from tests.utils import fixtures_path
8
+ from hestia_earth.models.faostat2018.utils import MODEL as FAOSTAT_MODEL
9
+ from hestia_earth.models.hestia.landCover import (
10
+ MODEL, MODEL_KEY, get_changes, _estimate_maximum_forest_change,
11
+ run, site_area_sum_to_100, _get_sums_of_crop_expansion
12
+ )
13
+
14
+ CLASS_PATH = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
15
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{MODEL_KEY}"
16
+
17
+ FAOSTAT_CLASS_PATH = f"hestia_earth.models.{FAOSTAT_MODEL}.utils"
18
+ faostat_fixtures_folder = f"{fixtures_path}/{FAOSTAT_MODEL}/utils"
19
+
20
+ BRAZIL_SITE = {
21
+ "@type": "Site",
22
+ "id": "Brazil-example",
23
+ "country": {
24
+ "name": "Brazil",
25
+ "type": "Term"
26
+ },
27
+ "siteType": "cropland",
28
+ "management": [
29
+ {
30
+ "term": {
31
+ "@id": "maizePlant",
32
+ "name": "Maize plant",
33
+ "type": "Term",
34
+ "termType": "landCover"
35
+ },
36
+ "value": 100,
37
+ "startDate": "2010-01-01",
38
+ "endDate": "2010-12-31",
39
+ "type": "Management"
40
+ }
41
+ ]
42
+ }
43
+
44
+
45
+ def recfromcsv_mod(filename, **kwargs):
46
+ def rewrite_csv_as_tab(csv_name):
47
+ with open(csv_name, newline='') as fp:
48
+ for row in csv.reader(fp, delimiter=","):
49
+ yield "\t".join(row)
50
+ return np.recfromcsv(
51
+ rewrite_csv_as_tab(filename), delimiter="\t", encoding=None, **kwargs)
52
+
53
+
54
+ def _download_fixture(filepath: str):
55
+ return recfromcsv_mod(filename=filepath)
56
+
57
+
58
+ @patch(f"{FAOSTAT_CLASS_PATH}.download_lookup")
59
+ def test_get_changes(mock_lookup):
60
+ mock_lookup.return_value = _download_fixture(f"{faostat_fixtures_folder}/gadm-afg.csv")
61
+ result = get_changes(
62
+ country_id="GADM-AFG",
63
+ end_year=2010
64
+ )
65
+ assert (
66
+ result == {
67
+ "Arable land": -117.0,
68
+ "Cropland": -123.0,
69
+ "Forest land": 0,
70
+ "Other land": 123.0,
71
+ "Land area": 0,
72
+ "Permanent crops": -6.0,
73
+ "Permanent meadows and pastures": 0,
74
+ "Total agricultural change": -123.0
75
+ }
76
+ )
77
+
78
+
79
+ @pytest.mark.parametrize(
80
+ "description,inputs,expected_output",
81
+ [
82
+ (
83
+ "Annual cropland gain from forest",
84
+ {
85
+ "forest_change": -1000,
86
+ "total_cropland_change": 1000,
87
+ "pasture_change": 0,
88
+ "total_agricultural_change": 1000
89
+ },
90
+ -1000
91
+ ),
92
+ (
93
+ "Pasture gain from forest",
94
+ {
95
+ "forest_change": -1000,
96
+ "total_cropland_change": 0,
97
+ "pasture_change": 1000,
98
+ "total_agricultural_change": 1000
99
+ },
100
+ -1000
101
+ ),
102
+ (
103
+ "Brazil",
104
+ {
105
+ "forest_change": -77317,
106
+ "total_cropland_change": 5201,
107
+ "pasture_change": -8267,
108
+ "total_agricultural_change": -3066
109
+ },
110
+ -5201
111
+ ),
112
+ (
113
+ "Argentina",
114
+ {
115
+ "forest_change": -4990,
116
+ "total_cropland_change": 11408,
117
+ "pasture_change": -12705,
118
+ "total_agricultural_change": -1297
119
+ },
120
+ -4990
121
+ ),
122
+ (
123
+ "Madagascar",
124
+ {
125
+ "forest_change": -1131,
126
+ "total_cropland_change": 275,
127
+ "pasture_change": 4295,
128
+ "total_agricultural_change": 4570
129
+ },
130
+ -1131
131
+ ),
132
+ (
133
+ "Afforestation",
134
+ {
135
+ "forest_change": 100,
136
+ "total_cropland_change": -1000,
137
+ "pasture_change": -50,
138
+ "total_agricultural_change": -1000
139
+ },
140
+ 0
141
+ ),
142
+ (
143
+ "Pasture gain more than forest loss",
144
+ {
145
+ "forest_change": -49,
146
+ "total_cropland_change": -1000,
147
+ "pasture_change": 50,
148
+ "total_agricultural_change": -950
149
+ },
150
+ -49
151
+ )
152
+ ]
153
+ )
154
+ def test_estimate_maximum_forest_change(description, inputs, expected_output):
155
+ assert _estimate_maximum_forest_change(**inputs) == expected_output, description
156
+
157
+
158
+ @pytest.mark.parametrize(
159
+ "description,inputs,expected_result",
160
+ [
161
+ ("All zeros, OK", {"a": 0, "b": 0, "c": 0.0, "d": 0.0}, True),
162
+ ("Exactly 1, OK", {"a": 0.1, "b": 0.5, "c": 0.4, "d": 0.0}, True),
163
+ ("Almost 1, OK", {"a": 0.1, "b": 0.5, "c": 0.4, "d": 0.01}, True),
164
+ ("Less than 1, Fail", {"a": 0.1, "b": 0, "c": 0.0, "d": 0.65}, False),
165
+ ("More than 1, Fail", {"a": 0.15, "b": 0.7, "c": 0.0, "d": 0.65}, False),
166
+ ]
167
+ )
168
+ def test_check_sum_of_percentages(description, inputs, expected_result):
169
+ assert site_area_sum_to_100(dict_of_percentages=inputs) == expected_result
170
+
171
+
172
+ def test_get_sums_of_crop_expansion():
173
+ result = _get_sums_of_crop_expansion(
174
+ country_id="GADM-AFG",
175
+ year=2010,
176
+ include_negatives=True
177
+ )
178
+ assert result == (753973.3, 18354.0)
179
+
180
+ result = _get_sums_of_crop_expansion(
181
+ country_id="GADM-AFG",
182
+ year=2010,
183
+ include_negatives=False
184
+ )
185
+ assert result == (940270.0, 28139.0)
186
+
187
+
188
+ @pytest.mark.parametrize(
189
+ "subfolder",
190
+ [
191
+ "albania_example",
192
+ "argentina_example",
193
+ "armenia_example",
194
+ "brazil_example",
195
+ "zimbabwe_example",
196
+ "brazil_empty_example",
197
+ "gbr_example"
198
+ ]
199
+ )
200
+ def test_run(subfolder):
201
+ folder = f"{fixtures_folder}/{subfolder}"
202
+ with open(f"{folder}/site.jsonld", encoding='utf-8') as f:
203
+ site = json.load(f)
204
+
205
+ with open(f"{folder}/result.jsonld", encoding='utf-8') as f:
206
+ expected = json.load(f)
207
+
208
+ result = run(site)
209
+ assert result == expected
@@ -0,0 +1,21 @@
1
+ from unittest.mock import patch
2
+ import json
3
+ from tests.utils import fixtures_path, fake_new_practice
4
+
5
+ from hestia_earth.models.ipcc2019 import MODEL
6
+ from hestia_earth.models.ipcc2019.animal.milkYieldPerAnimal import MODEL_KEY, run
7
+
8
+ class_path = f"hestia_earth.models.{MODEL}.animal.{MODEL_KEY}"
9
+ fixtures_folder = f"{fixtures_path}/{MODEL}/animal/{MODEL_KEY}"
10
+
11
+
12
+ @patch(f"{class_path}._new_practice", side_effect=fake_new_practice)
13
+ def test_run(*args):
14
+ with open(f"{fixtures_folder}/cycle.jsonld", encoding='utf-8') as f:
15
+ cycle = json.load(f)
16
+
17
+ with open(f"{fixtures_folder}/result.jsonld", encoding='utf-8') as f:
18
+ expected = json.load(f)
19
+
20
+ value = run(cycle)
21
+ assert value == expected
@@ -10,8 +10,34 @@ from tests.utils import fake_new_emission, fixtures_path, order_list
10
10
 
11
11
  class_path = f"hestia_earth.models.{MODEL}.co2ToAirSoilOrganicCarbonStockChange"
12
12
  utils_path = f"hestia_earth.models.{MODEL}.co2ToAirCarbonStockChange_utils"
13
+ soc_utils_path = f"hestia_earth.models.{MODEL}.organicCarbonPerHa_utils"
14
+ term_folder = "hestia_earth.models.utils.term"
13
15
  fixtures_folder = f"{fixtures_path}/{MODEL}/co2ToAirSoilOrganicCarbonStockChange"
14
16
 
17
+
18
+ IRRIGATED_TERM_IDS = [
19
+ "rainfedDeepWater",
20
+ "rainfedDeepWaterWaterDepth100Cm",
21
+ "rainfedDeepWaterWaterDepth50100Cm",
22
+ "irrigatedTypeUnspecified",
23
+ "irrigatedCenterPivotIrrigation",
24
+ "irrigatedContinuouslyFlooded",
25
+ "irrigatedDripIrrigation",
26
+ "irrigatedFurrowIrrigation",
27
+ "irrigatedLateralMoveIrrigation",
28
+ "irrigatedLocalizedIrrigation",
29
+ "irrigatedManualIrrigation",
30
+ "irrigatedSurfaceIrrigationMultipleDrainagePeriods",
31
+ "irrigatedSurfaceIrrigationSingleDrainagePeriod",
32
+ "irrigatedSprinklerIrrigation",
33
+ "irrigatedSubIrrigation",
34
+ "irrigatedSurfaceIrrigationDrainageRegimeUnspecified"
35
+ ]
36
+
37
+ UPLAND_RICE_LAND_COVER_TERM_IDS = [
38
+ "ricePlantUpland"
39
+ ]
40
+
15
41
  RUN_SCENARIOS = [
16
42
  ("no-overlapping-cycles", 3),
17
43
  ("overlapping-cycles", 4),
@@ -47,7 +73,20 @@ RUN_IDS = [f"{param[0]}, cycle{param[2]}" for param in RUN_PARAMS]
47
73
  @patch(f"{class_path}._new_emission", side_effect=fake_new_emission)
48
74
  @patch(f"{utils_path}.related_cycles")
49
75
  @patch(f"{utils_path}._get_site")
50
- def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder, num_cycles, cycle_index):
76
+ @patch(f"{soc_utils_path}.get_upland_rice_land_cover_terms", return_value=UPLAND_RICE_LAND_COVER_TERM_IDS)
77
+ @patch(f"{soc_utils_path}.get_irrigated_terms", return_value=IRRIGATED_TERM_IDS)
78
+ @patch(f"{term_folder}.search")
79
+ def test_run(
80
+ search_mock,
81
+ get_irrigated_terms_mock,
82
+ get_upland_rice_land_cover_terms_mock,
83
+ _get_site_mock,
84
+ related_cycles_mock,
85
+ _new_emission_mock,
86
+ subfolder,
87
+ num_cycles,
88
+ cycle_index
89
+ ):
51
90
  """
52
91
  Test `run` function for each cycle in each scenario.
53
92
  """
@@ -63,6 +102,14 @@ def test_run(_get_site_mock, related_cycles_mock, _new_emission_mock, subfolder,
63
102
  related_cycles_mock.return_value = cycles
64
103
 
65
104
  result = run(cycle)
105
+
106
+ # Ensure that API calls to retrieve term IDs are properly cached.
107
+ get_irrigated_terms_mock.call_count <= 1
108
+ get_upland_rice_land_cover_terms_mock.call_count <= 1
109
+
110
+ # Ensure that the property and term utils are properly mocked.
111
+ search_mock.assert_not_called()
112
+
66
113
  assert order_list(result) == order_list(expected)
67
114
 
68
115