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
pyholos/defaults.py
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
from pyholos.core_constants import CoreConstants
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Defaults:
|
|
5
|
+
EmissionFactorForLeachingAndRunoff = 0.011 # Updated to IPCC 2019 value
|
|
6
|
+
"""(kg(N2O-N) kg(N)-1) emission factor for leaching and runoff"""
|
|
7
|
+
|
|
8
|
+
PercentageOfProductReturnedToSoilForPerennials = 35
|
|
9
|
+
"""(%) percentage of the perennial crops biomass returned to soil after harvest"""
|
|
10
|
+
|
|
11
|
+
PercentageOfRootsReturnedToSoilForPerennials = 100
|
|
12
|
+
"""(%) percentage of the perennial crops root biomass returned to soil after harvest"""
|
|
13
|
+
|
|
14
|
+
PercentageOfProductReturnedToSoilForAnnuals = 2
|
|
15
|
+
"""(%) percentage of the annual crops biomass returned to soil after harvest"""
|
|
16
|
+
|
|
17
|
+
PercentageOfRootsReturnedToSoilForAnnuals = 100
|
|
18
|
+
"""(%) percentage of the annual crops root biomass returned to soil after harvest"""
|
|
19
|
+
|
|
20
|
+
PercentageOfStrawReturnedToSoilForAnnuals = 100
|
|
21
|
+
"""(%) percentage of the annual crops straw biomass returned to soil after harvest"""
|
|
22
|
+
|
|
23
|
+
PercentageOfProductReturnedToSoilForRootCrops = 0
|
|
24
|
+
"""(%) percentage of the root crops biomass returned to soil after harvest"""
|
|
25
|
+
|
|
26
|
+
PercentageOfStrawReturnedToSoilForRootCrops = 100
|
|
27
|
+
"""(%) percentage of the root crops straw biomass returned to soil after harvest"""
|
|
28
|
+
|
|
29
|
+
PercentageOfProductYieldReturnedToSoilForSilageCrops = 35
|
|
30
|
+
"""(%) percentage of the silage crops biomass returned to soil after harvest"""
|
|
31
|
+
|
|
32
|
+
PercentageOfRootsReturnedToSoilForSilageCrops = 100
|
|
33
|
+
"""(%) percentage of the annual crops root biomass returned to soil after harvest"""
|
|
34
|
+
|
|
35
|
+
PercentageOfProductYieldReturnedToSoilForCoverCrops = 100
|
|
36
|
+
"""(%) percentage of the cover crops biomass returned to soil after harvest"""
|
|
37
|
+
|
|
38
|
+
PercentageOfProductYieldReturnedToSoilForCoverCropsForage = 35
|
|
39
|
+
"""(%) percentage of the cover crops forage biomass returned to soil after harvest"""
|
|
40
|
+
|
|
41
|
+
PercentageOfProductYieldReturnedToSoilForCoverCropsProduce = 0
|
|
42
|
+
"""(%) percentage of the cover crops produce biomass returned to soil after harvest"""
|
|
43
|
+
|
|
44
|
+
PercentageOfStrawReturnedToSoilForCoverCrops = 100
|
|
45
|
+
"""(%) percentage of the cover crops straw biomass returned to soil after harvest"""
|
|
46
|
+
|
|
47
|
+
PercentageOfRootsReturnedToSoilForCoverCrops = 100
|
|
48
|
+
"""(%) percentage of the cover crops root biomass returned to soil after harvest"""
|
|
49
|
+
|
|
50
|
+
PercentageOfProductReturnedToSoilForRangelandDueToHarvestLoss = 35
|
|
51
|
+
"""(%) percentage of the rangeland product biomass returned to soil due to harvest loss"""
|
|
52
|
+
|
|
53
|
+
PercentageOfProductReturnedToSoilForRangelandDueToGrazingLoss = CoreConstants.ValueNotDetermined
|
|
54
|
+
"""(%) percentage of the rangeland product biomass returned to soil due to grazing loss"""
|
|
55
|
+
|
|
56
|
+
PercentageOfRootsReturnedToSoilForRangeland = 100
|
|
57
|
+
"""(%) percentage of the rangeland root biomass returned to soil after harvest"""
|
|
58
|
+
|
|
59
|
+
PercentageOfProductReturnedToSoilForFodderCorn = 35
|
|
60
|
+
"""(%) percentage of the fodder corn product biomass returned to soil after harvest"""
|
|
61
|
+
|
|
62
|
+
PercentageOfRootsReturnedToSoilForFodderCorn = 100
|
|
63
|
+
"""(%) percentage of the fodder corn root biomass returned to soil after harvest"""
|
|
64
|
+
|
|
65
|
+
DecompositionRateConstantYoungPool = 0.8
|
|
66
|
+
DecompositionRateConstantOldPool = 0.00605
|
|
67
|
+
OldPoolCarbonN = 0.1
|
|
68
|
+
NORatio = 0.1
|
|
69
|
+
EmissionFactorForVolatilization = 0.01
|
|
70
|
+
FractionOfNLostByVolatilization = 0.21
|
|
71
|
+
MicrobeDeath = 0.2
|
|
72
|
+
Denitrification = 0.5
|
|
73
|
+
|
|
74
|
+
HumificationCoefficientAboveGround = 0.125
|
|
75
|
+
HumificationCoefficientBelowGround = 0.3
|
|
76
|
+
HumificationCoefficientManure = 0.31
|
|
77
|
+
|
|
78
|
+
DefaultRunInPeriod = 15
|
|
79
|
+
|
|
80
|
+
CarbonConcentration = CoreConstants.CarbonConcentration
|
|
81
|
+
|
|
82
|
+
# for annual crops
|
|
83
|
+
EmergenceDay = 141
|
|
84
|
+
"""(julian day) day of plant emergence for annual crops"""
|
|
85
|
+
|
|
86
|
+
RipeningDay = 197
|
|
87
|
+
"""(julian day) day of plant ripening for annual crops"""
|
|
88
|
+
|
|
89
|
+
Variance = 300
|
|
90
|
+
"""width of distribution function for annual crops"""
|
|
91
|
+
|
|
92
|
+
# for perennial crops
|
|
93
|
+
EmergenceDayForPerennials = 75
|
|
94
|
+
"""(julian day) day of plant emergence for perennial crops"""
|
|
95
|
+
|
|
96
|
+
RipeningDayForPerennials = 300
|
|
97
|
+
"""(julian day) day of plant ripening for perennial crops"""
|
|
98
|
+
|
|
99
|
+
VarianceForPerennials = 1500
|
|
100
|
+
"""width of distribution function for perennial crops"""
|
|
101
|
+
|
|
102
|
+
# for all crops
|
|
103
|
+
Alfa = 0.7
|
|
104
|
+
"""(-) minimum water storage fraction of wilting_point"""
|
|
105
|
+
|
|
106
|
+
DecompositionMinimumTemperature = -3.78
|
|
107
|
+
"""(degree Celsius) maximum cardinal temperature for decomposition"""
|
|
108
|
+
|
|
109
|
+
DecompositionMaximumTemperature = 30
|
|
110
|
+
"""(degree Celsius) minimum cardinal temperature for decomposition"""
|
|
111
|
+
|
|
112
|
+
MoistureResponseFunctionAtWiltingPoint = 0.18
|
|
113
|
+
"""(mm3/mm3) soil volumetric water content at reference wilting point"""
|
|
114
|
+
|
|
115
|
+
MoistureResponseFunctionAtSaturation = 0.42
|
|
116
|
+
"""(mm3/mm3) soil volumetric water content at reference saturation"""
|
pyholos/farm/__init__.py
ADDED
|
File without changes
|
pyholos/farm/enums.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
from enum import StrEnum, auto
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class YieldAssignmentMethod(StrEnum):
|
|
5
|
+
"""Used to lookup default yields for a particular year and crop type.
|
|
6
|
+
|
|
7
|
+
Holos source code:
|
|
8
|
+
https://github.com/holos-aafc/Holos/blob/768b3d8fe2565dad0ba01fb8490974f1047a114f/H.Core/Enumerations/YieldAssignmentMethod.cs#L6
|
|
9
|
+
"""
|
|
10
|
+
Average = auto()
|
|
11
|
+
"""Takes the average of the yields from the crop view items of the field component"""
|
|
12
|
+
|
|
13
|
+
Custom = auto()
|
|
14
|
+
"""Uses the values entered for each year (by the user on the details screen)"""
|
|
15
|
+
|
|
16
|
+
CARValue = auto()
|
|
17
|
+
"""Uses CAR region values"""
|
|
18
|
+
|
|
19
|
+
InputFile = auto()
|
|
20
|
+
"""Reads a yield input file from the user"""
|
|
21
|
+
|
|
22
|
+
InputFileThenAverage = auto()
|
|
23
|
+
"""Reads a yield input file from the user and the use the average of all crops in rotation"""
|
|
24
|
+
|
|
25
|
+
SmallAreaData = auto()
|
|
26
|
+
"""Use Small Area Data (SAD) yields (https://open.canada.ca/data/en/dataset/65f1cde1-95e0-4a1d-9a1a-c45b2f83a351)"""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class CarbonModellingStrategies(StrEnum):
|
|
30
|
+
"""
|
|
31
|
+
Holos source code:
|
|
32
|
+
https://github.com/holos-aafc/Holos/blob/768b3d8fe2565dad0ba01fb8490974f1047a114f/H.Core/Enumerations/CarbonModellingStrategies.cs#L11
|
|
33
|
+
"""
|
|
34
|
+
IPCCTier2 = auto()
|
|
35
|
+
ICBM = auto()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class ChosenClimateAcquisition(StrEnum):
|
|
39
|
+
"""
|
|
40
|
+
Holos source code:
|
|
41
|
+
https://github.com/holos-aafc/Holos/blob/768b3d8fe2565dad0ba01fb8490974f1047a114f/H.Core/Models/Farm.cs#L36C1-L58C10
|
|
42
|
+
"""
|
|
43
|
+
SLC = auto()
|
|
44
|
+
"""Uses the 'old' default (non-daily) temperatures where normals were used to extract daily values.
|
|
45
|
+
This is deprecated in favor of NASA climate data"""
|
|
46
|
+
|
|
47
|
+
Custom = auto()
|
|
48
|
+
"""Used with the CLI where the user can specify default monthly values in a climate settings file"""
|
|
49
|
+
|
|
50
|
+
NASA = auto()
|
|
51
|
+
"""Daily climate data is downloaded from NASA website API"""
|
|
52
|
+
|
|
53
|
+
InputFile = auto()
|
|
54
|
+
"""Used with the CLI where the user can specify default daily values in a custom CSV file"""
|
pyholos/farm/farm.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from pandas import DataFrame
|
|
4
|
+
|
|
5
|
+
from pyholos.components.common import convert_province_name
|
|
6
|
+
from pyholos.farm.farm_inputs import (BeefCattleInput, DairyCattleInput,
|
|
7
|
+
FieldsInput, SheepFlockInput,
|
|
8
|
+
WeatherSummary)
|
|
9
|
+
from pyholos.farm.farm_settings import ParamsFarmSettings
|
|
10
|
+
from pyholos.soil import (convert_soil_functional_category_name,
|
|
11
|
+
convert_soil_texture_name)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Farm:
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
farm_settings: ParamsFarmSettings,
|
|
18
|
+
beef_cattle_data: BeefCattleInput = None,
|
|
19
|
+
dairy_cattle_data: DairyCattleInput = None,
|
|
20
|
+
sheep_flock_data: SheepFlockInput = None,
|
|
21
|
+
fields_data: FieldsInput = None,
|
|
22
|
+
):
|
|
23
|
+
self.farm_settings = farm_settings
|
|
24
|
+
self.beef = beef_cattle_data
|
|
25
|
+
self.dairy = dairy_cattle_data
|
|
26
|
+
self.sheep = sheep_flock_data
|
|
27
|
+
self.fields = fields_data
|
|
28
|
+
self.other_livestock = None
|
|
29
|
+
self.poultry = None
|
|
30
|
+
self.shelterbelts = None
|
|
31
|
+
self.swine = None
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def _set_dir_name(entry: str) -> str:
|
|
35
|
+
return ' '.join([s.capitalize() for s in entry.split('_')])
|
|
36
|
+
|
|
37
|
+
def write_files(
|
|
38
|
+
self,
|
|
39
|
+
path_dir_farm: Path
|
|
40
|
+
):
|
|
41
|
+
path_dir_farm.mkdir(parents=True, exist_ok=True)
|
|
42
|
+
self.farm_settings.write(path_dir_farm=path_dir_farm)
|
|
43
|
+
for k, v in self.__dict__.items():
|
|
44
|
+
if (v is not None) and (not isinstance(v, ParamsFarmSettings)):
|
|
45
|
+
path_dir = path_dir_farm / self._set_dir_name(entry=k)
|
|
46
|
+
path_dir.mkdir(parents=True, exist_ok=True)
|
|
47
|
+
dfs = [DataFrame.from_records([v.to_dict() for v in component]) for component in v]
|
|
48
|
+
for df in dfs:
|
|
49
|
+
name_output_file = df['Name'].unique()[0]
|
|
50
|
+
df.to_csv(path_dir / f'{name_output_file}.csv', index=False)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def create_farm(
|
|
54
|
+
latitude: float,
|
|
55
|
+
longitude: float,
|
|
56
|
+
weather_summary: WeatherSummary,
|
|
57
|
+
beef_cattle_data: BeefCattleInput = None,
|
|
58
|
+
dairy_cattle_data: DairyCattleInput = None,
|
|
59
|
+
sheep_flock_data: SheepFlockInput = None,
|
|
60
|
+
fields_data: FieldsInput = None,
|
|
61
|
+
) -> Farm:
|
|
62
|
+
farm = Farm(
|
|
63
|
+
farm_settings=ParamsFarmSettings(
|
|
64
|
+
latitude=latitude,
|
|
65
|
+
longitude=longitude,
|
|
66
|
+
year=weather_summary.year,
|
|
67
|
+
monthly_precipitation=weather_summary.monthly_precipitation,
|
|
68
|
+
monthly_potential_evapotranspiration=weather_summary.monthly_potential_evapotranspiration,
|
|
69
|
+
monthly_temperature=weather_summary.monthly_temperature)
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
params_soil = farm.farm_settings.params_soil
|
|
73
|
+
|
|
74
|
+
province = convert_province_name(name=params_soil.province.value)
|
|
75
|
+
soil_texture = convert_soil_texture_name(name=params_soil.soil_texture.value)
|
|
76
|
+
|
|
77
|
+
if beef_cattle_data is not None:
|
|
78
|
+
farm.beef = beef_cattle_data.create_components(
|
|
79
|
+
province=province,
|
|
80
|
+
soil_texture=soil_texture)
|
|
81
|
+
|
|
82
|
+
if dairy_cattle_data is not None:
|
|
83
|
+
farm.dairy = dairy_cattle_data.create_components(
|
|
84
|
+
province=province,
|
|
85
|
+
soil_texture=soil_texture)
|
|
86
|
+
|
|
87
|
+
if sheep_flock_data is not None:
|
|
88
|
+
farm.sheep = sheep_flock_data.create_components(
|
|
89
|
+
province=province,
|
|
90
|
+
soil_texture=soil_texture)
|
|
91
|
+
|
|
92
|
+
if fields_data is not None:
|
|
93
|
+
farm.fields = fields_data.create_components(
|
|
94
|
+
province=province,
|
|
95
|
+
clay_content=params_soil.proportion_of_clay_in_soil.value,
|
|
96
|
+
sand_content=params_soil.proportion_of_sand_in_soil.value,
|
|
97
|
+
organic_carbon_percentage=params_soil.proportion_of_soil_organic_carbon.value,
|
|
98
|
+
soil_top_layer_thickness=params_soil.top_layer_thickness.value,
|
|
99
|
+
soil_functional_category=convert_soil_functional_category_name(params_soil.soil_functional_category.value))
|
|
100
|
+
|
|
101
|
+
return farm
|