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

Made graphics output format configurable

parent faed2eae
Branches
No related tags found
No related merge requests found
name = "Persefone"
uuid = "039acd1d-2a07-4b33-b082-83a1ff0fd136"
authors = ["Daniel Vedder <daniel.vedder@idiv.de>"]
version = "0.4.0"
version = "0.4.1"
[deps]
Agents = "46ada45e-f475-11e8-01d0-f70cc89e6671"
......
......@@ -30,9 +30,8 @@ function visualisemap(model::AgentBasedModel,date=nothing,landcover=nothing)
isnothing(date) && (date = inds.Date[end])
#XXX other colour schemes: :tab10, :Accent_8, :Dark2_8, :Paired_12, :Set1_9
# https://juliagraphics.github.io/ColorSchemes.jl/stable/catalogue/
update_theme!(palette=(color=cgrad(:seaborn_bright,
max(2, length(@param(nature.targetspecies)))),),
cycle=[:color])
ncolors = max(2, length(@param(nature.targetspecies)))
update_theme!(palette=(color=cgrad(:seaborn_bright, ncolors),), cycle=[:color])
for s in @param(nature.targetspecies)
points = @select!(@subset(inds, :Species .== s, :Date .== date),
:X, :Y)
......@@ -53,9 +52,8 @@ Returns a Makie figure object.
"""
function populationtrends(model::AgentBasedModel)
pops = model.datatables["populations"]
update_theme!(palette=(color=cgrad(:seaborn_bright,
max(2, length(@param(nature.targetspecies)))),),
cycle=[:color])
ncolors = max(2, length(@param(nature.targetspecies)))
update_theme!(palette=(color=cgrad(:seaborn_bright, ncolors),), cycle=[:color])
f = Figure()
dates = @param(core.startdate):@param(core.enddate)
ax = Axis(f[1,1], xlabel="Date", ylabel="Population size",
......
......@@ -213,15 +213,16 @@ end
visualiseoutput(model)
Cycle through all data outputs and call their respective plot functions,
saving each figure as a PDF.
saving each figure to file.
"""
function visualiseoutput(model::AgentBasedModel, format::String="pdf")
function visualiseoutput(model::AgentBasedModel)
@debug "Visualising output."
CairoMakie.activate!() # make sure we're using Cairo
for output in model.dataoutputs
isnothing(output.plotfunction) && continue
figure = output.plotfunction(model)
save(joinpath(@param(core.outdir), output.name*"."*format), figure)
save(joinpath(@param(core.outdir), output.name*"."*@param(core.figureformat)),
figure)
end
end
......
......@@ -114,7 +114,7 @@ At the moment, this implementation is still in development.
m, d = monthday(model.date)
migrate = (((m < arrive[1]) || (m == arrive[1] && d < arrive[2])) ||
((m > leave[1]) || (m == leave[1] && d >= leave[2])))
if migrate
if migrate #FIXME not all migrate?
@kill(@trait(migrationmortality), "migration")
returndate = Date(year(model.date), arrive[1], arrive[2])
model.date != @param(core.startdate) && (returndate += Year(1))
......
......@@ -13,6 +13,7 @@ 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
figureformat = "pdf" # file format to use for graphical output
loglevel = "debug" # verbosity level: "debug", "info", "warn"
processors = 2 # number of processors to use on parallel runs
seed = 2 # seed value for the RNG (0 -> random value)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment