Skip to content
Snippets Groups Projects
Commit 950a114f authored by Lemaire Louis's avatar Lemaire Louis
Browse files

Merge branch '99-feature-crop-model-config-file' into 'develop'

[feature] Crop model config file

See merge request !14
parents 837cd62d 21b389e3
No related branches found
No related tags found
1 merge request!21v1.1.0
cutType:
Value: graze
Type: string
Limit: ['None', 'graze', 'mow']
Description: Determines how biomass is removed
cutDecisionType:
Value: frequency
Type: string
Limit: ['None', 'dates', 'sward_height', 'frequency']
Description: Specifies when cutting takes place
biomassRemovalType:
Value: max_BM
Type: string
Limit: ['None', 'max_BM', 'cut_height']
Description: Defines the extent of biomass removal
rotationType:
Value: None
Type: string
Limit: ['None', 'dates', 'sward_height', 'frequency']
Description: Specifies when rotation occurs
fertilizationType:
Value: None
Type: string
Limit: ['None', 'dates', 'days_after_cut']
Description: Specifies when fertilization occurs
number_of_cutting_periods:
Value: 1
Type: integer
Limit: [1,100]
Description: Number of cutting periods
cutting_start_1:
Value: '15-04'
Type: string
Description: start date of cutting period 1
cutting_end_1:
Value: '15-07'
Type: string
Description: end date of cutting period 1
cutting_frequency_1:
Value: 1
Type: integer
Limit: [1,365]
Unit: day
Description: cutting frequency of period 1
max_BM:
Value: 300
Type: float
Limit: [0,50000]
Unit: kg/ha/day
Description: Maximum daily sry biomass consumption
min_available_height:
Value: 0.03
Type: float
Limit: [0,1]
Unit: meter
Description: minimum grazing height
priority_order:
Value: ['GV', 'GR', 'DV', 'DR']
Type: list
Description : priority order of biomass consumption
......@@ -6,9 +6,13 @@ soil_variables:
- Vp
crop_variables:
- BM
- N_uptake
- QNGV
- FNH
- GRO
- GROGV
- SENGV
management_variables:
- exported_BM
crop_model: grassim
crop_init: crop_init_example.yml
soil_init: soil_init_example.yml
PFT_composition: PFT_composition.yml
PFT_values: Parameters_values_PFT.csv
Kc_values: Kc_values.yml
management: management_frequency_example.yml
variables_to_save: variables_to_save.yml
\ No newline at end of file
crop_model: simple
crop_init: crop_init.yaml
soil_init: soil_init.yaml
crop_parameters: crops_parameters.csv
crop_model: stics
simu_init: simu_init.yaml
......@@ -13,15 +13,16 @@ from MODULES.CROPS.GRASSIM.management.management import Management
from MODULES.DATA_MANAGEMENT.yaml_inputs_provider import YAML_Inputs_provider
from MODULES.CROPS.evapotranspiration_FAO56_PM import get_ET0
def run_grassim(WD, daily_irr, lat, alt):
def run_grassim(config, WD, daily_irr, lat, alt):
soil_init = YAML_Inputs_provider(file=f"CROPS/GRASSIM/soil/{config['soil_init']}").inputs
crop_init = YAML_Inputs_provider(file=f"CROPS/GRASSIM/crop/{config['crop_init']}").inputs
kc_values = YAML_Inputs_provider(file=f"CROPS/GRASSIM/crop/{config['Kc_values']}").inputs
pft_composition = YAML_Inputs_provider(file=f"CROPS/GRASSIM/{config['PFT_composition']}").inputs
pft_values = pd.read_csv(f"INPUTS/CROPS/GRASSIM/{config['PFT_values']}",header=0, sep=";", decimal='.')
management = YAML_Inputs_provider(file=f"CROPS/GRASSIM/management/{config['management']}").inputs
crop_init = YAML_Inputs_provider(file='CROPS/GRASSIM/crop/crop_init_example.yml').inputs
kc_values = YAML_Inputs_provider(file='CROPS/GRASSIM/crop/Kc_values.yml').inputs
pft_composition = YAML_Inputs_provider(file='CROPS/GRASSIM/PFT_composition.yml').inputs
pft_values = pd.read_csv('INPUTS/CROPS/GRASSIM/Parameters_values_PFT.csv',header=0, sep=";", decimal='.')
management = YAML_Inputs_provider(file='CROPS/GRASSIM/management/management_dates_example.yml').inputs
soil_init = YAML_Inputs_provider(file='CROPS/GRASSIM/soil/soil_init_example.yml').inputs
with open("INPUTS/CROPS/GRASSIM/variables_to_save.yml", "r") as file:
with open(f"INPUTS/CROPS/GRASSIM/{config['variables_to_save']}", "r") as file:
variables_to_save = yaml.safe_load(file)
simulation_dates = get_sim_dates(WD)
......
......@@ -13,14 +13,14 @@ from MODULES.DATA_MANAGEMENT.yaml_inputs_provider import YAML_Inputs_provider
from MODULES.CROPS.evapotranspiration_FAO56_PM import get_ET0
def run_independant_years_of_crop(option_2D, WD, daily_irr, lat, alt):
def run_independant_years_of_crop(config, option_2D, WD, daily_irr, lat, alt):
Crop_init = YAML_Inputs_provider(file = 'CROPS/SIMPLE/crop_init.yaml').inputs
Crop_init = YAML_Inputs_provider(file = f"CROPS/SIMPLE/{config['crop_init']}").inputs
list_rows_to_skip = list(np.arange(1, int(Crop_init['CropID']), 1))
Crop_param = pd.read_csv('INPUTS/CROPS/SIMPLE/crops_parameters.csv',
Crop_param = pd.read_csv(f"INPUTS/CROPS/SIMPLE/{config['crop_parameters']}",
skiprows=lambda x: x in list_rows_to_skip,
nrows=1).to_dict('records')[0]
Soil_param = YAML_Inputs_provider(file = 'CROPS/SIMPLE/soil_init.yaml').inputs
Soil_param = YAML_Inputs_provider(file = f"CROPS/SIMPLE/{config['soil_init']}").inputs
Soil_plot = water_balance.Soil(Soil_param)
Crop_plot = simple.Crop(Crop_param,
......
......@@ -16,9 +16,9 @@ import pandas as pd
import numpy as np
def run_independant_usms(WD, daily_irr, scenario_P):
def run_independant_usms(config, WD, daily_irr, scenario_P):
Simu_init = YAML_Inputs_provider('CROPS/STICS/simu_init.yaml').inputs
Simu_init = YAML_Inputs_provider(f"CROPS/STICS/{config['simu_init']}").inputs
WD_files_dict = generate_weather_data_file(WD, daily_irr,
scenario_P['LocationName'])
......
......@@ -11,21 +11,21 @@ from MODULES.CROPS.GRASSIM.run_grassim import run_grassim
def run_crop_simu(crop_model, option_2D, WD, daily_irr, scenario_P):
def run_crop_simu(config, option_2D, WD, daily_irr, scenario_P):
if crop_model == 1:
if config['crop_model'] == 'simple':
Soil_plot, Crop_plot = run_independant_years_of_crop(option_2D, WD, daily_irr,
Soil_plot, Crop_plot = run_independant_years_of_crop(config, option_2D, WD, daily_irr,
scenario_P['Latitude'],
scenario_P['Altitude'])
if crop_model == 2:
if config['crop_model'] == 'stics':
Soil_plot, Crop_plot = run_independant_usms(WD, daily_irr, scenario_P)
Soil_plot, Crop_plot = run_independant_usms(config, WD, daily_irr, scenario_P)
if crop_model == 3:
if config['crop_model'] == 'grassim':
Soil_plot, Crop_plot = run_grassim(WD, daily_irr, scenario_P['Latitude'], scenario_P['Altitude'])
Soil_plot, Crop_plot = run_grassim(config, WD, daily_irr, scenario_P['Latitude'], scenario_P['Altitude'])
return Soil_plot, Crop_plot
......@@ -8,6 +8,7 @@
import numpy as np
import os
import pickle
import yaml
from MODULES.user_support_tools import PASE_Logger
from MODULES.DATA_MANAGEMENT.yaml_inputs_provider import YAML_Inputs_provider, Inputs_aggregator
from MODULES.DATA_MANAGEMENT.weather_data_provider import Weather_data
......@@ -97,7 +98,6 @@ L.get_daily_irradiation_map(Sun_positions_samp.SP,
#DiffuseGround = L.Get_diffuse_map_byFlag(Flags=["wheat","corn"])
#DirectGround = L.Get_direct_map_byFlag(Flags=["crop"])
# Examples of visualisation for the direct light map, diffuse light map (sky view factor)
# and daily irradiation map. Those lines are for PV system with no rotation axis.
j = 5 #day definition
......@@ -190,16 +190,18 @@ PV_central = PV_Production(PV_params_dict)
PV_central.get_several_years_of_electricity_production(Sun_positions_complete, Light_instance.data, WD.nyears_data)
### CROP MODEL
#Temporary lines, those 2 parameters (crop_model and option_2D) should be in SCENARIOS input files (general parameters)
crop_model = 1 # 1 pour SIMPLE, 2 pour STICS JAVA et 3 pour GRASSIM
#Temporary line, this parameters (option_2D) should be in SCENARIOS input files (general parameters)
option_2D = 1 # 0 pour pas de spatialisation et 1 pour une spatialisation du modèle de culture
Soil_plot, Crop_plot = run_crop_simu(crop_model, option_2D, WD.nyears_daily_data,
with open('INPUTS/CROPS/config/grassim_example.yml', 'r') as file:
config_1 = yaml.safe_load(file)
Soil_plot, Crop_plot = run_crop_simu(config_1, option_2D, WD.nyears_daily_data,
L.daily_irr_spat,
Loc_1)
show_light_map2(L.sourcepoints[:,:-1],
Crop_plot.nyears_data['2008']['Dry_yield']['2008-10-10 00:00:00']/100,
Crop_plot[0].nyears_data['2008']['BM']['2008-10-10 00:00:00']/100,
PV_1_3Dconfig.PV_central_PD,
"Dry yield SIMPLE 2008 [t/ha]")
"Biomass Gras-Sim 2008 [t/ha]")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment