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

Added tests for visualisation, changed colour scheme

parent 9bd0f267
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@ run:
# run an example simulation
if [ -d "example_results" ]; then rm -r example_results; fi
./run.jl -o example_results
src/analysis/analyse_nature.R example_results
#src/analysis/analyse_nature.R example_results
test:
# running test suite
......
name = "Persefone"
uuid = "039acd1d-2a07-4b33-b082-83a1ff0fd136"
authors = ["Daniel Vedder <daniel.vedder@idiv.de>"]
version = "0.3.4"
version = "0.3.5"
[deps]
Agents = "46ada45e-f475-11e8-01d0-f70cc89e6671"
......
......@@ -28,6 +28,8 @@ function visualisemap(model::AgentBasedModel,date=nothing,landcover=nothing)
return f
end
isnothing(date) && (date = inds.Date[end])
update_theme!(palette=(color=cgrad(:seaborn_bright, length(unique(inds.Species))),),
cycle=[:color])
for s in unique(inds.Species)
points = @select!(@subset(inds, :Species .== s, :Date .== date),
:X, :Y)
......@@ -60,7 +62,8 @@ function populationtrends(model::AgentBasedModel)
deleteat!(ticks[1], 2:2:length(ticks[1]))
deleteat!(ticks[2], 2:2:length(ticks[2]))
end
update_theme!(palette=(color=cgrad(:seaborn_bright, length(unique(pops.Species))),),
cycle=[:color])
f = Figure()
ax = Axis(f[1,1], xlabel="Date", ylabel="Population size",
limits=((1, length(dates)), nothing), xticks = ticks)
......
......@@ -215,13 +215,13 @@ end
Cycle through all data outputs and call their respective plot functions,
saving each figure as a PDF.
"""
function visualiseoutput(model::AgentBasedModel)
#TODO write tests
function visualiseoutput(model::AgentBasedModel, format::String="pdf")
@debug "Visualising output."
CairoMakie.activate!()
for output in model.dataoutputs
isnothing(output.plotfunction) && continue
figure = output.plotfunction(model)
save(joinpath(@param(core.outdir), output.name*".pdf"), figure)
save(joinpath(@param(core.outdir), output.name*"."*format), figure)
end
end
......
......@@ -3,10 +3,6 @@
### This file includes the functions for collecting and saving ecological output data.
###
#XXX NOP functions while I try and get Makie to work
visualisemap(model) = nothing
populationtrends(model) = nothing
"""
initecologicaldata()
......
......@@ -66,7 +66,7 @@ end
@testset "Model object serialization" begin
model = inittestmodel()
Ps.createdatadir(@param(core.outdir), @param(core.overwrite))
Ps.createdatadir(@param(core.outdir), true)
@test_logs((:debug, "Saved model object to results_testsuite/test.dat."),
min_level=Logging.Debug, match_mode=:any,
savemodelobject(model, "test"))
......@@ -81,3 +81,14 @@ end
@test length(model.agents) == length(model2.agents)
rm(@param(core.outdir), force=true, recursive=true)
end
@testset "Output visualisation" begin
model = initialise(TESTPARAMETERS)
stepsimulation!(model)
@test_logs((:debug, "Visualising output."),
min_level=Logging.Debug, match_mode=:any,
visualiseoutput(model))
@test isfile(joinpath(@param(core.outdir), "individuals.pdf"))
@test isfile(joinpath(@param(core.outdir), "populations.pdf"))
rm(@param(core.outdir), force=true, recursive=true)
end
......@@ -10,6 +10,7 @@ configfile = "test_parameters.toml" # location of the configuration file
outdir = "results_testsuite" # location and name of the output folder
overwrite = true # 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 = "warn" # verbosity level: "debug", "info", "warn"
processors = 6 # number of processors to use on parallel runs
......@@ -29,7 +30,7 @@ farmmodel = "FieldManager" # which version of the farm model to use (not yet imp
[nature]
targetspecies = ["Wolpertinger", "Wyvern"] # list of target species to simulate
popoutfreq = "daily" # output frequency population-level data, daily/monthly/yearly/end/never
indoutfreq = "end" # output frequency individual-level data, daily/monthly/yearly/end/never
indoutfreq = "daily" # output frequency individual-level data, daily/monthly/yearly/end/never
insectmodel = ["season", "habitat", "pesticides"] # which factors affect insect growth ("weather" is not yet implemented)
[crop]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment