Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor parameterisation #28

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4c14226
adapt set parameters mechanism to definition in external module
christian34 Dec 18, 2017
ebf4e3c
add init mechanism for secondary parameter initialisation
christian34 Dec 18, 2017
423ba92
finalise experimental condition parameters
christian34 Dec 18, 2017
fc527cc
separate location and meteo
christian34 Dec 19, 2017
44bd19d
add nbj to parameters
christian34 Dec 19, 2017
529467e
simplify parameterisation
christian34 Dec 19, 2017
41c12e7
add mecanism for modularising genotypic parameters
christian34 Dec 19, 2017
9544e20
add dimension senescence and tillering parameters
christian34 Dec 19, 2017
d455eef
add comom plant parameters
christian34 Dec 19, 2017
c7b2027
handle phyll_adjust and phyll_adjust dependant parameters
christian34 Dec 19, 2017
8bc5ebd
refactor Dse parameters
christian34 Dec 19, 2017
5cd3051
handle crop conception parameters
christian34 Dec 20, 2017
1c9c273
remove unused code
christian34 Dec 20, 2017
23d24ee
simplify call to crop_conception
christian34 Dec 20, 2017
666679e
add comment
christian34 Dec 20, 2017
a40af09
add 'genotype_proportion' parameter (defined in PR #25)
christian34 Apr 3, 2018
b227c40
Add Phi_zen_B in genotypic Parameters.csv
christian34 Apr 3, 2018
8d3e27e
Modify management of param_Ln_final to handle per genotype parameteri…
christian34 Apr 3, 2018
328be8d
change lpy_cut_bug default as in PR #34
christian34 Apr 3, 2018
1f78e84
Merge branch 'master' into refactor_parameterisation
christian34 Apr 3, 2018
f0a752e
Merge remote-tracking branch 'remotes/origin/master' into refactor_pa…
christian34 Apr 11, 2018
d68a3d2
update initialisation of x_position_hazard according to PR #42
christian34 Apr 12, 2018
95c0b7a
Merge remote-tracking branch 'remotes/origin/master' into refactor_pa…
christian34 Apr 12, 2018
6320c99
Merge branch 'master' into refactor_parameterisation
christian34 Apr 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 205 additions & 0 deletions src/walter/crop_conception.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
"""compute crop_schemes for different configurations"""
from __future__ import division
from math import floor, ceil, sqrt


def design_crop_classical(nb_plt_temp=1, nb_rang=1, densite=150, dist_inter_rang = 0.135):
crop_scheme = {"dist_inter_rang": dist_inter_rang, "density": densite}
area = nb_plt_temp / crop_scheme["density"]
dy = nb_rang * dist_inter_rang
dx = area / dy
nb_plante_par_rang = int(nb_plt_temp / nb_rang)
dist_intra = dx / nb_plante_par_rang
nplant_peupl = int(nb_rang * nb_plante_par_rang)
crop_scheme["nplant_peupl"] = nplant_peupl
crop_scheme["dx"] = dx
crop_scheme["dy"] = dy
crop_scheme["surface_sol"] = dx * dy
crop_scheme["nb_rang"] = nb_rang
crop_scheme["nb_plante_par_rang"] = nb_plante_par_rang
crop_scheme["dist_intra_rang"] = dist_intra
crop_scheme["real_density"] = nplant_peupl / crop_scheme["surface_sol"]
crop_scheme["map_middle_y"] = ((crop_scheme["nb_rang"] * (
crop_scheme["dist_inter_rang"]) * 100) + (
crop_scheme["dist_inter_rang"]) * 100) / 2
crop_scheme["map_middle_x"] = ((crop_scheme["nb_plante_par_rang"] * (
crop_scheme["dist_intra_rang"]) * 100) + (
crop_scheme["dist_intra_rang"]) * 100) / 2
return crop_scheme

def design_crop_mesh_for_nplants (densite=150, nb_plt_utiles=1, dist_border_x=0, dist_border_y=0):
crop_scheme = {"density": densite}
nb_rang_utiles = floor(sqrt(nb_plt_utiles))
nb_plant_par_rang_utiles = ceil(sqrt(nb_plt_utiles))
d_intra = sqrt(1/densite)
d_inter = d_intra
nb_rang = nb_rang_utiles + ceil((dist_border_x/100)/d_inter) + ceil((dist_border_x/100)/d_inter)
nb_plant_par_rang = nb_plant_par_rang_utiles + ceil((dist_border_y/100)/d_intra) + ceil((dist_border_y/100)/d_intra)
dx = nb_rang*d_inter
dy = nb_plant_par_rang*d_intra
nplant_peupl = nb_rang*nb_plant_par_rang
crop_scheme["area"] = dx*dy
crop_scheme["nb_rang"] = int(nb_rang)
crop_scheme["nb_plante_par_rang"] = int(nb_plant_par_rang)
crop_scheme["dist_inter_rang"] = d_intra
crop_scheme["dist_intra_rang"] = d_intra
crop_scheme["dx"] = dx
crop_scheme["dy"] = dy
crop_scheme["nplant_peupl"] = int(nplant_peupl)
crop_scheme["real_density"] = nplant_peupl/crop_scheme["area"]
crop_scheme["surface_sol"] = dx*dy
crop_scheme["map_middle_y"] = ((crop_scheme["nb_rang"] * (crop_scheme["dist_inter_rang"])*100) + (crop_scheme["dist_inter_rang"])*100)/2
crop_scheme["map_middle_x"] = ((crop_scheme["nb_plante_par_rang"] * (crop_scheme["dist_intra_rang"])*100) + (crop_scheme["dist_intra_rang"])*100)/2
return crop_scheme


def adapting_crop_area(density=150, area_min=1, area_max=13, dist_inter=0.135, opt_plt_nb=10):
crop_scheme = {"dist_inter_rang": dist_inter, "density": density}
#print "density : ",density, "opt : ",opt_plt_nb, "area_max", area_max
if density < (opt_plt_nb/area_max):
area_temp = area_max
plt_nb_temp = density*area_temp
#elif (opt_plt_nb/area_max) < density < 55:
# area_temp = (50/density)
# plt_nb_temp = density*area_temp
elif density > (opt_plt_nb/area_min):
area_temp = area_min
plt_nb_temp = density*area_temp
else:
#a = (area_max - area_min)/((opt_plt_nb/area_max) - (opt_plt_nb/area_min))
#b = area_min - a*(opt_plt_nb/area_min)
#area = a * density + b
area_temp = (opt_plt_nb/density)
plt_nb_temp = density*area_temp
nb_rang = int(ceil(sqrt(area_temp)/dist_inter))
dy = nb_rang * dist_inter
dx = (area_temp/dy)
nb_plante_par_rang = int(plt_nb_temp/nb_rang)
dist_intra = dx/nb_plante_par_rang
nplant_peupl = int(nb_rang*nb_plante_par_rang)
crop_scheme["dx"] = dx
crop_scheme["dy"] = dy
crop_scheme["surface_sol"] = dx*dy
crop_scheme["nb_rang"] = nb_rang
crop_scheme["nb_plante_par_rang"] = nb_plante_par_rang
crop_scheme["dist_intra_rang"] = dist_intra
crop_scheme["nplant_peupl"] = nplant_peupl
crop_scheme["real_density"] = nplant_peupl/crop_scheme["surface_sol"]
crop_scheme["map_middle_y"] = ((crop_scheme["nb_rang"] * (crop_scheme["dist_inter_rang"])*100) + (crop_scheme["dist_inter_rang"])*100)/2
crop_scheme["map_middle_x"] = ((crop_scheme["nb_plante_par_rang"] * (crop_scheme["dist_intra_rang"])*100) + (crop_scheme["dist_intra_rang"])*100)/2
return crop_scheme


def design_crop_Darwinkel(area=1, density=150):
crop_scheme = {"area": area, "density": density}
nb_rang = floor(sqrt(area * density))
nb_plant_par_rang = ceil(sqrt(area * density))
d_intra = sqrt(area/(nb_rang*nb_plant_par_rang))
dx = nb_rang*d_intra
dy = nb_plant_par_rang*d_intra
nplant_peupl = nb_rang*nb_plant_par_rang
crop_scheme["nb_rang"] = int(nb_rang)
crop_scheme["nb_plante_par_rang"] = int(nb_plant_par_rang)
crop_scheme["dist_inter_rang"] = d_intra
crop_scheme["dist_intra_rang"] = d_intra
crop_scheme["dx"] = dx
crop_scheme["dy"] = dy
crop_scheme["nplant_peupl"] = int(nplant_peupl)
crop_scheme["real_density"] = nplant_peupl/area
crop_scheme["surface_sol"] = dx*dy
crop_scheme["map_middle_y"] = ((crop_scheme["nb_rang"] * (crop_scheme["dist_inter_rang"])*100) + (crop_scheme["dist_inter_rang"])*100)/2
crop_scheme["map_middle_x"] = ((crop_scheme["nb_plante_par_rang"] * (crop_scheme["dist_intra_rang"])*100) + (crop_scheme["dist_intra_rang"])*100)/2
return crop_scheme


def crop_conception(crop_ccptn='Mesh_for_n_plants', densite=150, nb_rang=1,
dist_inter_rang=.135, nb_plt_utiles=1, dist_border_x=0.,
dist_border_y=0, area_targeted=1, area_min=1, area_max=13,
opt_plt_nb=10, nb_plt_temp=1):
if crop_ccptn == 'classical':
crop_scheme = design_crop_classical(nb_plt_temp, nb_rang, densite,
dist_inter_rang)
elif crop_ccptn == 'Mesh_for_nplants':
crop_scheme = design_crop_mesh_for_nplants(densite, nb_plt_utiles,
dist_border_x, dist_border_y)
elif crop_ccptn == 'Darwinkel_original':
crop_scheme = design_crop_Darwinkel(area_targeted, densite)
elif crop_ccptn == 'neo_Darwinkel':
crop_scheme = adapting_crop_area(densite, area_min, area_max,
dist_inter_rang, opt_plt_nb)
else:
raise ValueError('unknown crop_ccptn: ' + crop_ccptn)
return crop_scheme


#def crop_conception2(densite, dx, dy, dist_inter_rang, area_max):
# if dx*dy > area_max:
# print "ATTENTION LES DIMENSIONS DE LA PARCELLE SONT TROP GRANDES!"
# dx, dy = sqrt(area_max)-0.01, sqrt(area_max)-0.01
# nb_rang_m2 = 1/dist_inter_rang
# nb_plante_par_rang_m2 = densite/nb_rang_m2
# crop_scheme["nb_rang"] = int(floor(dx*nb_rang_m2))
# crop_scheme["nb_plante_par_rang"] = int(floor(dy*nb_plante_par_rang_m2))
# crop_scheme["dist_intra_rang"] = dy/crop_scheme["nb_plante_par_rang"]
# crop_scheme["nplant_peupl"] = crop_scheme["nb_plante_par_rang"]*crop_scheme["nb_rang"]
# print crop_scheme
# return crop_scheme

# def crop_conception(densite, nb_rang, dist_inter_rang, nb_plante_min,
# nb_plante_max):
# crop_scheme = {"dist_inter_rang": dist_inter_rang, "density": densite}
# crop_scheme["nb_rang"] = int(nb_rang)
# dx = nb_rang * dist_inter_rang
# nb_rang_m2 = 1 / dist_inter_rang
# nb_plante_par_rang_m2 = densite / nb_rang_m2
# dist_intra_rang = 1 / nb_plante_par_rang_m2
# nb_plt_p_rang_min = nb_plante_min / nb_rang
# nb_plt_p_rang_max = nb_plante_max / nb_rang
# crop_scheme["dx"], crop_scheme["dist_intra_rang"] = dx, dist_intra_rang
# resultats = {}
# if nb_plante_min == nb_plante_max == 1:
# nb_plante_par_rang = 1
# nb_rang = 1
# dx, dy = dist_inter_rang, 1 / nb_plante_par_rang_m2
# nplant_peupl = 1
# crop_scheme["dy"] = dy
# crop_scheme["nb_plante_par_rang"], crop_scheme["nplant_peupl"] = int(
# nb_plante_par_rang), int(nplant_peupl)
# else:
# if round(nb_plt_p_rang_max * dist_intra_rang, 2) - round(
# nb_plt_p_rang_min * dist_intra_rang, 2) < 0.01:
# dy = round(nb_plt_p_rang_min * dist_intra_rang, 2)
# nb_plante_par_rang = floor(dy * nb_plante_par_rang_m2)
# nplant_peupl = nb_rang * nb_plante_par_rang
# surface_sol = dx * dy
# virtual_density = nplant_peupl / surface_sol
# ecart_de_densite = abs(densite - virtual_density) / densite
# resultats[ecart_de_densite] = (dx, dy)
# crop_scheme["nb_plante_par_rang"], crop_scheme[
# "nplant_peupl"] = int(nb_plante_par_rang), int(nplant_peupl)
# else:
# for dy in np.arange(round(nb_plt_p_rang_min * dist_intra_rang, 2),
# round(nb_plt_p_rang_max * dist_intra_rang, 2),
# 0.01):
# nb_plante_par_rang = floor(dy * nb_plante_par_rang_m2)
# nplant_peupl = nb_rang * nb_plante_par_rang
# surface_sol = dx * dy
# virtual_density = nplant_peupl / surface_sol
# ecart_de_densite = abs(densite - virtual_density) / densite
# resultats[ecart_de_densite] = (round(dx, 2), round(dy, 2))
# dy = round(resultats[min(resultats.keys())][1], 2)
# nb_plante_par_rang = floor(dy * nb_plante_par_rang_m2)
# nplant_peupl = nb_rang * nb_plante_par_rang
# crop_scheme["nb_plante_par_rang"], crop_scheme[
# "nplant_peupl"] = int(nb_plante_par_rang), int(nplant_peupl)
# crop_scheme["dy"] = dy
# if min(resultats.keys()) * 100 > 5:
# print "ATTENTION ERREUR CONSEQUENTE DE PREDICTION DE LA DENSITE"
# crop_scheme["surface_sol"] = dx * dy
# crop_scheme["map_middle_y"] = ((crop_scheme["nb_rang"] * (
# crop_scheme["dist_inter_rang"]) * 100) + (
# crop_scheme["dist_inter_rang"]) * 100) / 2
# crop_scheme["map_middle_x"] = ((crop_scheme["nb_plante_par_rang"] * (
# crop_scheme["dist_intra_rang"]) * 100) + (
# crop_scheme["dist_intra_rang"]) * 100) / 2
# return crop_scheme
129 changes: 129 additions & 0 deletions src/walter/experimental_conditions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import datetime

dico_latitudes = {'Gif_sur_Yvette': 48.5, 'Le_Pin_aux_Haras': 48.7,
'Lelystad': 52.5, 'Le_Rheu': 48.1,
'Alenya': 42.6, 'Grignon': 48.8,
'Colmar': 48.1, 'Fagniere': 49, 'Clermont': 45.7,
"Nottingham": 52.9}

experiments = {
"Sreten": {"sowing_date": datetime.date(1998, 10, 15),
"year": "1999",
"meteo": "Grignon",
"location": "Grignon",
"dist_inter_rang": 0.175,
"genotype": ["Soissons"],
"Ln_final": {"Soissons": 11}},
"Rim1-1": {"sowing_date": datetime.date(2007, 9, 25), "year": "2008",
"location": "Grignon", "meteo": "Grignon",
"dist_inter_rang": 0.175,
"genotype": ["Soissons"], "Ln_final": {"Soissons": 11}},
"Rim1-2": {"sowing_date": datetime.date(2007, 11, 12), "year": "2008",
"location": "Grignon", "meteo": "Grignon",
"dist_inter_rang": 0.175,
"genotype": ["Soissons"], "Ln_final": {"Soissons": 11}},
"Rim2-1": {"sowing_date": datetime.date(2008, 9, 30), "year": "2009",
"location": "Grignon", "meteo": "Grignon",
"dist_inter_rang": 0.175,
"genotype": ["Soissons"], "Ln_final": {"Soissons": 11}},
"Rim2-2": {"sowing_date": datetime.date(2008, 11, 17), "year": "2009",
"location": "Grignon", "meteo": "Grignon",
"dist_inter_rang": 0.175,
"genotype": ["Soissons"], "Ln_final": {"Soissons": 11}},
"Jillian": {"sowing_date": datetime.date(2003, 10, 16), "year": "2004",
"location": "Grignon", "meteo": "Grignon",
"dist_inter_rang": 0.175,
"genotype": ["Soissons"], "Ln_final": {"Soissons": 11}},
"Jessica": {"sowing_date": datetime.date(2005, 10, 27), "year": "2006",
"meteo": "Grignon", "location": "Grignon",
"dist_inter_rang": 0.175,
"genotype": ["Soissons"], "Ln_final": {"Soissons": 11.3}},
"Mariem": {"sowing_date": datetime.date(2010, 10, 26), "year": "1901",
"location": "Grignon", "meteo": "Grignon",
"dist_inter_rang": 0.175,
"genotype": ["Maxwell"], "Ln_final": {"Maxwell": 11.3}},
"Darwinkel": {"sowing_date": datetime.date(1976, 10, 19),
"year": "1977", "location": "Lelystad", "meteo": "Lelystad",
"dist_inter_rang": 0.175, "genotype": ["Lely"],
"Ln_final": {"Lely": 11}},
"Darwinkel_temp": {"sowing_date": datetime.date(2013, 10, 19),
"year": "1901", "location": "Grignon",
"meteo": "Grignon",
"dist_inter_rang": 0.175, "genotype": ["Maxwell"],
"Ln_final": {"Maxwell": 11}},
"Wheatamix-2014": {"sowing_date": datetime.date(2013, 10, 31),
"year": "2014", "location": "Grignon",
"meteo": "Grignon",
"dist_inter_rang": 0.175, "genotype": ["Soissons"],
"Ln_final": {"Soissons": 11}},
"Ouitamics-2014": {"sowing_date": datetime.date(2013, 10, 30),
"year": "2014", "location": "Gif_sur_Yvette",
"meteo": "Gif_sur_Yvette",
"dist_inter_rang": 0.15,
"genotype": ["Soissons", "Apache", "Renan",
"Caphorn", "A208", "A210", "F236",
"A398"],
"Ln_final": {"Soissons": 11, "Apache": 11, "Renan": 11,
"Caphorn": 11, "A208": 11, "A210": 11,
"F236": 11, "A398": 11}},
"None": {"sowing_date": datetime.date(2013, 10, 15), "year": "2014",
"location": "Gif_sur_Yvette", "meteo": "Gif_sur_Yvette",
"dist_inter_rang": 0.1,
"genotype": ["Soissons", "Maxwell"],
"Ln_final": {"Soissons": 11,"Maxwell": 11}},
"Mariem_mean": {"sowing_date": datetime.date(1900, 10, 26),
"year": "1901", "meteo": "Grignon_mean10",
"location": "Grignon",
"dist_inter_rang": 0.175, "genotype": ["Maxwell"],
"Ln_final": {"Maxwell": 11}},
"Darwinkel_Grignon_mean": {"sowing_date": datetime.date(1900, 10, 19),
"year": "1901", "meteo": "Grignon_mean10",
"location": "Grignon",
"genotype": ["Maxwell"],
"Ln_final": {"Maxwell": 11}},
"Darwinkel_mean": {"sowing_date": datetime.date(1900, 10, 19),
"year": "1901", "meteo": "Lelystad_mean10",
"location": "Lelystad",
"dist_inter_rang": 0.175, "genotype": ["Maxwell"],
"Ln_final": {"Maxwell": 11.3}
},
"Sparkes_2001": {"sowing_date": datetime.date(2000, 10, 17),
"year": "2001", "location": "Nottingham",
"meteo": "Nottingham",
"dist_inter_rang": 0.135, "genotype": ["Maxwell"],
"Ln_final": {"Maxwell": 11}},
"Sparkes_2002": {"sowing_date": datetime.date(2001, 10, 4),
"year": "2002", "location": "Nottingham",
"meteo": "Nottingham",
"dist_inter_rang": 0.135, "genotype": ["Maxwell"],
"Ln_final": {"Maxwell": 11}},
"Sparkes_2003": {"sowing_date": datetime.date(2002, 9, 20),
"year": "2003", "location": "Nottingham",
"meteo": "Nottingham",
"dist_inter_rang": 0.135, "genotype": ["Maxwell"],
"Ln_final": {"Maxwell": 11}},
"Association": {"sowing_date": datetime.date(2013, 10, 30),
"year": "2014", "location": "Gif_sur_Yvette",
"meteo": "Gif_sur_Yvette",
"dist_inter_rang": 0.175,
"genotype": ["Gigant_Maxwell", "Darwinkel_Maxwell"],
"Ln_final": {"Gigant_Maxwell": 11, "Darwinkel_Maxwell": 11}},
"Sensitivity_Analysis": {"sowing_date": datetime.date(1900, 10, 15),
"year": "1901", "meteo": "Climat_moy_AS",
"location": "Grignon",
"dist_inter_rang": 0.175,
"genotype": ["Maxwell"],
"Ln_final": {"Maxwell": 11.3}},
}


def experimental_conditions(expe_related='Sensitivity_Analysis'):
return experiments[expe_related]


def liste_expe():
return experiments.keys()


def get_latitude(location):
return dico_latitudes[location]
Loading