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
db386d25
Commit
db386d25
authored
3 months ago
by
Marco Matthies
Browse files
Options
Downloads
Patches
Plain Diff
Fix visualiseoutput test failures
parent
acc4b4b4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/analysis/makieplots.jl
+29
-15
29 additions, 15 deletions
src/analysis/makieplots.jl
with
29 additions
and
15 deletions
src/analysis/makieplots.jl
+
29
−
15
View file @
db386d25
...
...
@@ -3,6 +3,8 @@
### This file visualises model output using Makie.
###
const
MIN_AXISLIMIT
::
Float64
=
1e-5
"""
visualisemap(model, date, landcover)
...
...
@@ -59,7 +61,7 @@ function populationtrends(model::SimulationModel)
update_theme!
(
palette
=
(
color
=
cgrad
(
:
seaborn_bright
,
ncolors
),),
cycle
=
[
:
color
])
f
=
Figure
()
dates
=
@param
(
core
.
startdate
)
:
@param
(
core
.
enddate
)
axlimits
=
(
1
,
length
(
dates
),
0
,
maximum
(
pops
[
!
,
:
Abundance
])
*
1.1
)
axlimits
=
(
1
,
length
(
dates
),
0
,
max
(
MIN_AXISLIMIT
,
maximum
(
pops
[
!
,
:
Abundance
]
;
init
=
0
)
*
1.1
)
)
ax
=
Axis
(
f
[
1
,
1
],
xlabel
=
"Date"
,
ylabel
=
"Population size"
,
limits
=
axlimits
,
xticks
=
datetickmarks
(
dates
))
for
s
in
@param
(
nature
.
targetspecies
)
...
...
@@ -82,7 +84,7 @@ function skylarkpopulation(model::SimulationModel)
pops
=
@data
(
"skylark_abundance"
)
f
=
Figure
()
dates
=
@param
(
core
.
startdate
)
:
@param
(
core
.
enddate
)
axlimits
=
(
1
,
length
(
dates
),
0
,
maximum
(
pops
[
!
,
:
TotalAbundance
]))
axlimits
=
(
1
,
length
(
dates
),
0
,
max
(
MIN_AXISLIMIT
,
maximum
(
pops
[
!
,
:
TotalAbundance
]
;
init
=
0
)
))
ax
=
Axis
(
f
[
1
,
1
],
xlabel
=
"Date"
,
ylabel
=
"Population size"
,
limits
=
axlimits
,
xticks
=
datetickmarks
(
dates
))
lines!
(
f
[
1
,
1
],
Vector
{
Float32
}(
pops
.
TotalAbundance
),
linewidth
=
3
,
label
=
"Total abundance"
)
...
...
@@ -108,20 +110,28 @@ function skylarkstats(model::SimulationModel)
# nesting habitat
habitattype
=
unique
(
nestingdata
.
Landcover
)
htfrequency
=
[
count
(
x
->
x
==
h
,
nestingdata
.
Landcover
)
for
h
in
habitattype
]
barplot
(
f
[
1
,
1
],
1
:
length
(
habitattype
),
htfrequency
,
axis
=
(
xticks
=
(
1
:
length
(
habitattype
),
habitattype
),
title
=
"Nesting habitat"
))
if
!
isempty
(
habitattype
)
barplot
(
f
[
1
,
1
],
1
:
length
(
habitattype
),
htfrequency
,
axis
=
(
xticks
=
(
1
:
length
(
habitattype
),
habitattype
),
title
=
"Nesting habitat"
))
end
croptype
=
unique
(
nestingdata
.
Crop
)
ctfrequency
=
[
count
(
x
->
x
==
c
,
nestingdata
.
Crop
)
for
c
in
croptype
]
barplot
(
f
[
2
,
1
],
1
:
length
(
croptype
),
ctfrequency
,
axis
=
(
xticks
=
(
1
:
length
(
croptype
),
croptype
),
title
=
"Nesting crop type"
))
if
!
isempty
(
croptype
)
barplot
(
f
[
2
,
1
],
1
:
length
(
croptype
),
ctfrequency
,
axis
=
(
xticks
=
(
1
:
length
(
croptype
),
croptype
),
title
=
"Nesting crop type"
))
end
# mortality
causes
=
unique
(
mortalitydata
.
Cause
)
mtfrequency
=
[
count
(
x
->
x
==
c
,
mortalitydata
.
Cause
)
for
c
in
causes
]
barplot
(
f
[
1
,
2
],
1
:
length
(
causes
),
mtfrequency
,
axis
=
(
xticks
=
(
1
:
length
(
causes
),
causes
),
title
=
"Causes of Mortality"
))
if
!
isempty
(
causes
)
barplot
(
f
[
1
,
2
],
1
:
length
(
causes
),
mtfrequency
,
axis
=
(
xticks
=
(
1
:
length
(
causes
),
causes
),
title
=
"Causes of Mortality"
))
end
# territory size
hist
(
f
[
2
,
2
],
nestingdata
.
Territory
,
bins
=
20
,
axis
=
(
ylabel
=
"Frequency"
,
title
=
"Territory size (ha)"
))
if
!
isempty
(
nestingdata
.
Territory
)
hist
(
f
[
2
,
2
],
nestingdata
.
Territory
,
bins
=
20
,
axis
=
(
ylabel
=
"Frequency"
,
title
=
"Territory size (ha)"
))
end
f
end
...
...
@@ -136,17 +146,19 @@ function croptrends(model::SimulationModel)
f
=
Figure
(
size
=
(
1200
,
1000
))
dates
=
@param
(
core
.
startdate
)
:
@param
(
core
.
enddate
)
# plot cropped area over time
axlimitsarea
=
(
1
,
length
(
dates
),
0
,
maximum
(
cropdata
[
!
,
:
Area
])
*
1.1
)
axlimitsarea
=
(
1
,
length
(
dates
),
0
,
max
(
MIN_AXISLIMIT
,
maximum
(
cropdata
[
!
,
:
Area
]
;
init
=
0
)
*
1.1
)
)
ax1
=
Axis
(
f
[
1
,
1
],
xlabel
=
"Date"
,
ylabel
=
"Cropped area (ha)"
,
limits
=
axlimitsarea
,
xticks
=
datetickmarks
(
dates
))
limits
=
axlimitsarea
,
xticks
=
datetickmarks
(
dates
))
for
c
in
unique
(
cropdata
.
Crop
)
points
=
@select
!
(
@subset
(
cropdata
,
:
Crop
.==
c
),
:
Area
)
(
iszero
(
size
(
points
)[
1
])
||
iszero
(
sum
(
points
.
Area
)))
&&
continue
lines!
(
f
[
1
,
1
],
Vector
{
Float32
}(
points
.
Area
),
linewidth
=
3
,
label
=
c
)
end
axislegend
(
"Crop"
;
position
=:
rt
)
if
!
isempty
(
cropdata
.
Crop
)
axislegend
(
"Crop"
;
position
=:
rt
)
end
# plot average crop height over time
axlimitsheight
=
(
1
,
length
(
dates
),
0
,
maximum
(
cropdata
[
!
,
:
Height
])
*
1.1
)
axlimitsheight
=
(
1
,
length
(
dates
),
0
,
max
(
MIN_AXISLIMIT
,
maximum
(
cropdata
[
!
,
:
Height
]
;
init
=
0
)
*
1.1
)
)
ax2
=
Axis
(
f
[
2
,
1
],
xlabel
=
"Date"
,
ylabel
=
"Average plant height (cm)"
,
limits
=
axlimitsheight
,
xticks
=
datetickmarks
(
dates
))
for
c
in
unique
(
cropdata
.
Crop
)
...
...
@@ -154,7 +166,9 @@ function croptrends(model::SimulationModel)
(
iszero
(
size
(
points
)[
1
])
||
iszero
(
sum
(
points
.
Height
)))
&&
c
!=
"no growth"
&&
continue
lines!
(
f
[
2
,
1
],
Vector
{
Float32
}(
points
.
Height
),
linewidth
=
3
,
label
=
c
)
end
axislegend
(
"Crop"
;
position
=:
rt
)
if
!
isempty
(
cropdata
.
Crop
)
axislegend
(
"Crop"
;
position
=:
rt
)
end
f
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