From 26eb0dd512a3fb1b585f099fb6bac9c672ac776a Mon Sep 17 00:00:00 2001 From: Daniel Vedder <daniel.vedder@idiv.de> Date: Tue, 10 Oct 2023 16:42:18 +0200 Subject: [PATCH] Small bug fixes. This closes #47 --- src/Persefone.jl | 5 ++--- src/analysis/makieplots.jl | 5 +++-- src/core/input.jl | 12 ++++++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Persefone.jl b/src/Persefone.jl index a3550f2..be4ebff 100644 --- a/src/Persefone.jl +++ b/src/Persefone.jl @@ -22,10 +22,11 @@ using DataFramesMeta, 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? Logging, LoggingExtras, - CairoMakie, + CairoMakie, #XXX this is a very big dependency :-( Random, Serialization, StableRNGs, @@ -34,13 +35,11 @@ using ## Packages that may be useful later on: # MacroTools, http://fluxml.ai/MacroTools.jl/stable/utilities/ # Debugger, https://github.com/JuliaDebug/Debugger.jl -# Makie, https://docs.makie.org/stable/ # PackageCompiler, https://julialang.github.io/PackageCompiler.jl/stable/ # SpatialEcology, https://github.com/EcoJulia/SpatialEcology.jl # OmniScape, https://circuitscape.org/ # PlantSimEngine, https://virtualplantlab.github.io/PlantSimEngine.jl/stable/ # Overseer, https://juliapackages.com/p/overseer -> ECS -# QML, https://juliapackages.com/p/qml ## define exported functions and variables export diff --git a/src/analysis/makieplots.jl b/src/analysis/makieplots.jl index 691c7f9..463a0f6 100644 --- a/src/analysis/makieplots.jl +++ b/src/analysis/makieplots.jl @@ -22,10 +22,11 @@ function visualisemap(model::AgentBasedModel, date::Union{Date,Nothing}=nothing) image!(f[1,1], rotr90(landcover)) ax.aspect = DataAspect() # plot individuals - #FIXME this function displays the individuals in a different location than the - # R script does - somewhere, I'm confusing coordinates... for s in unique(inds.Species) 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) end f diff --git a/src/core/input.jl b/src/core/input.jl index 7d3ccf7..16b377c 100644 --- a/src/core/input.jl +++ b/src/core/input.jl @@ -13,6 +13,9 @@ const PARAMFILE = joinpath(pkgdir(Persefone), "src/parameters.toml") ## (DO NOT CHANGE THIS VALUE! Instead, specify simulation-specific configuration files ## by using the "--configfile" commandline argument, or when invoking simulate().) +#XXX do I need to use absolute paths for all input files in case working dir is changed? +# (can be done with `joinpath(dirname(@__FILE__), <filename>)` ) + """ @param(domainparam) @@ -174,12 +177,11 @@ end """ loadmodelobject(fullfilename) -Serialise a model object and save it to file for later reference. -Includes the current model and Julia versions for compatibility checking. +Deserialise a model object that was previously saved with `[savemodelobject](@ref)`. """ function loadmodelobject(fullfilename::String) object = deserialize(fullfilename) - + # Do basic integrity checks if !(typeof(object) <: Dict && typeof(object["model"]) <: AgentBasedModel) @warn "This file does not contain a model object. Loading failed." return @@ -189,6 +191,8 @@ function loadmodelobject(fullfilename::String) @warn "This model object was saved with a different version of Persefone or Julia. It may be incompatible." end model = object["model"] - model.logger = modellogger(@param(core.loglevel), @param(core.outdir)) #reset logger + # Reset the logger + !isdir(@param(core.outdir)) && mkpath(@param(core.outdir)) + model.logger = modellogger(@param(core.loglevel), @param(core.outdir)) model end -- GitLab