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

Fixes for SimpleCrop unit tests

parent 79d17c15
No related branches found
No related tags found
No related merge requests found
...@@ -18,7 +18,8 @@ function initcropmodel(cropmodel::AbstractString, cropfile::AbstractString, grow ...@@ -18,7 +18,8 @@ function initcropmodel(cropmodel::AbstractString, cropfile::AbstractString, grow
Tcroptype = SimpleCrop.CropType Tcroptype = SimpleCrop.CropType
Tcropstate = SimpleCrop.CropState Tcropstate = SimpleCrop.CropState
crops_almass = ALMaSS.readcropparameters(cropfile, growthfile) crops_almass = ALMaSS.readcropparameters(cropfile, growthfile)
crops = Dict(name => SimpleCrop.CropType(ct.name) for (name, ct) in crops_almass) crops = Dict(name => SimpleCrop.CropType(ct.name, ct.group, ct.minsowdate, ct.maxsowdate)
for (name, ct) in crops_almass)
else else
error("initcropmodel: no implementation for crop model '$cropmodel'") error("initcropmodel: no implementation for crop model '$cropmodel'")
end end
......
module SimpleCrop module SimpleCrop
using Persefone: using Persefone:
AnnualDate,
FarmPlot, FarmPlot,
Length, Length,
cm, cm,
...@@ -14,10 +15,17 @@ import Persefone: ...@@ -14,10 +15,17 @@ import Persefone:
cropcover, cropcover,
cropyield, cropyield,
sow!, sow!,
harvest! harvest!,
isharvestable
using Unitful: @u_str
# TODO: alternatively just use ALMaSS.CropType ?
struct CropType struct CropType
name::String name::String
group::String
minsowdate::Union{Missing,AnnualDate}
maxsowdate::Union{Missing,AnnualDate}
end end
cropname(ct::CropType) = ct.name cropname(ct::CropType) = ct.name
...@@ -64,8 +72,8 @@ function harvest!(cs::CropState, model::SimulationModel) ...@@ -64,8 +72,8 @@ function harvest!(cs::CropState, model::SimulationModel)
# TODO: set cs.croptype ? # TODO: set cs.croptype ?
# TODO: this 1.0g/cm/m^2 height_to_yield factor should be a param # TODO: this 1.0g/cm/m^2 height_to_yield factor should be a param
# for every crop type # for every crop type
yield = cs.height * 1.0g/cm/m^2 yield = cs.height * 1.0u"g/cm/m^2"
cs.height = 0cm cs.height = 5.0cm
return yield return yield
end end
......
...@@ -38,7 +38,7 @@ end ...@@ -38,7 +38,7 @@ end
end end
@testset "Submodule SimpleCrop" begin @testset "Submodule SimpleCrop" begin
ct = Ps.SimpleCrop.CropType("olive tree") ct = Ps.SimpleCrop.CropType("olive tree", "no_crop_group", AnnualDate(4, 1), AnnualDate(5, 1))
id = 0 id = 0
pixels = [(0, 0)] pixels = [(0, 0)]
farmer = 0 farmer = 0
......
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