hestia-earth-models 0.73.4__py3-none-any.whl → 0.73.6__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 (24) hide show
  1. hestia_earth/models/config/Cycle.json +0 -45
  2. hestia_earth/models/config/ImpactAssessment.json +0 -24
  3. hestia_earth/models/config/Site.json +11 -0
  4. hestia_earth/models/geospatialDatabase/potentialEvapotranspirationAnnual.py +2 -1
  5. hestia_earth/models/geospatialDatabase/precipitationAnnual.py +2 -1
  6. hestia_earth/models/geospatialDatabase/temperatureAnnual.py +2 -1
  7. hestia_earth/models/hestia/landCover.py +105 -36
  8. hestia_earth/models/ipcc2019/biocharOrganicCarbonPerHa.py +435 -0
  9. hestia_earth/models/mocking/search-results.json +706 -702
  10. hestia_earth/models/utils/__init__.py +10 -1
  11. hestia_earth/models/utils/blank_node.py +1 -1
  12. hestia_earth/models/version.py +1 -1
  13. {hestia_earth_models-0.73.4.dist-info → hestia_earth_models-0.73.6.dist-info}/METADATA +2 -2
  14. {hestia_earth_models-0.73.4.dist-info → hestia_earth_models-0.73.6.dist-info}/RECORD +20 -21
  15. tests/models/hestia/test_landCover.py +58 -2
  16. tests/models/ipcc2019/test_biocharOrganicCarbonPerHa.py +131 -0
  17. tests/models/test_utils.py +6 -0
  18. hestia_earth/models/faostat2018/landTransformation100YearAverageDuringCycle.py +0 -34
  19. hestia_earth/models/faostat2018/landTransformation20YearAverageDuringCycle.py +0 -34
  20. tests/models/faostat2018/test_landTransformation100YearAverageDuringCycle.py +0 -21
  21. tests/models/faostat2018/test_landTransformation20YearAverageDuringCycle.py +0 -21
  22. {hestia_earth_models-0.73.4.dist-info → hestia_earth_models-0.73.6.dist-info}/LICENSE +0 -0
  23. {hestia_earth_models-0.73.4.dist-info → hestia_earth_models-0.73.6.dist-info}/WHEEL +0 -0
  24. {hestia_earth_models-0.73.4.dist-info → hestia_earth_models-0.73.6.dist-info}/top_level.txt +0 -0
@@ -11,7 +11,7 @@ from pydash.objects import get
11
11
  from typing import Union, List, Callable
12
12
  from hestia_earth.schema import SchemaType
13
13
  from hestia_earth.utils.api import download_hestia
14
- from hestia_earth.utils.tools import flatten, non_empty_list
14
+ from hestia_earth.utils.tools import flatten, non_empty_list, safe_parse_date
15
15
  from hestia_earth.utils.date import is_in_days, is_in_months
16
16
 
17
17
  from .constant import Units
@@ -157,6 +157,15 @@ def current_date(): return datetime.datetime.now().date().strftime('%Y-%m-%d')
157
157
  def current_year(): return int(current_date()[:4])
158
158
 
159
159
 
160
+ def max_date(date_str: str):
161
+ """
162
+ If the date is after today, returns today. Otherwise returns the date.
163
+ """
164
+ date = safe_parse_date(date_str).date()
165
+ max_date = datetime.datetime.now().date()
166
+ return current_date() if date > max_date else date_str
167
+
168
+
160
169
  def flatten_args(args) -> list:
161
170
  """
162
171
  Flatten the input args into a single list.
@@ -584,7 +584,7 @@ def cumulative_nodes_match(
584
584
  """
585
585
  values = [
586
586
  get_node_value(
587
- node, 'value', is_larger_unit, array_treatment
587
+ node, key='value', is_larger_unit=is_larger_unit, array_treatment=array_treatment
588
588
  ) or default_node_value for node in nodes if function(node)
589
589
  ]
590
590
 
@@ -1 +1 @@
1
- VERSION = '0.73.4'
1
+ VERSION = '0.73.6'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hestia-earth-models
3
- Version: 0.73.4
3
+ Version: 0.73.6
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
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.6
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: hestia-earth-schema==33.*
15
- Requires-Dist: hestia-earth-utils>=0.14.7
15
+ Requires-Dist: hestia-earth-utils>=0.14.9
16
16
  Requires-Dist: python-dateutil>=2.8.1
17
17
  Requires-Dist: CurrencyConverter==0.16.8
18
18
  Requires-Dist: haversine>=2.7.0
@@ -5,7 +5,7 @@ hestia_earth/models/cache_sites.py,sha256=XpXnkYt823PQzrswgP__L4CT8xZG_n7a41CIHK
5
5
  hestia_earth/models/log.py,sha256=eRuH86v7Thuw-QXdKqaqVmA_MkwnOCo0UBEwtuDq4Oc,3554
6
6
  hestia_earth/models/preload_requests.py,sha256=vK_G1UzhNMhYy7ymnCtHUz_vv3cfApCSKqv29VREEBQ,1943
7
7
  hestia_earth/models/requirements.py,sha256=eU4yT443fx7BnaokhrLB_PCizJI7Y6m4auyo8vQauNg,17363
8
- hestia_earth/models/version.py,sha256=jKpV57P7KcWNOm5DrfT5hkuNicj89ENgA5Alu2opwy4,19
8
+ hestia_earth/models/version.py,sha256=gitCsBIWkcodAN8Lqch7WqL2CaXjTfpeoB_0nJ451NM,19
9
9
  hestia_earth/models/agribalyse2016/__init__.py,sha256=WvK0qCQbnYtg9oZxrACd1wGormZyXibPtpCnIQeDqbw,415
10
10
  hestia_earth/models/agribalyse2016/fuelElectricity.py,sha256=1ngl8pdxeNhlVV8keAeWRwGorr_1uFXM9EoPUWx-uSc,4382
11
11
  hestia_earth/models/agribalyse2016/machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=queToXuzq0tQ9_XuUJ2pJgSywXmbt9uX3ZoIKgqkROM,2660
@@ -35,9 +35,9 @@ hestia_earth/models/cml2001Baseline/terrestrialAcidificationPotentialIncludingFa
35
35
  hestia_earth/models/cml2001NonBaseline/__init__.py,sha256=vI8wp8Og_e8DiJqYYvp33YoI3t4ffAC31LWlnV20JTg,419
36
36
  hestia_earth/models/cml2001NonBaseline/eutrophicationPotentialIncludingFateAverageEurope.py,sha256=lcgyRHY08KCBFPERJNqV4DYGEJCvyHBDnJXD0kEkVqM,1097
37
37
  hestia_earth/models/cml2001NonBaseline/terrestrialAcidificationPotentialExcludingFate.py,sha256=xcrxfs9UoV_EWvV-XzMt35oPWCUsTzqg2SGA3j2MFIw,1091
38
- hestia_earth/models/config/Cycle.json,sha256=3fsz2dNEKA4noEjqrp25Or3_scDxqFS7c_7v911Gpno,59078
39
- hestia_earth/models/config/ImpactAssessment.json,sha256=ubAHJRHOFdX-fIYkOEBuD0CYvNZtFYSr8GSgKliVL8g,60968
40
- hestia_earth/models/config/Site.json,sha256=TnWIoaTspA0SUERWGpwuVf5o6x34N2riGftqzcvpCho,14086
38
+ hestia_earth/models/config/Cycle.json,sha256=DSwKJd-5UX4Lnt3C3sHeYKHh6Zr2Fe-RgTas2DoDTGA,57840
39
+ hestia_earth/models/config/ImpactAssessment.json,sha256=VLkGnDNGLilYK2410STpB63MO_hzOQCaY6QgUcvJLz0,60323
40
+ hestia_earth/models/config/Site.json,sha256=4DPSziHnDIngyub3Of8OvDEKa446q3Yx48R2Eobqk24,14374
41
41
  hestia_earth/models/config/__init__.py,sha256=l1WqL7ezlank86ABP4zUia_hIvM9ba-sOE3z6wNrea8,2333
42
42
  hestia_earth/models/config/run-calculations.json,sha256=e3nJ4M6CP1iFzfv8ou_ZUFbFxYkDxJgwuNDXTm4PBDc,615
43
43
  hestia_earth/models/config/trigger-calculations.json,sha256=3dmn2bRuj6QEtSTOLdIy31ho7thgUXyDsnqZzPV9rAQ,623
@@ -136,8 +136,6 @@ hestia_earth/models/fantkeEtAl2016/damageToHumanHealthParticulateMatterFormation
136
136
  hestia_earth/models/faostat2018/__init__.py,sha256=ecN-pKF1pkFnzmooBrg1VAxJkG76q9v4piiaKGP_vbo,412
137
137
  hestia_earth/models/faostat2018/coldCarcassWeightPerHead.py,sha256=Qf_nvHxT4mn9kSNgOEXJUX0oUIOuuw0KSzLf-si04tQ,3105
138
138
  hestia_earth/models/faostat2018/coldDressedCarcassWeightPerHead.py,sha256=2WqIFxUMHngcsY7CffAn0bZClB_VXW1egtvBrKOFmxw,3196
139
- hestia_earth/models/faostat2018/landTransformation100YearAverageDuringCycle.py,sha256=Pp94-1uMHN-jlMIbUQB-Go26WAxtMtTmf8zyyyAEvvk,998
140
- hestia_earth/models/faostat2018/landTransformation20YearAverageDuringCycle.py,sha256=LNQfb_vqNsJOrgZXVo6m9hBGdI8OaHSnfA9jSbp6JVY,995
141
139
  hestia_earth/models/faostat2018/liveweightPerHead.py,sha256=2BmSe8xdEdm68i6t_UkeXQshxLH3WVNyvButsoE_9zE,5031
142
140
  hestia_earth/models/faostat2018/readyToCookWeightPerHead.py,sha256=obJLPV8GgG2lEhLqg9RrJLSFPzbasXJnmzHnwkpW7O0,3131
143
141
  hestia_earth/models/faostat2018/seed.py,sha256=brDGypvFJR6gpb4VMTW16cN2Jw0jbvD2msV-NMWuwxQ,2948
@@ -160,10 +158,10 @@ hestia_earth/models/geospatialDatabase/histosol.py,sha256=uVl96zpxPHYDW81SxnEpMP
160
158
  hestia_earth/models/geospatialDatabase/longFallowRatio.py,sha256=X-qJS0euYVwhGHd4rCnlRSL3KOMLQJl5kO8QqSREcpA,2561
161
159
  hestia_earth/models/geospatialDatabase/nutrientLossToAquaticEnvironment.py,sha256=uEsoYJ1mzgUo6fQhUrcJ-ATcFw1j9oEgqMXKbQuFRxQ,1973
162
160
  hestia_earth/models/geospatialDatabase/organicCarbonPerKgSoil.py,sha256=pGy35cvt5Rzv2h0ka5PZqZqWp0wThWqJL8o_nVZinCo,2862
