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
791ff1d8
"02_Mesobromion_ExamineOutput.R" did not exist on "1dc7e5d5b769e1cf3b4a0fd3994c54059c292f86"
Commit
791ff1d8
authored
1 year ago
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
Refactored makieplots.jl
parent
629aaee2
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
Project.toml
+1
-1
1 addition, 1 deletion
Project.toml
src/analysis/makieplots.jl
+29
-14
29 additions, 14 deletions
src/analysis/makieplots.jl
src/core/output.jl
+1
-1
1 addition, 1 deletion
src/core/output.jl
with
31 additions
and
16 deletions
Project.toml
+
1
−
1
View file @
791ff1d8
name
=
"Persefone"
name
=
"Persefone"
uuid
=
"039acd1d-2a07-4b33-b082-83a1ff0fd136"
uuid
=
"039acd1d-2a07-4b33-b082-83a1ff0fd136"
authors
=
[
"Daniel Vedder <daniel.vedder@idiv.de>"
]
authors
=
[
"Daniel Vedder <daniel.vedder@idiv.de>"
]
version
=
"0.3.
5
"
version
=
"0.3.
6
"
[deps]
[deps]
Agents
=
"46ada45e-f475-11e8-01d0-f70cc89e6671"
Agents
=
"46ada45e-f475-11e8-01d0-f70cc89e6671"
...
...
This diff is collapsed.
Click to expand it.
src/analysis/makieplots.jl
+
29
−
14
View file @
791ff1d8
...
@@ -28,14 +28,16 @@ function visualisemap(model::AgentBasedModel,date=nothing,landcover=nothing)
...
@@ -28,14 +28,16 @@ function visualisemap(model::AgentBasedModel,date=nothing,landcover=nothing)
return
f
return
f
end
end
isnothing
(
date
)
&&
(
date
=
inds
.
Date
[
end
])
isnothing
(
date
)
&&
(
date
=
inds
.
Date
[
end
])
update_theme!
(
palette
=
(
color
=
cgrad
(
:
seaborn_bright
,
length
(
unique
(
inds
.
Species
))),),
update_theme!
(
palette
=
(
color
=
cgrad
(
:
seaborn_bright
,
length
(
@param
(
nature
.
targetspecies
))),),
cycle
=
[
:
color
])
cycle
=
[
:
color
])
for
s
in
unique
(
inds
.
S
pecies
)
for
s
in
@param
(
nature
.
targets
pecies
)
points
=
@select
!
(
@subset
(
inds
,
:
Species
.==
s
,
:
Date
.==
date
),
points
=
@select
!
(
@subset
(
inds
,
:
Species
.==
s
,
:
Date
.==
date
),
:
X
,
:
Y
)
:
X
,
:
Y
)
iszero
(
size
(
points
)[
1
])
&&
continue
# The origin in Makie is in the bottom-left rather than in the top-left as
# The origin in Makie is in the bottom-left rather than in the top-left as
# on the model map, so we have to invert the Y coordinates
# on the model map, so we have to invert the Y coordinates
@transform
!
(
points
,
:
Y
=
size
(
model
.
landscape
)[
2
]
.-
:
Y
)
@transform
!
(
points
,
:
Y
=
size
(
landcover
)[
2
]
.-
:
Y
)
scatter!
(
f
[
1
,
1
],
Matrix
{
Float32
}(
points
),
markersize
=
8
)
scatter!
(
f
[
1
,
1
],
Matrix
{
Float32
}(
points
),
markersize
=
8
)
end
end
f
f
...
@@ -50,7 +52,28 @@ Returns a Makie figure object.
...
@@ -50,7 +52,28 @@ Returns a Makie figure object.
function
populationtrends
(
model
::
AgentBasedModel
)
function
populationtrends
(
model
::
AgentBasedModel
)
pops
=
model
.
datatables
[
"populations"
]
pops
=
model
.
datatables
[
"populations"
]
# create the labels needed for the ticks on the X axis
# create the labels needed for the ticks on the X axis
update_theme!
(
palette
=
(
color
=
cgrad
(
:
seaborn_bright
,
length
(
unique
(
pops
.
Species
))),),
cycle
=
[
:
color
])
f
=
Figure
()
dates
=
@param
(
core
.
startdate
)
:
@param
(
core
.
enddate
)
dates
=
@param
(
core
.
startdate
)
:
@param
(
core
.
enddate
)
ax
=
Axis
(
f
[
1
,
1
],
xlabel
=
"Date"
,
ylabel
=
"Population size"
,
limits
=
((
1
,
length
(
dates
)),
nothing
),
xticks
=
gettickmarks
(
dates
))
for
s
in
@param
(
nature
.
targetspecies
)
points
=
@select
!
(
@subset
(
pops
,
:
Species
.==
s
),
:
Abundance
)
iszero
(
size
(
points
)[
1
])
&&
continue
lines!
(
f
[
1
,
1
],
Vector
{
Float32
}(
points
.
Abundance
),
linewidth
=
3
,
label
=
s
)
end
size
(
pops
)[
1
]
>
0
&&
axislegend
(
"Species"
;
position
=:
lt
)
f
end
"""
gettickmarks(dates)
Given a vector of dates, construct a selection to use as tick mark locations.
Helper function for `[populationtrends](@ref)`
"""
function
gettickmarks
(
dates
)
ticks
=
(
Int
[],
String
[])
ticks
=
(
Int
[],
String
[])
for
i
in
1
:
length
(
dates
)
for
i
in
1
:
length
(
dates
)
if
Day
(
dates
[
i
])
==
Day
(
1
)
if
Day
(
dates
[
i
])
==
Day
(
1
)
...
@@ -62,15 +85,7 @@ function populationtrends(model::AgentBasedModel)
...
@@ -62,15 +85,7 @@ function populationtrends(model::AgentBasedModel)
deleteat!
(
ticks
[
1
],
2
:
2
:
length
(
ticks
[
1
]))
deleteat!
(
ticks
[
1
],
2
:
2
:
length
(
ticks
[
1
]))
deleteat!
(
ticks
[
2
],
2
:
2
:
length
(
ticks
[
2
]))
deleteat!
(
ticks
[
2
],
2
:
2
:
length
(
ticks
[
2
]))
end
end
update_theme!
(
palette
=
(
color
=
cgrad
(
:
seaborn_bright
,
length
(
unique
(
pops
.
Species
))),),
ticks
cycle
=
[
:
color
])
f
=
Figure
()
ax
=
Axis
(
f
[
1
,
1
],
xlabel
=
"Date"
,
ylabel
=
"Population size"
,
limits
=
((
1
,
length
(
dates
)),
nothing
),
xticks
=
ticks
)
for
s
in
unique
(
pops
.
Species
)
points
=
@select
!
(
@subset
(
pops
,
:
Species
.==
s
),
:
Abundance
)
lines!
(
f
[
1
,
1
],
Vector
{
Float32
}(
points
.
Abundance
),
linewidth
=
3
,
label
=
s
)
end
size
(
pops
)[
1
]
>
0
&&
axislegend
(
"Species"
;
position
=:
lt
)
f
end
end
#XXX add animation with record()? https://docs.makie.org/stable/explanations/animation/
This diff is collapsed.
Click to expand it.
src/core/output.jl
+
1
−
1
View file @
791ff1d8
...
@@ -217,7 +217,7 @@ saving each figure as a PDF.
...
@@ -217,7 +217,7 @@ saving each figure as a PDF.
"""
"""
function
visualiseoutput
(
model
::
AgentBasedModel
,
format
::
String
=
"pdf"
)
function
visualiseoutput
(
model
::
AgentBasedModel
,
format
::
String
=
"pdf"
)
@debug
"Visualising output."
@debug
"Visualising output."
CairoMakie
.
activate!
()
CairoMakie
.
activate!
()
# make sure we're using Cairo
for
output
in
model
.
dataoutputs
for
output
in
model
.
dataoutputs
isnothing
(
output
.
plotfunction
)
&&
continue
isnothing
(
output
.
plotfunction
)
&&
continue
figure
=
output
.
plotfunction
(
model
)
figure
=
output
.
plotfunction
(
model
)
...
...
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