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
d08fb074
Commit
d08fb074
authored
3 weeks ago
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
Various bugfixes in the MarbledWhite model
parent
fce2c738
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/analysis/makieplots.jl
+1
-1
1 addition, 1 deletion
src/analysis/makieplots.jl
src/nature/ecologicaldata.jl
+3
-3
3 additions, 3 deletions
src/nature/ecologicaldata.jl
src/nature/species/marbled_white.jl
+10
-11
10 additions, 11 deletions
src/nature/species/marbled_white.jl
with
14 additions
and
15 deletions
src/analysis/makieplots.jl
+
1
−
1
View file @
d08fb074
...
...
@@ -167,7 +167,7 @@ function marbledwhitelifestats(model::SimulationModel)
!
(
"MarbledWhite"
in
@param
(
nature
.
targetspecies
))
&&
return
nothing
f
=
Figure
(
size
=
(
1600
,
800
))
data
=
@data
(
"marbledwhite_lifestats"
)
iszero
(
length
(
data
))
&&
return
nothing
iszero
(
size
(
data
)
[
1
]
)
&&
return
nothing
n
=
length
(
data
[
!
,
"ID"
])
# fecundity / population density / displacement
violin
(
f
[
1
,
1
],
repeat
([
1
],
n
),
data
[
!
,
"Fecundity"
],
axis
=
(
ylabel
=
"Eggs/Female"
,
xticks
=
([
1
],
[
""
]),
title
=
"Fecundity"
))
...
...
This diff is collapsed.
Click to expand it.
src/nature/ecologicaldata.jl
+
3
−
3
View file @
d08fb074
...
...
@@ -144,7 +144,7 @@ function initmarbledwhitedata(model::SimulationModel)
@param
(
nature
.
popoutfreq
),
nothing
,
marbledwhitelifestats
)
newdataoutput!
(
model
,
"marbledwhite_trends"
,
[
"Year"
,
"Abundance"
,
"Occupancy"
,
"Temperature"
],
"
15 July
"
,
marbledwhitetrends
,
marbledwhitetrendsplot
)
"
20 September
"
,
marbledwhitetrends
,
marbledwhitetrendsplot
)
end
"""
...
...
@@ -181,8 +181,8 @@ Save marbledwhite abundance data, including total abundance and demographic data
"""
function
marbledwhitetrends
(
model
::
SimulationModel
)
trends
=
Dict
{
String
,
Int
}(
"Abundance"
=>
0
,
"Occupancy"
=>
0
,
"Temperature"
=>
0
)
# retrieve adult abundance
abundance
=
@data
(
"marbledwhite_
abundance"
)
.
Adults
[
end
]
# retrieve adult abundance
(i.e. the number of adults that flew this summer)
abundance
=
size
(
@subset
(
@data
(
"marbledwhite_
lifestats"
),
:
Year
.==
year
(
model
.
date
)))[
1
]
# calculate occupancy rate
width
,
height
=
size
(
model
.
landscape
)
occupied
,
totalsites
=
(
0
,
0
)
...
...
This diff is collapsed.
Click to expand it.
src/nature/species/marbled_white.jl
+
10
−
11
View file @
d08fb074
...
...
@@ -64,14 +64,14 @@
# lifecycle parameters
# (eggsperday and time parameters from Reinhardt et al. 2007)
const
maxeggsperday
=
6
# number of eggs laid under optimal conditions #TODO recalculate
const
maxeggsperday
=
5
# number of eggs laid under optimal conditions #TODO recalculate
const
eggtime
=
18
:
22
# days as egg
const
larvatime
=
290
:
320
# days as larva
const
pupatime
=
16
:
29
# days as pupa
const
maxadulttime
=
34
# maximum lifespan in days as adult #XXX Reinhardt et al. say 17-34
const
maturationtime
=
5
:
8
# days from hatching to first oviposition
const
juvenilemortality
=
0.98
#0:25 # in percent (Wilson 1985, Dennis 1992) #TODO check up
const
mowingmortality
=
0.
3
# juvenile mortality from mowing events
const
mowingmortality
=
0.
1
# juvenile mortality from mowing events
const
earliesteclosure
::
AnnualDate
=
(
June
,
15
)
# (Ebert & Rennwald 1991)
const
latesteclosure
::
AnnualDate
=
(
August
,
15
)
# (Ebert & Rennwald 1991)
...
...
@@ -228,7 +228,7 @@ the land cover must be either grass or fallow, and if grass, must either not
be managed, or not have been fertilised and be a certain height.
"""
function
suitablehabitat
(
butterfly
::
MarbledWhite
,
model
::
SimulationModel
,
pos
::
Tuple
{
Int64
,
Int64
})
(
@landcover
()
==
agriculture
&&
@cropname
()
==
"permanent set-aside"
)
||
(
@landcover
()
==
agriculture
&&
@cropname
()
==
"permanent set-aside"
)
||
#TODO check height
(
@landcover
()
==
grass
&&
(
@cropname
()
==
"NA"
||
(
@cropname
()
==
"permanent grassland (low yield)"
&&
@cropheight
()
>=
butterfly
.
minheight
&&
...
...
@@ -273,7 +273,7 @@ function recordlifestats(butterfly::MarbledWhite, model::SimulationModel)
# use Pythagoras to calculate the lifetime displacement
displacement
=
round
(
sqrt
(
sum
(
abs
.
(
butterfly
.
birthplace
.-
butterfly
.
pos
)
.^
2
)))
record!
(
model
,
"marbledwhite_lifestats"
,
[
butterfly
.
id
,
Y
ear
(
model
.
date
),
[
butterfly
.
id
,
y
ear
(
model
.
date
),
stats
[
"Fecundity"
],
# save current population density and lifetime displacement distances (but strip out units)
countanimals
(
butterfly
.
pos
,
model
,
radius
=
500
m
,
species
=
"MarbledWhite"
),
...
...
@@ -315,12 +315,13 @@ random, but I don't have data for that.)
eclose
=
self
.
birthdate
+
Day
(
self
.
daysinphase
[
1
]
+
self
.
daysinphase
[
2
]
+
self
.
daysinphase
[
3
])
if
eclose
<
self
.
earliesteclosure
diff
=
@nextyear
(
self
.
earliesteclosure
)
-
eclose
self
.
daysinphase
[
2
]
+=
diff
.
value
@debug
(
"Increased larval time by
$(diff)
to stay in flying period."
)
#XXX add a random increase to avoid hard cut-offs
self
.
daysinphase
[
2
]
+=
(
diff
.
value
+
@randn
(
0
:
60
))
@debug
(
"Increased larval time by >
$(diff)
to stay in flying period."
)
elseif
eclose
>
self
.
latesteclosure
diff
=
eclose
-
@nextyear
(
self
.
latesteclosure
)
self
.
daysinphase
[
2
]
-=
diff
.
value
@debug
(
"Reduced larval time by
$(diff)
to stay in flying period."
)
self
.
daysinphase
[
2
]
-=
(
diff
.
value
+
@randn
(
0
:
60
))
@debug
(
"Reduced larval time by
>
$(diff)
to stay in flying period."
)
end
end
self
.
birthplace
=
self
.
pos
...
...
@@ -330,14 +331,12 @@ end
Initialise the marbled white population with one individual on every grassland pixel.
"""
@populate
MarbledWhite
begin
#TODO this is very rough at the moment
habitat
=
@habitat
(
@cropname
()
==
"permanent grassland (low yield)"
||
@cropname
()
==
"permanent set-aside"
||
(
@cropname
()
==
"NA"
&&
@landcover
()
==
grass
))
initphase
=
egg
# this should advance within a few days to the correct phase
birthphase
=
egg
#popsize = 200 #FIXME use something else
indarea
=
1
ha
# initialise 1 individual per 100 suitable pixels #XXX
sex
=
female
#TODO change to hermaphrodite to force all individuals to have the same sex
sex
=
hermaphrodite
end
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