163
- hestia_earth/models/geospatialDatabase/potentialEvapotranspirationAnnual.py,sha256=x8-108UuysEZNgCBvLGOWsYvvBAIlE_5h6y2Kl-Tl40,2396
161
+ hestia_earth/models/geospatialDatabase/potentialEvapotranspirationAnnual.py,sha256=UZl-1PlopZdhjzeCU2dbxQJhU7IeTIUI6oT4TPQ2mSQ,2453
164
162
  hestia_earth/models/geospatialDatabase/potentialEvapotranspirationLongTermAnnualMean.py,sha256=YywD9wCkGFF1q60LocXNvLr-tQ2_9km2PrVnXRgN83E,2125
165
163
  hestia_earth/models/geospatialDatabase/potentialEvapotranspirationMonthly.py,sha256=rt-MNUYkFruViMSPJV6r66042227CdCLmccYT48dU4o,3197
166
- hestia_earth/models/geospatialDatabase/precipitationAnnual.py,sha256=VMrz4z4FmA0SLIwYr1mT5RWX41XbmubQlwdQvU2eq80,2657
164
+ hestia_earth/models/geospatialDatabase/precipitationAnnual.py,sha256=ljqttqQ7bZqMOWt9hGxsGGjQ4u1wm7IpUS-J19ttrAU,2714
167
165
  hestia_earth/models/geospatialDatabase/precipitationLongTermAnnualMean.py,sha256=wZ_QprRT9ILSNpiUhPdKtTERUsGofQT1kqUaHuJjDOs,2390
168
166
  hestia_earth/models/geospatialDatabase/precipitationMonthly.py,sha256=jQ3XLN8Zh7q2LZgLmybzvwR0X2vdi6IDz301EUVbAmE,3261
169
167
  hestia_earth/models/geospatialDatabase/region.py,sha256=55tjxaffUaQnJ_kqWd-eejhLMs-5N2CjUQd9FU1wWoU,1448
@@ -172,7 +170,7 @@ hestia_earth/models/geospatialDatabase/siltContent.py,sha256=rFUlQ3SlwCJFcMYQd5F
172
170
  hestia_earth/models/geospatialDatabase/slope.py,sha256=g1SpuYks60injv2w-CMjESNfu8KM1JsiYnRT9XZfSuY,1859
173
171
  hestia_earth/models/geospatialDatabase/slopeLength.py,sha256=6pGr1qR0EiiUKkeflpYut7eI6UsnXAzHDoHhAzXKFJk,1864
174
172
  hestia_earth/models/geospatialDatabase/soilPh.py,sha256=f-jZhIpbsVDe_lGm0rfA7K0vRRTy0M5adKA-_-W11LU,2799
175
- hestia_earth/models/geospatialDatabase/temperatureAnnual.py,sha256=wprDhySO4y2wAebLIQPfsLP4tQYowaUh8V-rNGEc380,2553
173
+ hestia_earth/models/geospatialDatabase/temperatureAnnual.py,sha256=sI1j-Zw5cAlLRElv6c-RhHDMz4vQZV7yuKCEgqEV4sw,2610
176
174
  hestia_earth/models/geospatialDatabase/temperatureLongTermAnnualMean.py,sha256=ypQbdbily63m_B7t7_aTaJ8RN9gzzauHeZTFDgFhlds,2230
177
175
  hestia_earth/models/geospatialDatabase/temperatureMonthly.py,sha256=E2k2kkhVDtmeFEB4_AZhhq5od57lRDMWu6AqaurgqvQ,3194
178
176
  hestia_earth/models/geospatialDatabase/totalNitrogenPerKgSoil.py,sha256=eajSzMCX201k_xrfZZSHtTzEIH29hqgJdztQgQeewig,2853
@@ -205,7 +203,7 @@ hestia_earth/models/hestia/freshWater.py,sha256=Q-dmFJLZfyYEyFyYkJUOjgmQR3G5YXCX
205
203
  hestia_earth/models/hestia/histosol.py,sha256=IexiWTSlSJYGjrdpYmRooW6v8LjhYATPQ8smMz1UZBA,1612
206
204
  hestia_earth/models/hestia/inorganicFertiliser.py,sha256=We4PBaTXyGwEQTfhX0-J8Xt03p-FB9i9j3tEK5JQ8uE,9026
207
205
  hestia_earth/models/hestia/irrigatedTypeUnspecified.py,sha256=VdYzfYxcRzWv21qxRkDn9HBid7-Bt_CgIv4iyXJH03g,1929
208
- hestia_earth/models/hestia/landCover.py,sha256=FHJ98zDByDL3ofziHICQNKiz_OnmrdOqJC0ZJRHif7E,32953
206
+ hestia_earth/models/hestia/landCover.py,sha256=VI3DiDxbdHe54S47ixO4PIPyGVtt-Hw_QRScQokOEVo,35569
209
207
  hestia_earth/models/hestia/landTransformation100YearAverageDuringCycle.py,sha256=hF7_DDvrs7swH6ott_ihgYx13UzEKHH6pccYCtzrN8o,1069
210
208
  hestia_earth/models/hestia/landTransformation20YearAverageDuringCycle.py,sha256=05SCH6ZjEV3mIleRusBg677zu0xgu5YK0f9FCddgNPg,1067
211
209
  hestia_earth/models/hestia/liveAnimal.py,sha256=d7HuUi40c-7TN1kecdRuqbht8PAe7x4ps0NhSuWG34Q,3868
@@ -287,6 +285,7 @@ hestia_earth/models/ipcc2019/aboveGroundBiomass.py,sha256=T50NcJoyGrHYUSzJBXJKAO
287
285
  hestia_earth/models/ipcc2019/aboveGroundCropResidueTotal.py,sha256=lT2QVV5c2LvQqZRfPEvFT_bMTayMXgIsFLnx8I6iYzw,3089
288
286
  hestia_earth/models/ipcc2019/belowGroundBiomass.py,sha256=WN3R5kUIc5Ij4HxMFcTGKeNRoPChRY6ws0x3nQNeEMw,19421
289
287
  hestia_earth/models/ipcc2019/belowGroundCropResidue.py,sha256=qbfsLBPaMIt4oQzYAzbsZdkJozTbwuztNr48TLYC5-Y,3507
288
+ hestia_earth/models/ipcc2019/biocharOrganicCarbonPerHa.py,sha256=--qSO-v0X6qlti5NmUD5bcjGpf4tX352vPVDU0ECAI0,13276
290
289
  hestia_earth/models/ipcc2019/biomass_utils.py,sha256=NkTPGMl-0tqvhUZKZ1rxW0XTBnZOvgFJki_IPzEEyu0,15796
291
290
  hestia_earth/models/ipcc2019/carbonContent.py,sha256=XhXDu6DRQxANBsRsCEgw4f0UJDOgWsvhVyEwK1-4YT0,7263
292
291
  hestia_earth/models/ipcc2019/ch4ToAirAquacultureSystems.py,sha256=JeyF4tUPn3KIDbXwgM_MFp18hnTZjLBBqMFMH_ciZ1Q,3529
@@ -448,7 +447,7 @@ hestia_earth/models/linkedImpactAssessment/utils.py,sha256=7M-E7u35fIF0uMoA1hwcr
448
447
  hestia_earth/models/mocking/__init__.py,sha256=9VX50c-grz-snfd-7MBS0KfF7AadtbKuj7kK6PqtsgE,687
449
448
  hestia_earth/models/mocking/build_mock_search.py,sha256=p15ccEUmkmLp1RiGNznxMz3OFHbI8P1-29ExuohiQN8,1355
450
449
  hestia_earth/models/mocking/mock_search.py,sha256=ccFe_WrI73JElFmxp4hPNLCX7eeU--lBC1JFR901KJY,1069
451
- hestia_earth/models/mocking/search-results.json,sha256=q9-8NCcbbCa7h9SQk-gFtp3ZWLBHs2OW5OyN5RAybzY,162622
450
+ hestia_earth/models/mocking/search-results.json,sha256=RirhWmqO7ySe_qzdefCJuQb4iacXB_ioJLjaN940VXY,162692
452
451
  hestia_earth/models/pooreNemecek2018/__init__.py,sha256=nPboL7ULJzL5nJD5q7q9VOZt_fxbKVm8fmn1Az5YkVY,417
453
452
  hestia_earth/models/pooreNemecek2018/aboveGroundCropResidueTotal.py,sha256=oXillpppAas1q9GKmODxe1YXyno3EzV-j12xhzkqtTc,2404
454
453
  hestia_earth/models/pooreNemecek2018/belowGroundCropResidue.py,sha256=_pQMPSvI--Xm00H6vXDA4ct_pQXKRGrLE2f-2tQE6y4,2323
@@ -590,12 +589,12 @@ hestia_earth/models/transformation/product/__init__.py,sha256=47DEQpj8HBSa-_TImW
590
589
  hestia_earth/models/transformation/product/excreta.py,sha256=tggXIoUujzu8O949_3KFog219k_bQ0IcytpCsJ8oMcc,5384
591
590
  hestia_earth/models/usetoxV2/__init__.py,sha256=pK37V3H-KvYcvRKw4Mv8CWrB2N0LFLzmv0jKLdhGGqs,409
592
591
  hestia_earth/models/usetoxV2/freshwaterEcotoxicityPotentialCtue.py,sha256=pPX8u-Aq6Pg5Y9xw0CS0S2WkAHQpOMl0lL2tLQwwOuU,918
593
- hestia_earth/models/utils/__init__.py,sha256=8YXFDBdB7VJK9F4BTMeq_WoNAGySEGgoVbvW5EoZahA,6848
592
+ hestia_earth/models/utils/__init__.py,sha256=0v-wjG9xzJeitWEUN3XRleM_is1AkVm2r7WkApB7-ho,7136
594
593
  hestia_earth/models/utils/aggregated.py,sha256=G7FNJfHqJ_eoXB66kGdjLyZGDOI_gsF56o7VnyW3bqA,4801
595
594
  hestia_earth/models/utils/animalProduct.py,sha256=M5IunAKGY6oZv3j1Ascl34ywyeLWApqOIlBzbtlA2FE,721
596
595
  hestia_earth/models/utils/aquacultureManagement.py,sha256=dxrbC1Xf140cohxTbSw6TxLAnAASWTdNZwBBam4yQnw,171
597
596
  hestia_earth/models/utils/background_emissions.py,sha256=54zuH4yFNc_cle3uYGtK_EjhkG0XGaG5L6eGKiTyOG4,3100
598
- hestia_earth/models/utils/blank_node.py,sha256=o1MzCz6FXuJ4Iit55EeGrHbrGM9VUfdAF1RNqTBU89Y,56070
597
+ hestia_earth/models/utils/blank_node.py,sha256=Y4Q1wnddrMyo9NEqKFcmt43LKHPWDlbe9l1seDcU8K0,56105
599
598
  hestia_earth/models/utils/cache_sources.py,sha256=MBkrPpjwNiC4ApDjeYVHZjWBbpvAerXRDrMHpjasAZ0,377
600
599
  hestia_earth/models/utils/completeness.py,sha256=iRG4uviOAQQ4T2Nr4LlelPVTS_F1felGZNJYxek_JG8,1239
601
600
  hestia_earth/models/utils/constant.py,sha256=DmB3VVuoh7Pz2QDBJqiUG6yAML2i0fOy1BPuPHmhT1w,3442
