From 9a0ac83cc964034b77d3706f1214c92514eb0b69 Mon Sep 17 00:00:00 2001 From: Daniel Vedder <daniel.vedder@idiv.de> Date: Wed, 18 Oct 2023 10:19:55 +0200 Subject: [PATCH] Added precompilation and the `visualise` setting --- Project.toml | 2 +- src/Persefone.jl | 7 ++++--- src/analysis/makieplots.jl | 5 ++++- src/core/simulation.jl | 2 +- src/parameters.toml | 1 + 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 3bf9f92..e261199 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Persefone" uuid = "039acd1d-2a07-4b33-b082-83a1ff0fd136" authors = ["Daniel Vedder <daniel.vedder@idiv.de>"] -version = "0.3.1" +version = "0.3.2" [deps] Agents = "46ada45e-f475-11e8-01d0-f70cc89e6671" diff --git a/src/Persefone.jl b/src/Persefone.jl index da3f1cd..9dc807d 100644 --- a/src/Persefone.jl +++ b/src/Persefone.jl @@ -24,7 +24,7 @@ using Distributed, FileIO, #FIXME an upstream update broke GeoArrays for TableTransforms > 1.15.0 - GeoArrays, #XXX this is a big dependency - can we get rid of it? + GeoArrays, Logging, LoggingExtras, Random, @@ -114,7 +114,8 @@ include("nature/species/wyvern.jl") include("core/simulation.jl") #this must be last -#XXX precompile? -> PrecompileTools doesn't really give an improvement -# https://julialang.org/blog/2021/01/precompile_tutorial/ +# precompile important functions +precompile(initialise, (String,Int)) +precompile(stepsimulation!, (AgentBasedModel,)) end diff --git a/src/analysis/makieplots.jl b/src/analysis/makieplots.jl index 3967eeb..13bd6a5 100644 --- a/src/analysis/makieplots.jl +++ b/src/analysis/makieplots.jl @@ -22,7 +22,10 @@ function visualisemap(model::AgentBasedModel,date=nothing,landcover=nothing) ax.aspect = DataAspect() # check if there are individuals and plot them inds = model.datatables["individuals"] - iszero(size(inds)[1]) && return f + if iszero(size(inds)[1]) + @debug "No individual data to map" + return f + end isnothing(date) && (date = inds.Date[end]) for s in unique(inds.Species) points = @select!(@subset(inds, :Species .== s, :Date .== date), diff --git a/src/core/simulation.jl b/src/core/simulation.jl index 51dfdbf..81d931a 100644 --- a/src/core/simulation.jl +++ b/src/core/simulation.jl @@ -152,7 +152,7 @@ function finalise!(model::AgentBasedModel) with_logger(model.logger) do @info "Simulated $(model.date-@param(core.startdate))." @info "Simulation run completed at $(Dates.now()),\nwrote output to $(@param(core.outdir))." - visualiseoutput(model) + @param(core.visualise) && visualiseoutput(model) model end end diff --git a/src/parameters.toml b/src/parameters.toml index 99cea97..79bba3e 100644 --- a/src/parameters.toml +++ b/src/parameters.toml @@ -11,6 +11,7 @@ configfile = "src/parameters.toml" # location of the configuration file outdir = "results" # location and name of the output folder overwrite = "ask" # overwrite the output directory? (true/false/"ask") csvoutput = true # save collected data in CSV files +visualise = true # generate result graphs storedata = true # keep collected data in memory loglevel = "debug" # verbosity level: "debug", "info", "warn" processors = 2 # number of processors to use on parallel runs -- GitLab