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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
a3ce5121
Commit
a3ce5121
authored
Jun 20, 2024
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
Renamed EventType to Management
parent
04b3efec
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/crop/farmplot.jl
+2
-2
2 additions, 2 deletions
src/crop/farmplot.jl
src/nature/insects.jl
+1
-1
1 addition, 1 deletion
src/nature/insects.jl
src/nature/species/skylark.jl
+10
-7
10 additions, 7 deletions
src/nature/species/skylark.jl
src/world/landscape.jl
+6
-6
6 additions, 6 deletions
src/world/landscape.jl
with
19 additions
and
16 deletions
src/crop/farmplot.jl
+
2
−
2
View file @
a3ce5121
...
@@ -22,7 +22,7 @@ mutable struct FarmPlot <: ModelAgent
...
@@ -22,7 +22,7 @@ mutable struct FarmPlot <: ModelAgent
LAItotal
::
Float64
LAItotal
::
Float64
LAIgreen
::
Float64
LAIgreen
::
Float64
#biomass::Float64 #XXX I need to figure out how to calculate this
#biomass::Float64 #XXX I need to figure out how to calculate this
events
::
Vector
{
EventType
}
events
::
Vector
{
Management
}
end
end
"""
"""
...
@@ -50,7 +50,7 @@ function initfields!(model::SimulationModel)
...
@@ -50,7 +50,7 @@ function initfields!(model::SimulationModel)
month
(
model
.
date
)
<
3
?
phase
=
janfirst
:
phase
=
marchfirst
month
(
model
.
date
)
<
3
?
phase
=
janfirst
:
phase
=
marchfirst
fp
=
FarmPlot
(
length
(
model
.
farmplots
)
+
1
,
[(
x
,
y
)],
fp
=
FarmPlot
(
length
(
model
.
farmplots
)
+
1
,
[(
x
,
y
)],
model
.
crops
[
"natural grass"
],
phase
,
model
.
crops
[
"natural grass"
],
phase
,
0.0
,
0.0
,
0.0
,
0.0
,
Vector
{
EventType
}())
0.0
,
0.0
,
0.0
,
0.0
,
Vector
{
Management
}())
push!
(
model
.
farmplots
,
fp
)
push!
(
model
.
farmplots
,
fp
)
model
.
landscape
[
x
,
y
]
.
fieldid
=
fp
.
id
model
.
landscape
[
x
,
y
]
.
fieldid
=
fp
.
id
convertid
[
rawid
]
=
fp
.
id
convertid
[
rawid
]
=
fp
.
id
...
...
This diff is collapsed.
Click to expand it.
src/nature/insects.jl
+
1
−
1
View file @
a3ce5121
...
@@ -38,7 +38,7 @@ function insectbiomass(pixel::Pixel, model::SimulationModel)::Float64
...
@@ -38,7 +38,7 @@ function insectbiomass(pixel::Pixel, model::SimulationModel)::Float64
## based on fig. 3a in Paquette et al. (2013)
## based on fig. 3a in Paquette et al. (2013)
if
"season"
in
@param
(
nature
.
insectmodel
)
if
"season"
in
@param
(
nature
.
insectmodel
)
calendarday
=
dayofyear
(
model
.
date
)
calendarday
=
dayofyear
(
model
.
date
)
seasonfactor
=
-
0.085
(
calendarday
-
187
)
^
2
seasonfactor
=
(
-
0.085
(
calendarday
-
187
)
^
2
)
mg
/
m²
end
end
## habitat dependence of insect biomass,
## habitat dependence of insect biomass,
...
...
This diff is collapsed.
Click to expand it.
src/nature/species/skylark.jl
+
10
−
7
View file @
a3ce5121
...
@@ -31,9 +31,9 @@ At the moment, this implementation is still in development.
...
@@ -31,9 +31,9 @@ At the moment, this implementation is still in development.
"""
"""
@species
Skylark
begin
@species
Skylark
begin
# species parameters
# species parameters
const
eggtime
::
Int64
=
11
#
11
days from laying to hatching
const
eggtime
::
Int64
=
11
# days from laying to hatching
const
nestlingtime
::
UnitRange
{
Int64
}
=
7
:
11
#
7-11
days from hatching to leaving nest
const
nestlingtime
::
UnitRange
{
Int64
}
=
7
:
11
# days from hatching to leaving nest
const
fledglingtime
::
UnitRange
{
Int64
}
=
25
:
30
#
25-30
days from hatching to independence
const
fledglingtime
::
UnitRange
{
Int64
}
=
25
:
30
# days from hatching to independence
const
eggpredationmortality
::
Float64
=
0.03
# per-day egg mortality from predation
const
eggpredationmortality
::
Float64
=
0.03
# per-day egg mortality from predation
const
nestharvestmortality
::
Float64
=
0.9
# egg/nestling mortality after a harvest event (XXX guess)
const
nestharvestmortality
::
Float64
=
0.9
# egg/nestling mortality after a harvest event (XXX guess)
...
@@ -45,8 +45,8 @@ At the moment, this implementation is still in development.
...
@@ -45,8 +45,8 @@ At the moment, this implementation is still in development.
const
nestingbegin
::
Tuple
{
Int64
,
Int64
}
=
(
April
,
10
)
# begin nesting in the middle of April
const
nestingbegin
::
Tuple
{
Int64
,
Int64
}
=
(
April
,
10
)
# begin nesting in the middle of April
const
nestbuildingtime
::
UnitRange
{
Int64
}
=
4
:
5
# 4-5 days needed to build a nest (doubled for first nest)
const
nestbuildingtime
::
UnitRange
{
Int64
}
=
4
:
5
# 4-5 days needed to build a nest (doubled for first nest)
const
eggsperclutch
::
UnitRange
{
Int64
}
=
2
:
5
#
2-5
eggs laid per clutch
const
eggsperclutch
::
UnitRange
{
Int64
}
=
2
:
5
# eggs laid per clutch
const
breedingdelay
::
Int64
=
18
#
wait 18
days after hatching
to
start a new brood
const
breedingdelay
::
Int64
=
18
# days after hatching
before
start
ing
a new brood
const
nestingend
::
Int64
=
July
# last month of nesting
const
nestingend
::
Int64
=
July
# last month of nesting
const
habitats
::
Function
=
skylarkhabitat
const
habitats
::
Function
=
skylarkhabitat
...
@@ -221,11 +221,14 @@ Do lots of foraging (not yet implemented).
...
@@ -221,11 +221,14 @@ Do lots of foraging (not yet implemented).
# if all young have fledged, move to nonbreeding (if it's July) or breed again
# if all young have fledged, move to nonbreeding (if it's July) or breed again
if
isempty
(
self
.
clutch
)
if
isempty
(
self
.
clutch
)
self
.
nest
=
()
self
.
nest
=
()
month
(
model
.
date
)
>=
self
.
nestingend
?
if
month
(
model
.
date
)
>=
self
.
nestingend
@setphase
(
nonbreeding
)
:
self
.
territory
=
[]
@setphase
(
nonbreeding
)
else
@setphase
(
nestbuilding
)
@setphase
(
nestbuilding
)
end
end
end
end
end
"""
"""
migrationdates(skylark, model)
migrationdates(skylark, model)
...
...
This diff is collapsed.
Click to expand it.
src/world/landscape.jl
+
6
−
6
View file @
a3ce5121
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
"The land cover classes encoded in the Mundialis Sentinel data."
"The land cover classes encoded in the Mundialis Sentinel data."
@enum
LandCover
nodata
forest
grass
water
builtup
soil
agriculture
@enum
LandCover
nodata
forest
grass
water
builtup
soil
agriculture
"The types of
l
an
dscape
event that can be simulated"
"The types of
m
an
agement
event that can be simulated"
@enum
EventType
tillage
sowing
fertiliser
pesticide
harvesting
@enum
Management
tillage
sowing
fertiliser
pesticide
harvesting
#XXX rename to Management or similar?
#XXX rename to Management or similar?
"""
"""
...
@@ -21,7 +21,7 @@ in a single object. The model landscape consists of a matrix of pixels.
...
@@ -21,7 +21,7 @@ in a single object. The model landscape consists of a matrix of pixels.
mutable struct
Pixel
mutable struct
Pixel
landcover
::
LandCover
landcover
::
LandCover
fieldid
::
Union
{
Missing
,
Int64
}
fieldid
::
Union
{
Missing
,
Int64
}
events
::
Vector
{
EventType
}
events
::
Vector
{
Management
}
animals
::
Vector
{
Int64
}
animals
::
Vector
{
Int64
}
end
end
...
@@ -32,7 +32,7 @@ A data structure to define a landscape event, giving its type,
...
@@ -32,7 +32,7 @@ A data structure to define a landscape event, giving its type,
spatial extent, and duration.
spatial extent, and duration.
"""
"""
mutable struct
FarmEvent
mutable struct
FarmEvent
etype
::
EventType
management
::
Management
pixels
::
Vector
{
Tuple
{
Int64
,
Int64
}}
pixels
::
Vector
{
Tuple
{
Int64
,
Int64
}}
duration
::
Int64
duration
::
Int64
end
end
...
@@ -82,7 +82,7 @@ function updateevents!(model::SimulationModel)
...
@@ -82,7 +82,7 @@ function updateevents!(model::SimulationModel)
if
event
.
duration
<=
0
if
event
.
duration
<=
0
push!
(
expiredevents
,
e
)
push!
(
expiredevents
,
e
)
for
p
in
event
.
pixels
for
p
in
event
.
pixels
i
=
findnext
(
x
->
x
==
event
.
etype
,
model
.
landscape
[
p
...
]
.
events
,
1
)
i
=
findnext
(
x
->
x
==
event
.
management
,
model
.
landscape
[
p
...
]
.
events
,
1
)
deleteat!
(
model
.
landscape
[
p
...
]
.
events
,
i
)
deleteat!
(
model
.
landscape
[
p
...
]
.
events
,
i
)
end
end
end
end
...
@@ -96,7 +96,7 @@ end
...
@@ -96,7 +96,7 @@ end
Add a farm event to the specified pixels (a vector of position tuples) for a given duration.
Add a farm event to the specified pixels (a vector of position tuples) for a given duration.
"""
"""
function
createevent!
(
model
::
SimulationModel
,
pixels
::
Vector
{
Tuple
{
Int64
,
Int64
}},
function
createevent!
(
model
::
SimulationModel
,
pixels
::
Vector
{
Tuple
{
Int64
,
Int64
}},
name
::
EventType
,
duration
::
Int64
=
1
)
name
::
Management
,
duration
::
Int64
=
1
)
push!
(
model
.
events
,
FarmEvent
(
name
,
pixels
,
duration
))
push!
(
model
.
events
,
FarmEvent
(
name
,
pixels
,
duration
))
for
p
in
pixels
for
p
in
pixels
push!
(
model
.
landscape
[
p
...
]
.
events
,
name
)
push!
(
model
.
landscape
[
p
...
]
.
events
,
name
)
...
...
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
sign in
to comment