@@ -659,6 +658,7 @@ tests/models/test_ecoinventV3.py,sha256=SvBn1ZomoturZhjj4BE2EU46Sq0il-tOJIqutmGa
659
658
  tests/models/test_ecoinventV3AndEmberClimate.py,sha256=_7sX0s07Xr00uNcVk78L1AdSqI1OpUV3tkkG1hVSY2w,803
660
659
  tests/models/test_emissionNotRelevant.py,sha256=TsIV47lpn7joLGx-LlPVqWbshcLf2c6pUvB3FZwLvwY,1023
661
660
  tests/models/test_resourceUseNotRelevant.py,sha256=z1zY3pJdffongIsBJaLB7WToBrMiE4wYuHSsAbGEJ7w,983
661
+ tests/models/test_utils.py,sha256=Caa9sCyz25egPrSlu7FQhjXD2vNcQW9gea_ppUYOsEs,186
662
662
  tests/models/agribalyse2016/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
663
663
  tests/models/agribalyse2016/test_fuelElectricity.py,sha256=u_wNlqngJc8NELPr16kYsYQ-_2PcL8BnrfJucY7dccU,1353
664
664
  tests/models/agribalyse2016/test_machineryInfrastructureDepreciatedAmountPerCycle.py,sha256=75yJ0yuPbIizpSsHr7CpZnUv01LZbuYsm5s9hE0VL_o,1090
@@ -775,8 +775,6 @@ tests/models/faostat2018/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
775
775
  tests/models/faostat2018/test_coldCarcassWeightPerHead.py,sha256=RImhLygwrJ2RoEHjDwhuymvLEitOtNleP_lLoBhiNOs,1736
776
776
  tests/models/faostat2018/test_coldDressedCarcassWeightPerHead.py,sha256=hZVKMtf-F5Iz7igZVahDJoqzfm2VtcIlwWBPCry7kqw,1594
777
777
  tests/models/faostat2018/test_faostat_utils.py,sha256=25Y6N4kdbBXno0PwosaC94NRW3W2FIyjS4-WoIV9Xmc,1679
778
- tests/models/faostat2018/test_landTransformation100YearAverageDuringCycle.py,sha256=gcJd_d1GYw7VI8oZHvgbSjUgagp4AyMiMeJBrnpLgAE,753
779
- tests/models/faostat2018/test_landTransformation20YearAverageDuringCycle.py,sha256=ZRDfN2E-kJOKQkbs6se0x7T03dzmnf4TN1D5uwrLdKA,752
780
778
  tests/models/faostat2018/test_liveweightPerHead.py,sha256=Qp4iKZ6Ofq1rGQL8ngESAx2JSPR_97TK4wOymmikdfA,4781
781
779
  tests/models/faostat2018/test_readyToCookWeightPerHead.py,sha256=pMDcONs0WUvANcJ6_OPF7TBwMF45JGMxFRPNPtHLqVI,1570
782
780
  tests/models/faostat2018/test_seed.py,sha256=tUXoNVveX0m0ed9UXB4zXxIZsPxktXyUXlbWuUKG0sQ,1705
@@ -844,7 +842,7 @@ tests/models/hestia/test_freshWater.py,sha256=v2UD69csKrniKP3MXkOEHxQeE6O3-lvIVi
844
842
  tests/models/hestia/test_histosol.py,sha256=7g-3wQPZok2O8mExcnKZxO_T2Ye_h3UHv3HG3Kn8orM,888
845
843
  tests/models/hestia/test_inorganicFertiliser.py,sha256=v2Zs1Ig-ChOaq9gXuurcBt12izkH2bRUUuzW6rh3rqQ,643
846
844
  tests/models/hestia/test_irrigatedTypeUnspecified.py,sha256=bluZADFagxfXW4QyI0CIJzG97D2V33w333Z9Vwjqo0M,2015
847
- tests/models/hestia/test_landCover.py,sha256=YLu-fttf0tGGT8IAPGo8BZDsSyRoW7f-JU8Ra0Pp-dA,7494
845
+ tests/models/hestia/test_landCover.py,sha256=usfFMcVUvZDFpYoo53NdsinbhZjwlEnjtWNuNli03eE,9889
848
846
  tests/models/hestia/test_landTransformation100YearAverageDuringCycle.py,sha256=3qa4rWUFqP1VM5-vm_182rhiBYJDxPqJwWtBqJ5K028,956
849
847
  tests/models/hestia/test_landTransformation20YearAverageDuringCycle.py,sha256=bUByojQuVeuCfko1_2YtNJi1PT9yktHlcbPi_p-MPvk,1001
850
848
  tests/models/hestia/test_liveAnimal.py,sha256=3K9cL1fwr6LlBl1_D8zIaeCOuiExqkDEU7BXx1JK_dk,2139
@@ -919,6 +917,7 @@ tests/models/ipcc2019/test_aboveGroundBiomass.py,sha256=zzsE1zr8qYWgc1EWNrCZggjk
919
917
  tests/models/ipcc2019/test_aboveGroundCropResidueTotal.py,sha256=HrTsqm1r5c5di5JONu7P4_95JMp1kbDuKfQjWLE0Jhs,2573
920
918
  tests/models/ipcc2019/test_belowGroundBiomass.py,sha256=Cu41RM63R-xti0qi_mLD0J5TClo61OkjsR4FI3caNxs,7579
921
919
  tests/models/ipcc2019/test_belowGroundCropResidue.py,sha256=no71pfxgOhn_tEWc_EwuWvlKRtHFqlIqNIvnP7cj0Tc,2568
920
+ tests/models/ipcc2019/test_biocharOrganicCarbonPerHa.py,sha256=19SX8sCKjyqThydHBh7jE9S46Y6SBd-pJx_RUmuZ0nU,3785
922
921
  tests/models/ipcc2019/test_biomass_utils.py,sha256=I2q4pDGAD0aY_kpZCMPJoC-KbRYxdzY1rhr4xtJFWIA,3592
