Skip to content
Snippets Groups Projects
Commit 33770923 authored by xo30xoqa's avatar xo30xoqa
Browse files

Fixed bug in makieplots

parent 26eb0dd5
Branches
Tags v0.3.0
No related merge requests found
......@@ -2,7 +2,7 @@
julia_version = "1.9.3"
manifest_format = "2.0"
project_hash = "ce171af7d57f8fcad6d5ea123349f467345ec803"
project_hash = "ba06f527c3b60c5d5c4950e08943bcf1017cc1e3"
[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
......
name = "Persefone"
uuid = "039acd1d-2a07-4b33-b082-83a1ff0fd136"
authors = ["Daniel Vedder <daniel.vedder@idiv.de>"]
version = "0.2.0"
version = "0.3.0"
[deps]
Agents = "46ada45e-f475-11e8-01d0-f70cc89e6671"
......@@ -18,12 +18,14 @@ ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
TiffImages = "731e570b-9d59-4bfa-96dc-6df516fadf69"
[compat]
Agents = ">= 5.6"
......
......@@ -8,10 +8,10 @@
version="1.1"
id="svg8"
inkscape:version="1.3 (1:1.3+202307231459+0e150ed6c4)"
sodipodi:docname="persefonejl_logo_v3.svg"
sodipodi:docname="persefonejl_logo_v3_icon.svg"
inkscape:export-filename="persefonejl_logo_v3.png"
inkscape:export-xdpi="300"
inkscape:export-ydpi="300"
inkscape:export-xdpi="40.639999"
inkscape:export-ydpi="40.639999"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
......
docs/persefonejl_logo_v3_splash.png

131 KiB | W: | H:

docs/persefonejl_logo_v3_splash.png

124 KiB | W: | H:

docs/persefonejl_logo_v3_splash.png
docs/persefonejl_logo_v3_splash.png
docs/persefonejl_logo_v3_splash.png
docs/persefonejl_logo_v3_splash.png
  • 2-up
  • Swipe
  • Onion skin
This diff is collapsed.
......@@ -16,6 +16,7 @@ module Persefone
using
Agents,
ArgParse,
CairoMakie, #XXX this is a very big dependency :-(
CSV,
Dates,
DataFrames,
......@@ -26,7 +27,7 @@ using
GeoArrays, #XXX this is a big dependency - can we get rid of it?
Logging,
LoggingExtras,
CairoMakie, #XXX this is a very big dependency :-(
#PrecompileTools, #TODO
Random,
Serialization,
StableRNGs,
......@@ -114,4 +115,8 @@ include("nature/species/wyvern.jl")
include("core/simulation.jl") #this must be last
#XXX precompile?
# https://julialang.org/blog/2021/01/precompile_tutorial/
# https://julialang.github.io/PrecompileTools.jl/stable/
end
......@@ -4,30 +4,33 @@
###
"""
visualisemap(model, date)
visualisemap(model, date, landcovermap)
Draw the model's land cover map and plot all individuals as points on it at the
specified date. If no date is passed, use the last date for which data are available.
Draw the model's land cover map and plot all individuals as points on it at
the specified date. If no date is passed, use the last date for which data
are available. Optionally, you can pass a landcover map image (this is needed
to reduce the frequency of disk I/O for Persefone Desktop).
Returns a Makie figure object.
"""
function visualisemap(model::AgentBasedModel, date::Union{Date,Nothing}=nothing)
# extract the data from the model and load the map
inds = model.datatables["individuals"]
isnothing(date) && (date = inds.Date[end])
landcover = load(@param(world.landcovermap))
# draw the map
function visualisemap(model::AgentBasedModel,date=nothing,landcover=nothing)
# load and plot the map
isnothing(landcover) && (landcover = load(@param(world.landcovermap)))
f = Figure()
ax = Axis(f[1,1])
hidedecorations!(ax)
image!(f[1,1], rotr90(landcover))
ax.aspect = DataAspect()
# plot individuals
# check if there are individuals and plot them
inds = model.datatables["individuals"]
iszero(size(inds)[1]) && return f
isnothing(date) && (date = inds.Date[end])
for s in unique(inds.Species)
points = @select!(@subset(inds, :Species .== s, :Date .== date), :X, :Y)
points = @select!(@subset(inds, :Species .== s, :Date .== date),
:X, :Y)
# 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
@transform!(points, :Y = size(model.landscape)[2] .- :Y)
scatter!(f[1,1], Matrix{Float32}(points), markersize=10)
scatter!(f[1,1], Matrix{Float32}(points), markersize=8)
end
f
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment