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

Small bug fixes.

This closes #47
parent 1d9779a4
No related branches found
No related tags found
No related merge requests found
...@@ -22,10 +22,11 @@ using ...@@ -22,10 +22,11 @@ using
DataFramesMeta, DataFramesMeta,
Distributed, Distributed,
FileIO, 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, #XXX this is a big dependency - can we get rid of it?
Logging, Logging,
LoggingExtras, LoggingExtras,
CairoMakie, CairoMakie, #XXX this is a very big dependency :-(
Random, Random,
Serialization, Serialization,
StableRNGs, StableRNGs,
...@@ -34,13 +35,11 @@ using ...@@ -34,13 +35,11 @@ using
## Packages that may be useful later on: ## Packages that may be useful later on:
# MacroTools, http://fluxml.ai/MacroTools.jl/stable/utilities/ # MacroTools, http://fluxml.ai/MacroTools.jl/stable/utilities/
# Debugger, https://github.com/JuliaDebug/Debugger.jl # Debugger, https://github.com/JuliaDebug/Debugger.jl
# Makie, https://docs.makie.org/stable/
# PackageCompiler, https://julialang.github.io/PackageCompiler.jl/stable/ # PackageCompiler, https://julialang.github.io/PackageCompiler.jl/stable/
# SpatialEcology, https://github.com/EcoJulia/SpatialEcology.jl # SpatialEcology, https://github.com/EcoJulia/SpatialEcology.jl
# OmniScape, https://circuitscape.org/ # OmniScape, https://circuitscape.org/
# PlantSimEngine, https://virtualplantlab.github.io/PlantSimEngine.jl/stable/ # PlantSimEngine, https://virtualplantlab.github.io/PlantSimEngine.jl/stable/
# Overseer, https://juliapackages.com/p/overseer -> ECS # Overseer, https://juliapackages.com/p/overseer -> ECS
# QML, https://juliapackages.com/p/qml
## define exported functions and variables ## define exported functions and variables
export export
......
...@@ -22,10 +22,11 @@ function visualisemap(model::AgentBasedModel, date::Union{Date,Nothing}=nothing) ...@@ -22,10 +22,11 @@ function visualisemap(model::AgentBasedModel, date::Union{Date,Nothing}=nothing)
image!(f[1,1], rotr90(landcover)) image!(f[1,1], rotr90(landcover))
ax.aspect = DataAspect() ax.aspect = DataAspect()
# plot individuals # 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) 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=10)
end end
f f
......
...@@ -13,6 +13,9 @@ const PARAMFILE = joinpath(pkgdir(Persefone), "src/parameters.toml") ...@@ -13,6 +13,9 @@ const PARAMFILE = joinpath(pkgdir(Persefone), "src/parameters.toml")
## (DO NOT CHANGE THIS VALUE! Instead, specify simulation-specific configuration files ## (DO NOT CHANGE THIS VALUE! Instead, specify simulation-specific configuration files
## by using the "--configfile" commandline argument, or when invoking simulate().) ## 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) @param(domainparam)
...@@ -174,12 +177,11 @@ end ...@@ -174,12 +177,11 @@ end
""" """
loadmodelobject(fullfilename) loadmodelobject(fullfilename)
Serialise a model object and save it to file for later reference. Deserialise a model object that was previously saved with `[savemodelobject](@ref)`.
Includes the current model and Julia versions for compatibility checking.
""" """
function loadmodelobject(fullfilename::String) function loadmodelobject(fullfilename::String)
object = deserialize(fullfilename) object = deserialize(fullfilename)
# Do basic integrity checks
if !(typeof(object) <: Dict && typeof(object["model"]) <: AgentBasedModel) if !(typeof(object) <: Dict && typeof(object["model"]) <: AgentBasedModel)
@warn "This file does not contain a model object. Loading failed." @warn "This file does not contain a model object. Loading failed."
return return
...@@ -189,6 +191,8 @@ function loadmodelobject(fullfilename::String) ...@@ -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." @warn "This model object was saved with a different version of Persefone or Julia. It may be incompatible."
end end
model = object["model"] 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 model
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment