From e36dd056c545630e900781cfd9a0d83d65def5b1 Mon Sep 17 00:00:00 2001 From: Marco Matthies <71844+marcom@users.noreply.github.com> Date: Mon, 2 Dec 2024 13:36:20 +0100 Subject: [PATCH] ALMaSS: is_c4_plant is now taken from the crop csv file --- data/crops/almass/crop_data_general.csv | 56 ++++++++++---------- src/crop/almass.jl | 8 +-- test/cropparams-almass/crop_data_general.csv | 56 ++++++++++---------- 3 files changed, 58 insertions(+), 62 deletions(-) diff --git a/data/crops/almass/crop_data_general.csv b/data/crops/almass/crop_data_general.csv index edf3da7..0d1a6cd 100644 --- a/data/crops/almass/crop_data_general.csv +++ b/data/crops/almass/crop_data_general.csv @@ -1,28 +1,28 @@ -name,minsowdate,maxsowdate,minharvestdate,maxharvestdate,mingrowthtemp,group,biomass_scale -"spring rape",NA,NA,NA,NA,NA,"grain",1.071 -"winter rape","20 August","25 August",NA,NA,NA,"grain",1.071 -"winter wheat","15 October","31 October",NA,NA,0,"grain",1.0 -"spring wheat",NA,NA,NA,NA,NA,"grain",1.0 -"winter barley","15 September","30 September",NA,NA,0,"grain",0.857 -"spring barley","1 March","10 April",NA,NA,0,"grain",0.857 -"undersown spring barley",NA,NA,NA,NA,0,"grain",0.857 -"winter rye","23 September","15 October",NA,NA,NA,"grain",0.857 -"triticale","25 September","10 October",NA,NA,NA,"grain",1.0 -"oats",NA,NA,NA,NA,NA,"grain",0.857 -"maize","15 April","30 April",NA,NA,8,"grain",1.0 -"potatoes",NA,NA,NA,NA,4,"root",0.857 -"carrots",NA,NA,NA,NA,NA,"root",0.7857 -"beet","15 March","10 May",NA,NA,NA,"root",0.857 -"sunflower","25 March","15 April",NA,NA,NA,"other",1.0 -"lucerne",NA,NA,NA,NA,NA,"legumes",1.2 -"peas/beans","15 February","15 March",NA,NA,5,"legumes",0.857 -"silage clover/grass",NA,NA,NA,NA,NA,"legumes",1.1 -"fodder/clover",NA,NA,NA,NA,NA,"legumes",1.2 -"lawn",NA,NA,NA,NA,NA,"grass",0.5 -"permanent grassland (grazed)",NA,NA,NA,NA,NA,"grass",1.1 -"permanent grassland (seeded)",NA,NA,NA,NA,NA,"grass",1.1 -"permanent grassland (low yield)",NA,NA,NA,NA,NA,"grass",1.0 -"permanent set-aside",NA,NA,NA,NA,NA,"semi-natural",0.7857 -"natural grass",NA,NA,NA,NA,NA,"semi-natural",0.567 -"no growth",NA,NA,NA,NA,NA,"semi-natural",0.0 -"heath",NA,NA,NA,NA,NA,"semi-natural",0.567 +name,minsowdate,maxsowdate,minharvestdate,maxharvestdate,mingrowthtemp,group,biomass_scale,is_c4_plant +"spring rape",NA,NA,NA,NA,NA,"grain",1.071,false +"winter rape","20 August","25 August",NA,NA,NA,"grain",1.071,false +"winter wheat","15 October","31 October",NA,NA,0,"grain",1.0,false +"spring wheat",NA,NA,NA,NA,NA,"grain",1.0,false +"winter barley","15 September","30 September",NA,NA,0,"grain",0.857,false +"spring barley","1 March","10 April",NA,NA,0,"grain",0.857,false +"undersown spring barley",NA,NA,NA,NA,0,"grain",0.857,false +"winter rye","23 September","15 October",NA,NA,NA,"grain",0.857,false +"triticale","25 September","10 October",NA,NA,NA,"grain",1.0,false +"oats",NA,NA,NA,NA,NA,"grain",0.857,false +"maize","15 April","30 April",NA,NA,8,"grain",1.0,true +"potatoes",NA,NA,NA,NA,4,"root",0.857,false +"carrots",NA,NA,NA,NA,NA,"root",0.7857,false +"beet","15 March","10 May",NA,NA,NA,"root",0.857,false +"sunflower","25 March","15 April",NA,NA,NA,"other",1.0,false +"lucerne",NA,NA,NA,NA,NA,"legumes",1.2,false +"peas/beans","15 February","15 March",NA,NA,5,"legumes",0.857,false +"silage clover/grass",NA,NA,NA,NA,NA,"legumes",1.1,false +"fodder/clover",NA,NA,NA,NA,NA,"legumes",1.2,false +"lawn",NA,NA,NA,NA,NA,"grass",0.5,false +"permanent grassland (grazed)",NA,NA,NA,NA,NA,"grass",1.1,false +"permanent grassland (seeded)",NA,NA,NA,NA,NA,"grass",1.1,false +"permanent grassland (low yield)",NA,NA,NA,NA,NA,"grass",1.0,false +"permanent set-aside",NA,NA,NA,NA,NA,"semi-natural",0.7857,false +"natural grass",NA,NA,NA,NA,NA,"semi-natural",0.567,false +"no growth",NA,NA,NA,NA,NA,"semi-natural",0.0,false +"heath",NA,NA,NA,NA,NA,"semi-natural",0.567,false diff --git a/src/crop/almass.jl b/src/crop/almass.jl index 243f10b..6a49497 100644 --- a/src/crop/almass.jl +++ b/src/crop/almass.jl @@ -367,7 +367,7 @@ Parse a CSV file containing the required parameter values for each crop function readcropparameters(cropdirectory::String) @debug "Reading crop parameters" cropdata = CSV.File(joinpath(cropdirectory, CROPFILE), missingstring="NA", - types=[String,AnnualDate,AnnualDate,AnnualDate,AnnualDate,Float64,String,Float64]) + types=[String,AnnualDate,AnnualDate,AnnualDate,AnnualDate,Float64,String,Float64,Bool]) growthdata = CSV.File(joinpath(cropdirectory, GROWTHFILE), missingstring="NA", types=[Int,String,String,GrowthPhase,String, Float64,Float64,Float64,Float64]) @@ -382,11 +382,7 @@ function readcropparameters(cropdirectory::String) # TODO: set crop group temporarily until there is a column in # the csv file crop_group = "CROP_GROUP_NOT_SET" - # TODO: it would be better to save this in the parameter file - # (Note that this matches the current ALMaSS code though, - # which also only hardcodes maize as a C4 crop) - is_c4_plant = occursin("maize", lowercase(crop.name)) - croptypes[crop.name] = CropType(crop.name, crop_group, is_c4_plant, crop.minsowdate, + croptypes[crop.name] = CropType(crop.name, crop_group, crop.is_c4_plant, crop.minsowdate, crop.maxsowdate, crop.minharvestdate, crop.maxharvestdate, crop.mingrowthtemp, highnuts, lownuts, crop.biomass_scale) end diff --git a/test/cropparams-almass/crop_data_general.csv b/test/cropparams-almass/crop_data_general.csv index edf3da7..0d1a6cd 100644 --- a/test/cropparams-almass/crop_data_general.csv +++ b/test/cropparams-almass/crop_data_general.csv @@ -1,28 +1,28 @@ -name,minsowdate,maxsowdate,minharvestdate,maxharvestdate,mingrowthtemp,group,biomass_scale -"spring rape",NA,NA,NA,NA,NA,"grain",1.071 -"winter rape","20 August","25 August",NA,NA,NA,"grain",1.071 -"winter wheat","15 October","31 October",NA,NA,0,"grain",1.0 -"spring wheat",NA,NA,NA,NA,NA,"grain",1.0 -"winter barley","15 September","30 September",NA,NA,0,"grain",0.857 -"spring barley","1 March","10 April",NA,NA,0,"grain",0.857 -"undersown spring barley",NA,NA,NA,NA,0,"grain",0.857 -"winter rye","23 September","15 October",NA,NA,NA,"grain",0.857 -"triticale","25 September","10 October",NA,NA,NA,"grain",1.0 -"oats",NA,NA,NA,NA,NA,"grain",0.857 -"maize","15 April","30 April",NA,NA,8,"grain",1.0 -"potatoes",NA,NA,NA,NA,4,"root",0.857 -"carrots",NA,NA,NA,NA,NA,"root",0.7857 -"beet","15 March","10 May",NA,NA,NA,"root",0.857 -"sunflower","25 March","15 April",NA,NA,NA,"other",1.0 -"lucerne",NA,NA,NA,NA,NA,"legumes",1.2 -"peas/beans","15 February","15 March",NA,NA,5,"legumes",0.857 -"silage clover/grass",NA,NA,NA,NA,NA,"legumes",1.1 -"fodder/clover",NA,NA,NA,NA,NA,"legumes",1.2 -"lawn",NA,NA,NA,NA,NA,"grass",0.5 -"permanent grassland (grazed)",NA,NA,NA,NA,NA,"grass",1.1 -"permanent grassland (seeded)",NA,NA,NA,NA,NA,"grass",1.1 -"permanent grassland (low yield)",NA,NA,NA,NA,NA,"grass",1.0 -"permanent set-aside",NA,NA,NA,NA,NA,"semi-natural",0.7857 -"natural grass",NA,NA,NA,NA,NA,"semi-natural",0.567 -"no growth",NA,NA,NA,NA,NA,"semi-natural",0.0 -"heath",NA,NA,NA,NA,NA,"semi-natural",0.567 +name,minsowdate,maxsowdate,minharvestdate,maxharvestdate,mingrowthtemp,group,biomass_scale,is_c4_plant +"spring rape",NA,NA,NA,NA,NA,"grain",1.071,false +"winter rape","20 August","25 August",NA,NA,NA,"grain",1.071,false +"winter wheat","15 October","31 October",NA,NA,0,"grain",1.0,false +"spring wheat",NA,NA,NA,NA,NA,"grain",1.0,false +"winter barley","15 September","30 September",NA,NA,0,"grain",0.857,false +"spring barley","1 March","10 April",NA,NA,0,"grain",0.857,false +"undersown spring barley",NA,NA,NA,NA,0,"grain",0.857,false +"winter rye","23 September","15 October",NA,NA,NA,"grain",0.857,false +"triticale","25 September","10 October",NA,NA,NA,"grain",1.0,false +"oats",NA,NA,NA,NA,NA,"grain",0.857,false +"maize","15 April","30 April",NA,NA,8,"grain",1.0,true +"potatoes",NA,NA,NA,NA,4,"root",0.857,false +"carrots",NA,NA,NA,NA,NA,"root",0.7857,false +"beet","15 March","10 May",NA,NA,NA,"root",0.857,false +"sunflower","25 March","15 April",NA,NA,NA,"other",1.0,false +"lucerne",NA,NA,NA,NA,NA,"legumes",1.2,false +"peas/beans","15 February","15 March",NA,NA,5,"legumes",0.857,false +"silage clover/grass",NA,NA,NA,NA,NA,"legumes",1.1,false +"fodder/clover",NA,NA,NA,NA,NA,"legumes",1.2,false +"lawn",NA,NA,NA,NA,NA,"grass",0.5,false +"permanent grassland (grazed)",NA,NA,NA,NA,NA,"grass",1.1,false +"permanent grassland (seeded)",NA,NA,NA,NA,NA,"grass",1.1,false +"permanent grassland (low yield)",NA,NA,NA,NA,NA,"grass",1.0,false +"permanent set-aside",NA,NA,NA,NA,NA,"semi-natural",0.7857,false +"natural grass",NA,NA,NA,NA,NA,"semi-natural",0.567,false +"no growth",NA,NA,NA,NA,NA,"semi-natural",0.0,false +"heath",NA,NA,NA,NA,NA,"semi-natural",0.567,false -- GitLab