pyholos 0.0.1__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 pyholos might be problematic. Click here for more details.
- pyholos/__init__.py +0 -0
- pyholos/common.py +141 -0
- pyholos/common2.py +157 -0
- pyholos/components/__init__.py +0 -0
- pyholos/components/animals/__init__.py +0 -0
- pyholos/components/animals/beef.py +766 -0
- pyholos/components/animals/common.py +2301 -0
- pyholos/components/animals/dairy.py +341 -0
- pyholos/components/animals/sheep.py +412 -0
- pyholos/components/common.py +170 -0
- pyholos/components/land_management/__init__.py +0 -0
- pyholos/components/land_management/carbon/__init__.py +0 -0
- pyholos/components/land_management/carbon/climate.py +863 -0
- pyholos/components/land_management/carbon/management.py +21 -0
- pyholos/components/land_management/carbon/relative_biomass_information.py +410 -0
- pyholos/components/land_management/carbon/tillage.py +88 -0
- pyholos/components/land_management/common.py +220 -0
- pyholos/components/land_management/crop.py +1233 -0
- pyholos/components/land_management/field_system.py +458 -0
- pyholos/components/land_management/utils.py +66 -0
- pyholos/config.py +49 -0
- pyholos/core_constants.py +20 -0
- pyholos/defaults.py +116 -0
- pyholos/farm/__init__.py +0 -0
- pyholos/farm/enums.py +54 -0
- pyholos/farm/farm.py +101 -0
- pyholos/farm/farm_inputs.py +633 -0
- pyholos/farm/farm_settings.py +542 -0
- pyholos/launching.py +86 -0
- pyholos/postprocessing/__init__.py +0 -0
- pyholos/postprocessing/plots.py +164 -0
- pyholos/postprocessing/postprocessing.py +38 -0
- pyholos/resources/holos/Table_16_Livestock_Coefficients_BeefAndDairy_Cattle_Provider.csv +21 -0
- pyholos/resources/holos/Table_21_Average_Milk_Production_For_Dairy_Cows_By_Province.csv +23 -0
- pyholos/resources/holos/Table_22_Livestock_Coefficients_For_Sheep.csv +28 -0
- pyholos/resources/holos/Table_29_Percentage_Total_Manure_Produced_In_Systems.csv +56 -0
- pyholos/resources/holos/Table_30_Default_Bedding_Material_Composition_Provider.csv +28 -0
- pyholos/resources/holos/Table_50_Fuel_Energy_Requirement_Estimates_By_Region.csv +81 -0
- pyholos/resources/holos/Table_51_Herbicide_Energy_Requirement_Estimates_By_Region.csv +81 -0
- pyholos/resources/holos/Table_61_Fractions_of_dairy_cattle_N_volatilized.csv +25 -0
- pyholos/resources/holos/Table_62_Fractions_of_swine_N_volatilized.csv +25 -0
- pyholos/resources/holos/Table_6_Manure_Types_And_Default_Composition.csv +126 -0
- pyholos/resources/holos/Table_7_Relative_Biomass_Information.csv +112 -0
- pyholos/resources/holos/Table_9_Default_Values_For_Nitrogen_Lignin_In_Crops.csv +72 -0
- pyholos/resources/holos/Table_Tillage_Factor.csv +13 -0
- pyholos/resources/holos/feeds.csv +223 -0
- pyholos/resources/holos/main_tables.py +493 -0
- pyholos/resources/holos/small_area_yields.csv +167159 -0
- pyholos/resources/soil_landscapes_of_canada_v3r2.zip +0 -0
- pyholos/soil.py +439 -0
- pyholos/utils.py +83 -0
- pyholos-0.0.1.dist-info/METADATA +16 -0
- pyholos-0.0.1.dist-info/RECORD +55 -0
- pyholos-0.0.1.dist-info/WHEEL +4 -0
- pyholos-0.0.1.dist-info/licenses/LICENSE +677 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
from enum import auto
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from pandas import DataFrame, MultiIndex
|
|
5
|
+
|
|
6
|
+
from pyholos.common import Region, get_region
|
|
7
|
+
from pyholos.components.common import convert_province_name
|
|
8
|
+
from pyholos.components.land_management.crop import (CropType,
|
|
9
|
+
convert_crop_type_name)
|
|
10
|
+
from pyholos.config import PathsHolosResources
|
|
11
|
+
from pyholos.common2 import CanadianProvince
|
|
12
|
+
from pyholos.soil import (SoilFunctionalCategory,
|
|
13
|
+
convert_soil_functional_category_name)
|
|
14
|
+
from pyholos.utils import (AutoNameEnum, keep_alphabetical_characters,
|
|
15
|
+
read_holos_resource_table)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class IrrigationType(AutoNameEnum):
|
|
19
|
+
Irrigated = auto()
|
|
20
|
+
RainFed = auto()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class TillageType(AutoNameEnum):
|
|
24
|
+
"""
|
|
25
|
+
Holos Source Code:
|
|
26
|
+
https://github.com/holos-aafc/Holos/blob/b183dab99d211158d1fed9da5370ce599ac7c914/H.Core/Enumerations/TillageType.cs#L6
|
|
27
|
+
"""
|
|
28
|
+
NotSelected = auto()
|
|
29
|
+
Reduced = auto()
|
|
30
|
+
NoTill = auto()
|
|
31
|
+
Intensive = auto()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def convert_tillage_type_name(
|
|
35
|
+
name: str
|
|
36
|
+
) -> TillageType:
|
|
37
|
+
match keep_alphabetical_characters(name=name):
|
|
38
|
+
case "notill" | "nt":
|
|
39
|
+
return TillageType.NoTill
|
|
40
|
+
case "reduced" | "rt":
|
|
41
|
+
return TillageType.Reduced
|
|
42
|
+
case "intensive" | "it" | "conventional":
|
|
43
|
+
return TillageType.Intensive
|
|
44
|
+
case _:
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class HarvestMethod(AutoNameEnum):
|
|
49
|
+
"""
|
|
50
|
+
Holos source code:
|
|
51
|
+
https://github.com/holos-aafc/Holos/blob/b183dab99d211158d1fed9da5370ce599ac7c914/H.Core/Enumerations/HarvestMethods.cs#L6
|
|
52
|
+
"""
|
|
53
|
+
Silage = auto()
|
|
54
|
+
Swathing = auto()
|
|
55
|
+
GreenManure = auto()
|
|
56
|
+
CashCrop = auto()
|
|
57
|
+
StubbleGrazing = auto()
|
|
58
|
+
NONE = auto() # Used for fallow, etc.
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class ManureApplicationTypes(AutoNameEnum):
|
|
62
|
+
"""
|
|
63
|
+
Holos source code:
|
|
64
|
+
https://github.com/holos-aafc/Holos/blob/c06f6619907fba89c3ddc29b4239a903a8c20a7a/H.Core/Enumerations/ManureApplicationTypes.cs#L9
|
|
65
|
+
"""
|
|
66
|
+
NotSelected = auto()
|
|
67
|
+
OptionA = auto()
|
|
68
|
+
OptionB = auto()
|
|
69
|
+
OptionC = auto()
|
|
70
|
+
TilledLandSolidSpread = auto() # Also known as 'Solid spread (intensive tillage)
|
|
71
|
+
UntilledLandSolidSpread = auto() # Also known as 'Solid spread (no tillage or reduced tillage)
|
|
72
|
+
SlurryBroadcasting = auto()
|
|
73
|
+
DropHoseBanding = auto()
|
|
74
|
+
ShallowInjection = auto()
|
|
75
|
+
DeepInjection = auto()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class TimePeriodCategory(AutoNameEnum):
|
|
79
|
+
"""
|
|
80
|
+
Holos source code:
|
|
81
|
+
https://github.com/holos-aafc/Holos/blob/c06f6619907fba89c3ddc29b4239a903a8c20a7a/H.Core/Enumerations/TimePeriodCategory.cs#L3C4-L7C16
|
|
82
|
+
"""
|
|
83
|
+
Past = auto()
|
|
84
|
+
Current = auto()
|
|
85
|
+
Future = auto()
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class FertilizerBlends(AutoNameEnum):
|
|
89
|
+
"""
|
|
90
|
+
Holos source code:
|
|
91
|
+
https://github.com/holos-aafc/Holos/blob/771f74699faafb12e5efe53157b03e0d29579f4b/H.Core/Enumerations/FertilizerBlends.cs#L6
|
|
92
|
+
"""
|
|
93
|
+
Urea = auto()
|
|
94
|
+
Ammonia = auto()
|
|
95
|
+
UreaAmmoniumNitrate = auto()
|
|
96
|
+
AmmoniumNitrate = auto()
|
|
97
|
+
CalciumAmmoniumNitrate = auto()
|
|
98
|
+
AmmoniumSulphate = auto()
|
|
99
|
+
MesS15 = auto()
|
|
100
|
+
MonoAmmoniumPhosphate = auto()
|
|
101
|
+
DiAmmoniumPhosphate = auto()
|
|
102
|
+
TripleSuperPhosphate = auto()
|
|
103
|
+
Potash = auto()
|
|
104
|
+
Npk = auto()
|
|
105
|
+
CalciumNitrate = auto()
|
|
106
|
+
AmmoniumNitroSulphate = auto()
|
|
107
|
+
Custom = auto() # Custom synthetic (there is also a custom organic)
|
|
108
|
+
Lime = auto()
|
|
109
|
+
CustomOrganic = auto() # Custom organic
|
|
110
|
+
AmmoniumNitratePrilled = auto()
|
|
111
|
+
AmmoniumNitrateGranulated = auto()
|
|
112
|
+
SuperPhosphate = auto()
|
|
113
|
+
NpkMixedAcid = auto()
|
|
114
|
+
NpkNitrophosphate = auto()
|
|
115
|
+
PotassiumSulphate = auto()
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def read_energy_table(path_table: Path) -> DataFrame:
|
|
119
|
+
df = read_holos_resource_table(path_file=path_table, header=[0, 1, 2])
|
|
120
|
+
df.index = [convert_crop_type_name(s) for s in df.pop(('Unnamed: 0_level_0', 'Unnamed: 0_level_1', 'CROP'))]
|
|
121
|
+
df.columns = MultiIndex.from_tuples(
|
|
122
|
+
[(convert_province_name(p), convert_soil_functional_category_name(s), convert_tillage_type_name(t))
|
|
123
|
+
for p, s, t in df.columns])
|
|
124
|
+
|
|
125
|
+
return df
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class HolosTables:
|
|
129
|
+
Table_50_Fuel_Energy_Requirement_Estimates_By_Region: DataFrame = read_energy_table(
|
|
130
|
+
path_table=PathsHolosResources.Table_50_Fuel_Energy_Requirement_Estimates_By_Region)
|
|
131
|
+
|
|
132
|
+
Table_51_Herbicide_Energy_Requirement_Estimates_By_Region: DataFrame = read_energy_table(
|
|
133
|
+
path_table=PathsHolosResources.Table_51_Herbicide_Energy_Requirement_Estimates_By_Region)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def get_energy_estimate(
|
|
137
|
+
data: DataFrame,
|
|
138
|
+
province: CanadianProvince,
|
|
139
|
+
soil_category: SoilFunctionalCategory,
|
|
140
|
+
tillage_type: TillageType,
|
|
141
|
+
crop_type: CropType
|
|
142
|
+
) -> float:
|
|
143
|
+
"""Returns the energy estimate for fuel or pesticide.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
data: HolosTables member
|
|
147
|
+
province: CanadianProvince member
|
|
148
|
+
soil_category: SoilFunctionalCategory member
|
|
149
|
+
tillage_type: TillageType member
|
|
150
|
+
crop_type: CropType member
|
|
151
|
+
Returns:
|
|
152
|
+
(GJ ha-1) energy estimate
|
|
153
|
+
|
|
154
|
+
Holos source code:
|
|
155
|
+
Fuel: https://github.com/holos-aafc/Holos/blob/e6e79c3185b68999eaea1e68dbf77c89d1764b53/H.Core/Providers/Energy/Table_50_Fuel_Energy_Estimates_Provider.cs#L62
|
|
156
|
+
Fuel: https://github.com/holos-aafc/Holos/blob/e6e79c3185b68999eaea1e68dbf77c89d1764b53/H.Core/Providers/Energy/Table_51_Herbicide_Energy_Estimates_Provider.cs#L60
|
|
157
|
+
"""
|
|
158
|
+
soil_lookup_type = (
|
|
159
|
+
SoilFunctionalCategory.EasternCanada if get_region(province=province) == Region.EasternCanada
|
|
160
|
+
else soil_category.get_simplified_soil_category())
|
|
161
|
+
|
|
162
|
+
# No summer fallow in table
|
|
163
|
+
if crop_type.is_fallow():
|
|
164
|
+
crop_type = CropType.Fallow
|
|
165
|
+
|
|
166
|
+
try:
|
|
167
|
+
res = data.loc[crop_type, (province, soil_lookup_type, tillage_type.value)]
|
|
168
|
+
except KeyError:
|
|
169
|
+
res = 0.
|
|
170
|
+
|
|
171
|
+
return 0. if res is None else res
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def get_fuel_energy_estimate(
|
|
175
|
+
province: CanadianProvince,
|
|
176
|
+
soil_category: SoilFunctionalCategory,
|
|
177
|
+
tillage_type: TillageType,
|
|
178
|
+
crop_type: CropType
|
|
179
|
+
) -> float:
|
|
180
|
+
"""Returns the fuel energy estimate.
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
province: CanadianProvince member
|
|
184
|
+
soil_category: SoilFunctionalCategory member
|
|
185
|
+
tillage_type: TillageType member
|
|
186
|
+
crop_type: CropType member
|
|
187
|
+
Returns:
|
|
188
|
+
(GJ ha-1) fuel energy estimate
|
|
189
|
+
|
|
190
|
+
Holos source code:
|
|
191
|
+
https://github.com/holos-aafc/Holos/blob/e6e79c3185b68999eaea1e68dbf77c89d1764b53/H.Core/Providers/Energy/Table_50_Fuel_Energy_Estimates_Provider.cs#L62
|
|
192
|
+
"""
|
|
193
|
+
|
|
194
|
+
return get_energy_estimate(
|
|
195
|
+
data=HolosTables.Table_50_Fuel_Energy_Requirement_Estimates_By_Region,
|
|
196
|
+
**locals())
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def get_herbicide_energy_estimate(
|
|
200
|
+
province: CanadianProvince,
|
|
201
|
+
soil_category: SoilFunctionalCategory,
|
|
202
|
+
tillage_type: TillageType,
|
|
203
|
+
crop_type: CropType
|
|
204
|
+
) -> float:
|
|
205
|
+
"""Returns the herbicide energy estimate.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
province: CanadianProvince member
|
|
209
|
+
soil_category: SoilFunctionalCategory member
|
|
210
|
+
tillage_type: TillageType member
|
|
211
|
+
crop_type: CropType member
|
|
212
|
+
Returns:
|
|
213
|
+
(GJ ha-1) herbicide energy estimate
|
|
214
|
+
|
|
215
|
+
Holos source code:
|
|
216
|
+
https://github.com/holos-aafc/Holos/blob/e6e79c3185b68999eaea1e68dbf77c89d1764b53/H.Core/Providers/Energy/Table_51_Herbicide_Energy_Estimates_Provider.cs#L60
|
|
217
|
+
"""
|
|
218
|
+
return get_energy_estimate(
|
|
219
|
+
data=HolosTables.Table_51_Herbicide_Energy_Requirement_Estimates_By_Region,
|
|
220
|
+
**locals())
|