Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Persefone.jl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
26ee5084
Commit
26ee5084
authored
1 year ago
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
Added tests for insect submodel
parent
e82aa559
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/nature/insects.jl
+1
-1
1 addition, 1 deletion
src/nature/insects.jl
test/nature_tests.jl
+32
-4
32 additions, 4 deletions
test/nature_tests.jl
test/test_parameters.toml
+1
-0
1 addition, 0 deletions
test/test_parameters.toml
with
34 additions
and
5 deletions
src/nature/insects.jl
+
1
−
1
View file @
26ee5084
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
test/nature_tests.jl
+
32
−
4
View file @
26ee5084
...
...
@@ -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
This diff is collapsed.
Click to expand it.
test/test_parameters.toml
+
1
−
0
View file @
26ee5084
...
...
@@ -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)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment