diff --git a/Project.toml b/Project.toml index b34a8e3bb74ffe2a863e273a054352ef359724ac..b7d065cded4d2e79c1aa2d3867efd9f93395b0d7 100644 --- a/Project.toml +++ b/Project.toml @@ -4,6 +4,7 @@ authors = ["Daniel Vedder <daniel.vedder@idiv.de>"] version = "0.5.5" [deps] +AquaCrop = "8f16cebd-c0b4-44a3-857f-c101f083256c" ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63" CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" diff --git a/src/crop/aquacrop.jl b/src/crop/aquacrop.jl index 2ae7942913253ba90b11650f2be14af7bbd77e9d..69868735c5dbc490197e1af3049962d8a4207291 100644 --- a/src/crop/aquacrop.jl +++ b/src/crop/aquacrop.jl @@ -1,3 +1,5 @@ +import AquaCrop + struct AquaCropType name::String group::String @@ -9,7 +11,17 @@ cropname(ct::AquaCropType) = ct.name mutable struct AquaCropState 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 croptype(cs::AquaCropState) = cs.croptype diff --git a/src/crop/cropmodels.jl b/src/crop/cropmodels.jl index 4846716948fa4756fd48d3d3d905814c236fc77e..c9cc1fda7ef121b21dce3a692c33313324bb1ffd 100644 --- a/src/crop/cropmodels.jl +++ b/src/crop/cropmodels.jl @@ -82,7 +82,7 @@ function makecropstate(model::SimulationModel) 0.0m ) elseif @param(crop.cropmodel) == "aquacrop" - cs = AquaCropState(model.crops["natural grass"], 0.0m) + cs = AquaCropState(model.crops["natural grass"], 0.0cm) else Base.error("Unhandled crop model '$(@param(crop.cropmodel))' in makecropstate().") end diff --git a/test/crop_tests.jl b/test/crop_tests.jl index ec80f27f5bee2a3e6d3b58d271abd97a199e8ad6..59ffdb6b86974cf206d2e18e80a5f0f61b441d42 100644 --- a/test/crop_tests.jl +++ b/test/crop_tests.jl @@ -58,7 +58,7 @@ end id = 0 pixels = [(0, 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{Ps.AquaCropState} @test croptype(fp) isa Ps.AquaCropType