Skip to content
Snippets Groups Projects
Commit 26ee5084 authored by xo30xoqa's avatar xo30xoqa
Browse files

Added tests for insect submodel

parent e82aa559
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ function insectbiomass(pixel::Pixel, model::AgentBasedModel)::Float64
weatherfactor = 1.0
pesticidefactor = 1.0
## parabolic curve of seasonal development,
## parabolic curve of seasonal development (peaking on the 6th of July),
## based on fig. 3a in Paquette et al. (2013)
if "season" in @param(nature.insectmodel)
calendarday = dayofyear(model.date)
......
......@@ -137,10 +137,38 @@ end
@test @rand([true, true])
end
@testset "Insect submodel" begin
# create a set of pixels and dates for testing
model = smalltestlandscape()
#TODO create a set of pixels and check if their calculated biomass
# meets the expected values
date1 = Date("2023-05-08") # day 128 (season begin)
date2 = Date("2023-07-06") # day 187 (insect max)
date3 = Date("2023-09-27") # day 270 (season end)
p1 = Pixel(Ps.agriculture, 1, [])
p2 = Pixel(Ps.agriculture, 1, [Ps.pesticide])
p3 = Pixel(Ps.grass, 1, [])
p4 = Pixel(Ps.soil, 1, [Ps.fertiliser, Ps.pesticide])
p5 = Pixel(Ps.forest, 1, [])
p6 = Pixel(Ps.water, 1, [])
# check whether the model calculates the same numbers I did by hand
model.date = date1
@test Ps.insectbiomass(p1, model) 4.11 atol=0.01
@test Ps.insectbiomass(p2, model) == 0.0
@test Ps.insectbiomass(p3, model) 154.11 atol=0.01
@test Ps.insectbiomass(p4, model) 4.11 atol=0.01
@test Ps.insectbiomass(p5, model) 304.11 atol=0.01
@test Ps.insectbiomass(p6, model) == 0.0
model.date = date2
@test Ps.insectbiomass(p1, model) == 300.0
@test Ps.insectbiomass(p2, model) == 150.0
@test Ps.insectbiomass(p3, model) == 450.0
@test Ps.insectbiomass(p4, model) == 300.0
@test Ps.insectbiomass(p5, model) == 600.0
@test Ps.insectbiomass(p6, model) == 0.0
model.date = date3
@test Ps.insectbiomass(p1, model) == 0.0
@test Ps.insectbiomass(p2, model) == 0.0
@test Ps.insectbiomass(p3, model) == 0.0
@test Ps.insectbiomass(p4, model) == 0.0
@test Ps.insectbiomass(p5, model) 14.43 atol=0.01
@test Ps.insectbiomass(p6, model) == 0.0
end
......@@ -27,6 +27,7 @@ farmmodel = "FieldManager" # which version of the farm model to use (not yet imp
targetspecies = ["Wolpertinger", "Wyvern"] # list of target species to simulate
popoutfreq = "daily" # output frequency population-level data, daily/monthly/yearly/end/never
indoutfreq = "end" # output frequency individual-level data, daily/monthly/yearly/end/never
insectmodel = ["season", "habitat", "pesticides"] # which factors affect insect growth ("weather" is not yet implemented)
[crop]
cropmodel = "linear" # crop growth model to use, "linear" or "aquacrop" (not yet implemented)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment