Skip to content
Snippets Groups Projects
Commit f4c80402 authored by Marco Matthies's avatar Marco Matthies
Browse files

Add crop state init for AquaCrop

Currently errors with an error from inside AquaCrop.jl
parent dbfad2f7
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ authors = ["Daniel Vedder <daniel.vedder@idiv.de>"] ...@@ -4,6 +4,7 @@ authors = ["Daniel Vedder <daniel.vedder@idiv.de>"]
version = "0.5.5" version = "0.5.5"
[deps] [deps]
AquaCrop = "8f16cebd-c0b4-44a3-857f-c101f083256c"
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
......
import AquaCrop
struct AquaCropType struct AquaCropType
name::String name::String
group::String group::String
...@@ -9,7 +11,17 @@ cropname(ct::AquaCropType) = ct.name ...@@ -9,7 +11,17 @@ cropname(ct::AquaCropType) = ct.name
mutable struct AquaCropState mutable struct AquaCropState
croptype::AquaCropType croptype::AquaCropType
height::Length{Float64} height::Length{Float64} # TODO: remove height field, supply from cropstate
cropstate::AquaCrop.AquaCropField
function AquaCropState(croptype::AquaCropType, height::Length{Float64}=0.0cm)
ac_parentdir = "./tmp-aquacrop-param" # TODO
# TODO: runtype can be :Fortran, :Julia or :Persefone in the
# future, so then use :Persefone
ac_runtype = :Julia
cropstate = AquaCrop.AquaCropField(ac_parentdir, ac_runtype)
return new(croptype, height, cropstate)
end
end end
croptype(cs::AquaCropState) = cs.croptype croptype(cs::AquaCropState) = cs.croptype
......
...@@ -82,7 +82,7 @@ function makecropstate(model::SimulationModel) ...@@ -82,7 +82,7 @@ function makecropstate(model::SimulationModel)
0.0m 0.0m
) )
elseif @param(crop.cropmodel) == "aquacrop" elseif @param(crop.cropmodel) == "aquacrop"
cs = AquaCropState(model.crops["natural grass"], 0.0m) cs = AquaCropState(model.crops["natural grass"], 0.0cm)
else else
Base.error("Unhandled crop model '$(@param(crop.cropmodel))' in makecropstate().") Base.error("Unhandled crop model '$(@param(crop.cropmodel))' in makecropstate().")
end end
......
...@@ -58,7 +58,7 @@ end ...@@ -58,7 +58,7 @@ end
id = 0 id = 0
pixels = [(0, 0)] pixels = [(0, 0)]
farmer = 0 farmer = 0
fp = FarmPlot(id, pixels, farmer, Ps.AquaCropState(ct, 0.0cm)) fp = FarmPlot(id, pixels, farmer, Ps.AquaCropState(ct))
@test fp isa FarmPlot @test fp isa FarmPlot
@test fp isa FarmPlot{Ps.AquaCropState} @test fp isa FarmPlot{Ps.AquaCropState}
@test croptype(fp) isa Ps.AquaCropType @test croptype(fp) isa Ps.AquaCropType
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment