diff --git a/src/nature/insects.jl b/src/nature/insects.jl index a513dd8801a24bc4f14ab06cea0833b037a1628a..c0fd291b6ab1c10f0421751bef6d31d5f080506e 100644 --- a/src/nature/insects.jl +++ b/src/nature/insects.jl @@ -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) diff --git a/test/nature_tests.jl b/test/nature_tests.jl index 33260d9079a9df323dbb3ed5283b57b87944ecac..7495004731dab9a5838facceaddd29d112ff3b9c 100644 --- a/test/nature_tests.jl +++ b/test/nature_tests.jl @@ -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 diff --git a/test/test_parameters.toml b/test/test_parameters.toml index f4cc679068ae61e9bfe67621a2d21b80d5b63cd0..53792a90a6c9e61beadfddd64746745c6bf31c1d 100644 --- a/test/test_parameters.toml +++ b/test/test_parameters.toml @@ -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)