923
922
  tests/models/ipcc2019/test_carbonContent.py,sha256=_GWF5nGy-PxiqBZ5V7W_sHMz75YRzmxr79R-sZZg7yk,4146
924
923
  tests/models/ipcc2019/test_ch4ToAirAquacultureSystems.py,sha256=hG1zunH2gCeix8fxxkoGfl_I0GRyAcLbwEtwWVE9i5M,1925
@@ -1249,8 +1248,8 @@ tests/orchestrator/strategies/run/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
1249
1248
  tests/orchestrator/strategies/run/test_add_blank_node_if_missing.py,sha256=K4xg4UAXfNhSaLyknKVPO7MGBF44Z_gD7CuZ_pe28gU,3512
1250
1249
  tests/orchestrator/strategies/run/test_add_key_if_missing.py,sha256=hKwvk1ohcBVnQUCTiDhRW99J0xEa29BpwFi1KC0yWLE,329
1251
1250
  tests/orchestrator/strategies/run/test_always.py,sha256=w5-Dhp6yLzgZGAeMRz3OrqZbbAed9gZ1O266a3z9k7w,134
1252
- hestia_earth_models-0.73.4.dist-info/LICENSE,sha256=TD25LoiRJsA5CPUNrcyt1PXlGcbUGFMAeZoBcfCrCNE,1154
1253
- hestia_earth_models-0.73.4.dist-info/METADATA,sha256=Acqy7een93J-4E9V-DI_J5-n-_Lb9lzOnoHcCbKGO5U,4065
1254
- hestia_earth_models-0.73.4.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1255
- hestia_earth_models-0.73.4.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
1256
- hestia_earth_models-0.73.4.dist-info/RECORD,,
1251
+ hestia_earth_models-0.73.6.dist-info/LICENSE,sha256=TD25LoiRJsA5CPUNrcyt1PXlGcbUGFMAeZoBcfCrCNE,1154
1252
+ hestia_earth_models-0.73.6.dist-info/METADATA,sha256=sI6oUwv9y6tLBVv_TWI8Wj7LWgBYs0ij46PzkKOYypc,4065
1253
+ hestia_earth_models-0.73.6.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1254
+ hestia_earth_models-0.73.6.dist-info/top_level.txt,sha256=1dqA9TqpOLTEgpqa-YBsmbCmmNU1y56AtfFGEceZ2A0,19
1255
+ hestia_earth_models-0.73.6.dist-info/RECORD,,
@@ -1,19 +1,26 @@
1
+ import logging
1
2
  import os
2
3
  import json
3
4
  import pytest
4
5
  from unittest.mock import patch
5
6
 
7
+ from hestia_earth.models.hestia.utils import (
8
+ FOREST_LAND, PERMANENT_PASTURE, PERMANENT_CROPLAND, ANNUAL_CROPLAND, OTHER_LAND
9
+ )
6
10
  from tests.utils import fixtures_path, fake_new_management
7
11
  from hestia_earth.models.faostat2018.utils import MODEL as FAOSTAT_MODEL
8
12
  from hestia_earth.models.hestia.landCover import (
9
13
  MODEL, MODEL_KEY, _get_changes, _estimate_maximum_forest_change,
10
14
  run, site_area_sum_to_100, _get_sums_of_crop_expansion, _get_sum_for_land_category, scale_values_to_one,
11
- _get_most_common_or_alphabetically_first
15
+ _get_most_common_or_alphabetically_first, _get_land_cover_lookup_suffix
12
16
  )
13
17
 
14
18
  CLASS_PATH = f"hestia_earth.models.{MODEL}.{MODEL_KEY}"
15
19
  fixtures_folder = f"{fixtures_path}/{MODEL}/{MODEL_KEY}"
16
- _folders = [d for d in os.listdir(fixtures_folder) if os.path.isdir(os.path.join(fixtures_folder, d))]
20
+ _folders = [
21
+ d for d in os.listdir(fixtures_folder)
22
+ if os.path.isdir(os.path.join(fixtures_folder, d)) and not d.startswith("_")
23
+ ]
17
24
 
18
25
  FAOSTAT_CLASS_PATH = f"hestia_earth.models.{FAOSTAT_MODEL}.utils"
19
26
  faostat_fixtures_folder = f"{fixtures_path}/{FAOSTAT_MODEL}/utils"
@@ -242,6 +249,20 @@ def test_scale_values_to_one(dictionary, expected_result):
242
249
  assert round(v, 3) == round(expected_result[k], 3)
243
250
 
244
251
 
252
+ @pytest.mark.parametrize(
253
+ "land_type,expected",
254
+ [
255
+ (FOREST_LAND, "forest"),
256
+ (ANNUAL_CROPLAND, "annualCropland"),
257
+ (PERMANENT_CROPLAND, "permanentCropland"),
258
+ (PERMANENT_PASTURE, "permanentPasture"),
259
+ (OTHER_LAND, "otherLand"),
260
+ ]
261
+ )
262
+ def test_get_land_cover_lookup_suffix(land_type: str, expected: str):
263
+ assert _get_land_cover_lookup_suffix(land_type=land_type) == expected, land_type
264
+
265
+
245
266
  @pytest.mark.parametrize("subfolder", _folders)
246
267
  @patch(f"{CLASS_PATH}._new_management", side_effect=fake_new_management)
247
268
  def test_run(mock, subfolder: str):
@@ -254,3 +275,38 @@ def test_run(mock, subfolder: str):
254
275
 
255
276
  result = run(site)
256
277
  assert result == expected
