PCSE 6.0.9__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.
Files changed (187) hide show
  1. PCSE-6.0.9.dist-info/LICENSE +19 -0
  2. PCSE-6.0.9.dist-info/METADATA +187 -0
  3. PCSE-6.0.9.dist-info/RECORD +187 -0
  4. PCSE-6.0.9.dist-info/WHEEL +5 -0
  5. PCSE-6.0.9.dist-info/top_level.txt +3 -0
  6. exp/__init__.py +0 -0
  7. exp/__main__.py +22 -0
  8. exp/process_experiment_collections.py +210 -0
  9. exp/reduce_yaml.py +43 -0
  10. pcse/__init__.py +104 -0
  11. pcse/agromanager.py +961 -0
  12. pcse/base/__init__.py +16 -0
  13. pcse/base/config_loader.py +117 -0
  14. pcse/base/dispatcher.py +33 -0
  15. pcse/base/engine.py +105 -0
  16. pcse/base/parameter_providers.py +283 -0
  17. pcse/base/simulationobject.py +280 -0
  18. pcse/base/states_rates.py +421 -0
  19. pcse/base/variablekiosk.py +243 -0
  20. pcse/base/weather.py +397 -0
  21. pcse/conf/Alcepas10_PP.conf +38 -0
  22. pcse/conf/FAO_WRSI.conf +42 -0
  23. pcse/conf/Lingra_NWLP_FD.conf +38 -0
  24. pcse/conf/Lingra_PP.conf +36 -0
  25. pcse/conf/Lingra_WLP_FD.conf +39 -0
  26. pcse/conf/Lintul3.conf +40 -0
  27. pcse/conf/Wofost72_PP.conf +44 -0
  28. pcse/conf/Wofost72_Pheno.conf +38 -0
  29. pcse/conf/Wofost72_WLP_CWB.conf +46 -0
  30. pcse/conf/Wofost73_PP.conf +44 -0
  31. pcse/conf/Wofost73_WLP_CWB.conf +42 -0
  32. pcse/conf/Wofost73_WLP_MLWB.conf +42 -0
  33. pcse/conf/Wofost81_NWLP_CWB_CNB.conf +46 -0
  34. pcse/conf/Wofost81_NWLP_MLWB_CNB.conf +46 -0
  35. pcse/conf/Wofost81_NWLP_MLWB_SNOMIN.conf +46 -0
  36. pcse/conf/Wofost81_PP.conf +44 -0
  37. pcse/conf/Wofost81_WLP_CWB.conf +46 -0
  38. pcse/conf/Wofost81_WLP_MLWB.conf +47 -0
  39. pcse/conf/Wofost_winterkill.conf +52 -0
  40. pcse/conf/__init__.py +0 -0
  41. pcse/crop/__init__.py +18 -0
  42. pcse/crop/abioticdamage.py +640 -0
  43. pcse/crop/alcepas.py +617 -0
  44. pcse/crop/assimilation.py +618 -0
  45. pcse/crop/evapotranspiration.py +728 -0
  46. pcse/crop/greenlayercrop.py +123 -0
  47. pcse/crop/leaf_dynamics.py +767 -0
  48. pcse/crop/lingra.py +668 -0
  49. pcse/crop/lingraN.py +691 -0
  50. pcse/crop/lingra_ndynamics.py +454 -0
  51. pcse/crop/lintul3.py +893 -0
  52. pcse/crop/n_dynamics.py +212 -0
  53. pcse/crop/npk_dynamics.py +410 -0
  54. pcse/crop/nutrients/__init__.py +2 -0
  55. pcse/crop/nutrients/n_demand_uptake.py +251 -0
  56. pcse/crop/nutrients/n_stress.py +131 -0
  57. pcse/crop/nutrients/npk_demand_uptake.py +372 -0
  58. pcse/crop/nutrients/npk_stress.py +247 -0
  59. pcse/crop/nutrients/npk_translocation.py +233 -0
  60. pcse/crop/partitioning.py +310 -0
  61. pcse/crop/phenology.py +495 -0
  62. pcse/crop/respiration.py +107 -0
  63. pcse/crop/root_dynamics.py +313 -0
  64. pcse/crop/stem_dynamics.py +165 -0
  65. pcse/crop/storage_organ_dynamics.py +154 -0
  66. pcse/crop/wofost72.py +298 -0
  67. pcse/crop/wofost73.py +333 -0
  68. pcse/crop/wofost81.py +365 -0
  69. pcse/crop/wofost_winterkill.py +313 -0
  70. pcse/db/__init__.py +11 -0
  71. pcse/db/cgms12/__init__.py +13 -0
  72. pcse/db/cgms12/data_providers.py +809 -0
  73. pcse/db/cgms14/__init__.py +14 -0
  74. pcse/db/cgms14/data_providers.py +790 -0
  75. pcse/db/cgms18/__init__.py +12 -0
  76. pcse/db/cgms18/data_providers.py +34 -0
  77. pcse/db/cgms8/__init__.py +21 -0
  78. pcse/db/cgms8/data_providers.py +319 -0
  79. pcse/db/hdf5/__init__.py +2 -0
  80. pcse/db/hdf5/cgms2hdfstore.py +285 -0
  81. pcse/db/hdf5/hdf5_readers.py +609 -0
  82. pcse/db/pcse/__init__.py +15 -0
  83. pcse/db/pcse/database_definition.py +315 -0
  84. pcse/db/pcse/db_input.py +818 -0
  85. pcse/db/pcse/pcse_dump.sql +47816 -0
  86. pcse/db/wofost_parameters.py +18 -0
  87. pcse/decorators.py +99 -0
  88. pcse/empty_model.py +39 -0
  89. pcse/engine.py +558 -0
  90. pcse/exceptions.py +44 -0
  91. pcse/fileinput.py +3 -0
  92. pcse/input/__init__.py +34 -0
  93. pcse/input/cabo_reader.py +247 -0
  94. pcse/input/cabo_weather.py +427 -0
  95. pcse/input/csvweatherdataprovider.py +268 -0
  96. pcse/input/excelweatherdataprovider.py +259 -0
  97. pcse/input/nasapower.py +350 -0
  98. pcse/input/pcsefilereader.py +125 -0
  99. pcse/input/sitedataproviders.py +223 -0
  100. pcse/input/soildataproviders.py +28 -0
  101. pcse/input/yaml_agro_loader.py +29 -0
  102. pcse/input/yaml_cropdataprovider.py +306 -0
  103. pcse/models.py +260 -0
  104. pcse/pydispatch/__init__.py +6 -0
  105. pcse/pydispatch/dispatcher.py +492 -0
  106. pcse/pydispatch/errors.py +10 -0
  107. pcse/pydispatch/robust.py +57 -0
  108. pcse/pydispatch/robustapply.py +57 -0
  109. pcse/pydispatch/saferef.py +172 -0
  110. pcse/rerunner.py +83 -0
  111. pcse/settings/__init__.py +60 -0
  112. pcse/settings/default_settings.py +88 -0
  113. pcse/signals.py +205 -0
  114. pcse/soil/__init__.py +11 -0
  115. pcse/soil/classic_waterbalance.py +715 -0
  116. pcse/soil/lintul3soil.py +271 -0
  117. pcse/soil/multilayer_waterbalance.py +910 -0
  118. pcse/soil/n_soil_dynamics.py +178 -0
  119. pcse/soil/snomin.py +1107 -0
  120. pcse/soil/snowmaus.py +163 -0
  121. pcse/soil/soil_profile.py +418 -0
  122. pcse/soil/soil_wrappers.py +96 -0
  123. pcse/soil/soiln_profile.py +203 -0
  124. pcse/start_wofost.py +74 -0
  125. pcse/taskmanager.py +159 -0
  126. pcse/tests/__init__.py +41 -0
  127. pcse/tests/run_wofost.py +116 -0
  128. pcse/tests/test_abioticdamage.py +76 -0
  129. pcse/tests/test_agromanager.py +287 -0
  130. pcse/tests/test_assimilation.py +68 -0
  131. pcse/tests/test_data/10870_munchen_flughafen.csv +528 -0
  132. pcse/tests/test_data/2297_sweden.csv +528 -0
  133. pcse/tests/test_data/8011_asturias.csv +528 -0
  134. pcse/tests/test_data/8443_ronda.csv +403 -0
  135. pcse/tests/test_data/LINTUL3_reference_results.csv +226 -0
  136. pcse/tests/test_data/NL1.976 +390 -0
  137. pcse/tests/test_data/NL1.977 +389 -0
  138. pcse/tests/test_data/NL1.978 +391 -0
  139. pcse/tests/test_data/NL1.979 +389 -0
  140. pcse/tests/test_data/NL1.980 +390 -0
  141. pcse/tests/test_data/NL1.981 +389 -0
  142. pcse/tests/test_data/NL1.982 +389 -0
  143. pcse/tests/test_data/NL1.983 +389 -0
  144. pcse/tests/test_data/NL1.984 +390 -0
  145. pcse/tests/test_data/NL1.985 +389 -0
  146. pcse/tests/test_data/NL1.986 +391 -0
  147. pcse/tests/test_data/NL1.987 +416 -0
  148. pcse/tests/test_data/NL1.988 +413 -0
  149. pcse/tests/test_data/NL1.989 +430 -0
  150. pcse/tests/test_data/NL1.990 +397 -0
  151. pcse/tests/test_data/NL1.991 +272 -0
  152. pcse/tests/test_data/NL1.992 +397 -0
  153. pcse/tests/test_data/NL1.993 +394 -0
  154. pcse/tests/test_data/NL1.994 +394 -0
  155. pcse/tests/test_data/NL1.995 +394 -0
  156. pcse/tests/test_data/NL1.996 +397 -0
  157. pcse/tests/test_data/NL1.997 +394 -0
  158. pcse/tests/test_data/NL1.998 +394 -0
  159. pcse/tests/test_data/NL1.999 +394 -0
  160. pcse/tests/test_data/__init__.py +6 -0
  161. pcse/tests/test_data/evapotranspiration_testdata.py +124 -0
  162. pcse/tests/test_data/frostol_testdata.py +268 -0
  163. pcse/tests/test_data/lintul3.csv +184 -0
  164. pcse/tests/test_data/lintul3_springwheat.agro +19 -0
  165. pcse/tests/test_data/lintul3_springwheat.crop +142 -0
  166. pcse/tests/test_data/lintul3_springwheat.site +11 -0
  167. pcse/tests/test_data/lintul3_springwheat.soil +8 -0
  168. pcse/tests/test_data/respiration_testdata.py +35 -0
  169. pcse/tests/test_data/wofost_npk.agro +19 -0
  170. pcse/tests/test_data/wofost_npk.crop +235 -0
  171. pcse/tests/test_data/wofost_npk.site +36 -0
  172. pcse/tests/test_data/wofost_npk.soil +52 -0
  173. pcse/tests/test_data/wofost_npk_potential.csv +217 -0
  174. pcse/tests/test_data/wofost_npk_waterlimited.csv +217 -0
  175. pcse/tests/test_evapotranspiration.py +129 -0
  176. pcse/tests/test_lintul3.py +88 -0
  177. pcse/tests/test_partitioning.py +58 -0
  178. pcse/tests/test_penmanmonteith.py +90 -0
  179. pcse/tests/test_respiration.py +50 -0
  180. pcse/tests/test_wofost72.py +291 -0
  181. pcse/timer.py +159 -0
  182. pcse/traitlets.py +68 -0
  183. pcse/util.py +901 -0
  184. tests/__init__.py +0 -0
  185. tests/__main__.py +34 -0
  186. tests/run_tests.py +115 -0
  187. tests/test_code.py +232 -0
exp/reduce_yaml.py ADDED
@@ -0,0 +1,43 @@
1
+ from pathlib import Path
2
+
3
+
4
+ def process_yaml_file(fname):
5
+
6
+ out_fname = fname.with_suffix(".yaml.new")
7
+ lines_out = []
8
+
9
+ weather_section = False
10
+ weather_valid_period = False
11
+ with open(fname) as fp_read:
12
+ for line in fp_read:
13
+ if not weather_section:
14
+ lines_out.append(line)
15
+ else:
16
+ if weather_valid_period:
17
+ lines_out.append(line)
18
+
19
+ if line.startswith("WeatherVariables:"):
20
+ weather_section = True
21
+
22
+ if line.startswith("- DAY: 1982-01-01"):
23
+ weather_valid_period = True
24
+ lines_out.append(line)
25
+
26
+ if line.startswith("- DAY: 1987-01-02"):
27
+ weather_valid_period = False
28
+ lines_out.pop(-1)
29
+
30
+ with open(fname, "w") as fp_out:
31
+ fp_out.writelines(lines_out)
32
+
33
+
34
+ def main():
35
+ this_dir = Path.cwd()
36
+ for fname in this_dir.glob("*.yaml"):
37
+ print(f"processing {fname.name}")
38
+ process_yaml_file(fname)
39
+
40
+
41
+ if __name__ == "__main__":
42
+ main()
43
+
pcse/__init__.py ADDED
@@ -0,0 +1,104 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) 2004-2024 Wageningen Environmental Research, Wageningen-UR
3
+ # Allard de Wit (allard.dewit@wur.nl) and Herman Berghuijs, June 2024
4
+ """
5
+ The Python Crop Simulation Environment (PCSE) has been developed
6
+ to facilitate implementing crop simulation models that were
7
+ developed in Wageningen. PCSE provides a set of building blocks
8
+ that on the one hand facilitates implementing the crop simulation
9
+ models themselves and other hand allows to interface these models with
10
+ external inputs and outputs (files, databases, webservers)
11
+
12
+ PCSE builds on existing ideas implemented in the FORTRAN
13
+ Translator (FST) and its user interface FSE. It inherits ideas
14
+ regarding the rigid distinction between rate calculation
15
+ and state integration and the initialization of parameters
16
+ in a PCSE model. Moreover PCSE provides support for reusing
17
+ input files and weather files that are used by FST models.
18
+
19
+ PCSE currently provides an implementation of the WOFOST and LINTUL crop
20
+ simulation models and the LINGRA grassland simulation model.
21
+
22
+ See Also
23
+ --------
24
+ * http://www.wageningenur.nl/wofost
25
+ * http://github.com/ajwdewit/pcse
26
+ * http://pcse.readthedocs.org
27
+ """
28
+ from __future__ import print_function
29
+ __author__ = "Allard de Wit <allard.dewit@wur.nl>"
30
+ __license__ = "European Union Public License"
31
+ __stable__ = True
32
+ __version__ = "6.0.9"
33
+
34
+
35
+ import sys, os
36
+ from . import util
37
+
38
+ # First define and run setup before importing the rest of the stuff
39
+ def setup():
40
+ """
41
+ Set up the .pcse folder and user settings file, add ~/.pcse to the
42
+ sys.path.
43
+ """
44
+
45
+ user_home = util.get_user_home()
46
+ pcse_user_home = os.path.join(user_home, ".pcse")
47
+ if not os.path.exists(pcse_user_home):
48
+ os.mkdir(pcse_user_home)
49
+
50
+ # Add PCSE home to python PATH
51
+ sys.path.append(pcse_user_home)
52
+
53
+ # Check existence of user settings file. If not exists, create it.
54
+ user_settings_file = os.path.join(pcse_user_home, "user_settings.py")
55
+ if not os.path.exists(user_settings_file):
56
+ pcse_dir = os.path.dirname(__file__)
57
+ default_settings_file = os.path.join(pcse_dir, "settings", "default_settings.py")
58
+ lines = open(default_settings_file).readlines()
59
+ with open(user_settings_file, "w") as fp:
60
+ for line in lines:
61
+ if line.startswith(("#", '"', "'", "import")):
62
+ cline = line
63
+ elif len(line.strip()) == 0: # empty line
64
+ cline = line
65
+ else:
66
+ cline = "# " + line
67
+ fp.write(cline)
68
+
69
+ setup()
70
+
71
+ import logging.config
72
+ from .settings import settings
73
+ logging.config.dictConfig(settings.LOG_CONFIG)
74
+
75
+ from . import db
76
+ from . import input
77
+ from . import tests
78
+ from . import agromanager
79
+ from . import soil
80
+ from . import crop
81
+ from .start_wofost import start_wofost
82
+
83
+ # If no PCSE demo database, build it!
84
+ pcse_db_file = os.path.join(settings.PCSE_USER_HOME, "pcse.db")
85
+ if not os.path.exists(pcse_db_file):
86
+ print("Building PCSE demo database at: %s ..." % pcse_db_file, end=" ")
87
+ pcse_home = os.path.dirname(__file__)
88
+ pcse_db_dump_file = os.path.join(pcse_home, "db", "pcse", "pcse_dump.sql")
89
+ try:
90
+ util.load_SQLite_dump_file(pcse_db_dump_file, pcse_db_file)
91
+ print("OK")
92
+ except Exception as e:
93
+ logger = logging.getLogger()
94
+ msg1 = "Failed to create the PCSE demo database: %s" % e
95
+ msg2 = "PCSE will likely be functional, but some tests and demos may fail."
96
+ logger.warning(msg1)
97
+ logger.warning(msg2)
98
+
99
+ if not __stable__:
100
+ print("Warning: You are running a PCSE development version: %s" % __version__)
101
+
102
+ def test(dsn=None):
103
+ """Run all available tests for PCSE."""
104
+ tests.test_all(dsn)