278
+
279
+
280
+ def fake_region_lookup(lookup_name: str, term_id: str, column: str, **log_args):
281
+ """Returns obviously-wrong mock results from Brazil to be distinct from model."""
282
+ return ("2010:55.0")
283
+
284
+
285
+ @patch(f"{CLASS_PATH}.get_region_lookup_value", side_effect=fake_region_lookup)
286
+ @patch(f"{CLASS_PATH}._new_management", side_effect=fake_new_management)
287
+ def test_landCover_from_lookup_run(mock_mgmt, mock_region_lookup, caplog):
288
+ caplog.set_level(logging.INFO)
289
+ folder = f"{fixtures_folder}/_from_lookups"
290
+ with open(f"{folder}/site.jsonld", encoding='utf-8') as f:
291
+ site = json.load(f)
292
+
293
+ with open(f"{folder}/result.jsonld", encoding='utf-8') as f:
294
+ expected = json.load(f)
295
+
296
+ result = run(site)
297
+ mock_region_lookup.assert_called_with(
298
+ lookup_name='region-crop-cropGroupingFAOSTAT-landCover-otherLand.csv',
299
+ term_id='GADM-BRA',
300
+ column='Maize plant',
301
+ model='hestia',
302
+ key='landCover'
303
+ )
304
+ expected_message = ("site=Brazil-example, requirements=true, model=hestia, model_key=landCover, "
305
+ "has_management_nodes=True, land_use_type=Arable land, allowed_land_use_types=Arable land;"
306
+ "Permanent crops;Permanent meadows and pastures, has_no_prior_land_cover_data=True, "
307
+ "management_nodes=value:100_id:maizePlant_land-use-type:Arable land_endDate:2010-12-31"
308
+ "_startDate:2010-01-01, landCover_from_lookups=Forest land:0.55;Arable land:0.55;"
309
+ "Permanent crops:0.55;Permanent meadows and pastures:0.55;Other land:0.55, "
310
+ "should_run_nodes=True")
311
+ assert expected_message in [r.msg for r in caplog.records]
312
+ assert result == expected
@@ -0,0 +1,131 @@
1
+ import json
2
+ from os.path import isfile
3
+ from pytest import mark
4
+ from unittest.mock import MagicMock, patch
5
+
6
+ from hestia_earth.models.ipcc2019.biocharOrganicCarbonPerHa import _should_run, MODEL, run, TERM_ID
7
+
8
+ from tests.utils import fake_new_measurement, fixtures_path
9
+
10
+ class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
11
+ property_path = "hestia_earth.models.utils.property"
12
+ fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
13
+
14
+ _DEFAULT_PROPERTIES = {
15
+ "biocharManureGasification": {
16
+ "organicCarbonContent": {
17
+ "value": 9,
18
+ "sd": 2.4,
19
+ "min": 0,
20
+ "max": 100
21
+ }
22
+ },
23
+ "biocharBambooLowTemperaturePyrolysis": {
24
+ "organicCarbonContent": {
25
+ "value": 77,
26
+ "sd": 16.5,
27
+ "min": 0,
28
+ "max": 100
29
+ }
30
+ },
31
+ "biocharStrawHighTemperaturePyrolysis": {
32
+ "organicCarbonContent": {
33
+ "value": 65,
34
+ "sd": 14.9,
35
+ "min": 0,
36
+ "max": 100
37
+ }
38
+ },
39
+ "biocharPaperSludgeMediumTemperaturePyrolysis": {
40
+ "organicCarbonContent": {
41
+ "value": 35,
42
+ "sd": 7.1,
43
+ "min": 0,
44
+ "max": 100
45
+ }
46
+ },
47
+ "biocharUnspecifiedFeedstockUnspecifiedProductionMethod": {
48
+ "organicCarbonContent": {
49
+ "value": 40.6,
50
+ "sd": 10.5,
51
+ "min": 0,
52
+ "max": 100
53
+ }
54
+ }
55
+ }
56
+
57
+
58
+ def fake_find_term_property(term: dict, property: str, *_):
59
+ term_id = term.get('@id', None)
60
+ return _DEFAULT_PROPERTIES.get(term_id, {}).get(property, {})
61
+
62
+
63
+ def _load_fixture(path: str, default=None):
64
+ if isfile(path):
65
+ with open(path, encoding="utf-8") as f:
66
+ return json.load(f)
67
+ return default
68
+
69
+
70
+ # subfolder, should_run
71
+ PARAMS_SHOULD_RUN = [
72
+ ("with-stats", True),
73
+ ("no-biochar", True),
74
+ ("no-cycles", False),
75
+ ("with-organic-soils", False),
76
+ ("with-relative-func-unit", False),
77
+ ("with-site-type-forest", False)
78
+ ]
79
+ IDS_SHOULD_RUN = [p[0] for p in PARAMS_SHOULD_RUN]
80
+
81
+
82
+ @mark.parametrize("subfolder, should_run", PARAMS_SHOULD_RUN, ids=IDS_SHOULD_RUN)
83
+ @patch(f"{property_path}.find_term_property", side_effect=fake_find_term_property)
84
+ @patch(f"{property_path}.download_term")
85
+ @patch(f"{class_path}.related_cycles")
86
+ def test_should_run(
87
+ related_cycles_mock: MagicMock,
88
+ download_term_mock: MagicMock,
89
+ _find_term_property_mock: MagicMock,
90
+ subfolder: str,
91
+ should_run: bool
92
+ ):
93
+ folder = f"{fixtures_folder}/{subfolder}"
94
+
95
+ site = _load_fixture(f"{folder}/site.jsonld", {})
96
+ related_cycles_mock.return_value = _load_fixture(f"{folder}/cycles.jsonld", [])
97
+
98
+ result, *_ = _should_run(site)
99
+ assert result == should_run
100
+
101
+ # Ensure that the property utils are properly mocked.
102
+ download_term_mock.assert_not_called()
103
+
104
+
105
+ PARAMS_RUN = [subfolder for subfolder, should_run in PARAMS_SHOULD_RUN if should_run]
106
+
107
+
108
+ @mark.parametrize("subfolder", PARAMS_RUN)
109
+ @patch(f"{property_path}.find_term_property", side_effect=fake_find_term_property)
110
+ @patch(f"{property_path}.download_term")
111
+ @patch(f"{class_path}.related_cycles")
112
+ @patch(f"{class_path}._new_measurement", side_effect=fake_new_measurement)
113
+ def test_run(
114
+ _new_measurement_mock: MagicMock,
115
+ related_cycles_mock: MagicMock,
116
+ download_term_mock: MagicMock,
117
+ _find_term_property_mock: MagicMock,
118
+ subfolder: str
119
+ ):
120
+ folder = f"{fixtures_folder}/{subfolder}"
121
+
122
+ site = _load_fixture(f"{folder}/site.jsonld", {})
123
+ related_cycles_mock.return_value = _load_fixture(f"{folder}/cycles.jsonld", [])
124
+
125
+ expected = _load_fixture(f"{folder}/result.jsonld", [])
126
+
127
+ result = run(site)
128
+ assert result == expected
129
+
130
+ # Ensure that the property utils are properly mocked.
131
+ download_term_mock.assert_not_called()
@@ -0,0 +1,6 @@
1
+ from hestia_earth.models.utils import current_date, max_date
2
+
3
+
4
+ def test_max_date():
5
+ assert max_date('2100-01-01') == current_date()
6
+ assert max_date('2000-01-01') == '2000-01-01'
@@ -1,34 +0,0 @@
1
- from .utils import should_run_landTransformationFromCropland, run_landTransformationFromCropland
2
-
3
- REQUIREMENTS = {
4
- "ImpactAssessment": {
5
- "endDate": "",
6
- "country": {"@type": "Term", "termType": "region"},
7
- "emissionsResourceUse": [{
8
- "@type": "Indicator",
9
- "term.@id": "landTransformation100YearAverageDuringCycle",
10
- "value": "",
11
- "previousLandCover": {
12
- "@type": "Term",
13
- "termType": "landCover",
14
- "@id": "cropland"
15
- }
16
- }]
17
- }
18
- }
19
- LOOKUPS = {
20
- "region-faostatArea": ""
21
- }
22
- RETURNS = {
23
- "Indicator": [{
24
- "value": "",
25
- "landCover": "",
26
- "previousLandCover": ""
27
- }]
28
- }
29
- TERM_ID = 'landTransformation100YearAverageDuringCycle'
30
-
31
-
32
- def run(impact: dict):
33
- should_run, indicators = should_run_landTransformationFromCropland(TERM_ID, impact)
34
- return run_landTransformationFromCropland(TERM_ID, impact, indicators, 100) if should_run else []
@@ -1,34 +0,0 @@
1
- from .utils import should_run_landTransformationFromCropland, run_landTransformationFromCropland
2
-
3
- REQUIREMENTS = {
4
- "ImpactAssessment": {
5
- "endDate": "",
6
- "country": {"@type": "Term", "termType": "region"},
7
- "emissionsResourceUse": [{
8
- "@type": "Indicator",
9
- "term.@id": "landTransformation20YearAverageDuringCycle",
10
- "value": "",
11
- "previousLandCover": {
12
- "@type": "Term",
13
- "termType": "landCover",
14
- "@id": "cropland"
15
- }
16
- }]
17
- }
18
- }
19
- LOOKUPS = {
20
- "region-faostatArea": ""
21
- }
22
- RETURNS = {
23
- "Indicator": [{
24
- "value": "",
25
- "landCover": "",
26
- "previousLandCover": ""
27
- }]
28
- }
29
- TERM_ID = 'landTransformation20YearAverageDuringCycle'
30
-
31
-
32
- def run(impact: dict):
33
- should_run, indicators = should_run_landTransformationFromCropland(TERM_ID, impact)
34
- return run_landTransformationFromCropland(TERM_ID, impact, indicators, 20) if should_run else []
@@ -1,21 +0,0 @@
1
- from unittest.mock import patch
2
- import json
3
- from tests.utils import fixtures_path, fake_new_indicator
4
-
5
- from hestia_earth.models.faostat2018 import MODEL
6
- from hestia_earth.models.faostat2018.landTransformation100YearAverageDuringCycle import TERM_ID, run
7
-
8
- class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
9
- fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
10
-
11
-
12
- @patch(f"hestia_earth.models.{MODEL}.utils._new_indicator", side_effect=fake_new_indicator)
13
- def test_run(*args):
14
- with open(f"{fixtures_folder}/impact-assessment.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
@@ -1,21 +0,0 @@
1
- from unittest.mock import patch
2
- import json
3
- from tests.utils import fixtures_path, fake_new_indicator
4
-
5
- from hestia_earth.models.faostat2018 import MODEL
6
- from hestia_earth.models.faostat2018.landTransformation20YearAverageDuringCycle import TERM_ID, run
7
-
8
- class_path = f"hestia_earth.models.{MODEL}.{TERM_ID}"
9
- fixtures_folder = f"{fixtures_path}/{MODEL}/{TERM_ID}"
10
-
11
-
12
- @patch(f"hestia_earth.models.{MODEL}.utils._new_indicator", side_effect=fake_new_indicator)
13
- def test_run(*args):
14
- with open(f"{fixtures_folder}/impact-assessment.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