From af0de58901ef998412dc13ca40c80ca0a5b96ac0 Mon Sep 17 00:00:00 2001
From: Daniel Vedder <daniel.vedder@idiv.de>
Date: Wed, 4 Sep 2024 10:17:30 +0200
Subject: [PATCH] Got PersefoneDesktop working with the newest version of
Persefone
---
desktop.jl | 0
guiparams.toml | 22 ++++++++++++----------
src/GUI.jl | 12 ++++++------
src/PersefoneDesktop.jl | 3 +--
src/logic.jl | 2 +-
src/main.qml | 8 ++++----
src/variables.jl | 9 ++++-----
7 files changed, 28 insertions(+), 28 deletions(-)
mode change 100755 => 100644 desktop.jl
diff --git a/desktop.jl b/desktop.jl
old mode 100755
new mode 100644
diff --git a/guiparams.toml b/guiparams.toml
index b3ba1e8..4eb653b 100644
--- a/guiparams.toml
+++ b/guiparams.toml
@@ -10,31 +10,33 @@
configfile = "guiparams.toml" # location of the configuration file
outdir = "desktop_results" # location and name of the output folder
overwrite = true # overwrite the output directory? (true/false/"ask")
+logoutput = "both" # log output to screen/file/none/both
csvoutput = false # save collected data in CSV files
visualise = false # generate result graphs
storedata = true # keep collected data in memory
-loglevel = "debug" # verbosity level: "debug", "info", "warn"
+loglevel = "info" # 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)
# dates to start and end the simulation
-startdate = 2022-01-01
-enddate = 2022-12-31
+startdate = 2021-01-01
+enddate = 2023-12-31
[world]
-#TODO point to files in the main data directory? (avoid file duplication)
-landcovermap = "data/regions/jena-small/landcover.tif" # location of the landcover map
-farmfieldsmap = "data/regions/jena-small/fields.tif" # location of the field geometry map
-weatherfile = "data/regions/jena-small/weather.csv" # location of the weather data file
+mapdirectory = "data/regions/jena-small" # the directory in which all geographic data are stored
+mapresolution = 10 # map resolution in meters
+landcovermap = "landcover.tif" # name of the landcover map in the map directory
+farmfieldsmap = "fields.tif" # name of the field geometry map in the map directory
+weatherfile = "weather.csv" # name of the weather data file in the map directory
[farm]
-farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented)
+farmmodel = "BasicFarmer" # which version of the farm model to use
+setaside = 0.04 # proportion of farm area set aside as fallow
+fieldoutfreq = "daily" # output frequency for crop/field data, daily/monthly/yearly/end/never
[nature]
-#targetspecies = ["Wolpertinger", "Wyvern"] # list of target species to simulate
targetspecies = ["Skylark"] # species to be simulated
popoutfreq = "daily" # output frequency population-level data, daily/monthly/yearly/end/never
indoutfreq = "daily" # output frequency individual-level data, daily/monthly/yearly/end/never
-insectmodel = ["season", "habitat", "pesticides", "weather"] # factors affecting insect growth
[crop]
cropmodel = "almass" # crop growth model to use, "almass" or "aquacrop"
diff --git a/src/GUI.jl b/src/GUI.jl
index cf461a4..a136a1d 100644
--- a/src/GUI.jl
+++ b/src/GUI.jl
@@ -58,14 +58,14 @@ function render_map(screen)
launching[] && return display(screen, Figure().scene) # blank screen at launch
println("Updating map")
if isnothing(mapimage)
- landcover = rotr90(load(@param(world.landcovermap)))
+ landcover = rotr90(load(joinpath(@param(world.mapdirectory), @param(world.landcovermap))))
mapimage = Figure()
ax = Axis(mapimage[1,1])
hidedecorations!(ax)
image!(mapimage[1,1], landcover)
ax.aspect = DataAspect()
- inds = @lift(@transform!(@subset(model.datatables["individuals"],
- :Date .== $date-Day(1)),
+ inds = @lift(@transform!(@subset(@data("individuals"),
+ :X .!= -1, :Date .== $date-Day(1)),
:Y = size(landcover)[2] .- :Y))
ncolors = max(2, length(@param(nature.targetspecies)))
update_theme!(palette=(color=cgrad(:seaborn_bright, ncolors),),
@@ -86,7 +86,7 @@ function render_plot(screen)
if isnothing(plotimage)
pops = @lift begin
$date #needed to activate the lift, doesn't do anything
- model.datatables["populations"]
+ @data("populations")
end
#XXX other colour schemes: :tab10, :Accent_8, :Dark2_8, :Paired_12, :Set1_9
# https://juliagraphics.github.io/ColorSchemes.jl/stable/catalogue/
@@ -135,13 +135,13 @@ end
datestring = () -> Dates.format(date[], "dd U yyyy")
function activateqmlfunctions()
- @qmlfunction configwindow
+ #@qmlfunction configwindow
@qmlfunction loadsimulation
@qmlfunction savesimulation
@qmlfunction nextstep
@qmlfunction previousstep
@qmlfunction datestring
- @qmlfunction writeconfig
+ #@qmlfunction writeconfig
@qmlfunction saveoutput
end
diff --git a/src/PersefoneDesktop.jl b/src/PersefoneDesktop.jl
index bbcfa13..b9acdff 100644
--- a/src/PersefoneDesktop.jl
+++ b/src/PersefoneDesktop.jl
@@ -18,7 +18,6 @@ using
TOML,
Dates,
Makie,
- Agents,
FileIO,
CxxWrap,
GLMakie,
@@ -31,7 +30,7 @@ using
include("variables.jl")
include("logic.jl")
-include("config.jl")
+#include("config.jl") # ignore config for now
include("GUI.jl")
precompile(launch, ())
diff --git a/src/logic.jl b/src/logic.jl
index 3e9ef54..b8795ec 100644
--- a/src/logic.jl
+++ b/src/logic.jl
@@ -13,7 +13,7 @@
model.date -= Day(1)
Persefone.outputdata(model, true) # record data before run starts
model.date += Day(1)
- landcovermap = rotr90(load(@param(world.landcovermap)))
+ landcovermap = rotr90(load(joinpath(@param(world.mapdirectory), @param(world.landcovermap))))
date[] = model.date
launching[] = false
end
diff --git a/src/main.qml b/src/main.qml
index 6ce7279..8ebfc9e 100644
--- a/src/main.qml
+++ b/src/main.qml
@@ -24,10 +24,10 @@ ApplicationWindow {
text: "&New Simulation"
onTriggered: { vars.launching = true } //TODO select config file
}
- Action {
- text: "&Configure Simulation"
- onTriggered: { Julia.configwindow() }
- }
+ /* Action { */
+ /* text: "&Configure Simulation" */
+ /* onTriggered: { Julia.configwindow() } */
+ /* } */
Action {
text: "&Load Saved State"
onTriggered: { loadFileChooser.open() }
diff --git a/src/variables.jl b/src/variables.jl
index af18c91..6c20057 100644
--- a/src/variables.jl
+++ b/src/variables.jl
@@ -26,7 +26,7 @@ const runbuttontip = Observable("Run")
## configuration parameters
-const userconfigfile = Observable("userconfig.toml")
+const userconfigfile = Observable("userconfig.toml") #XXX not yet needed
const outdir = Observable("persefone_output")
const csvoutput = Observable(false)
const loglevel = Observable("warn")
@@ -34,15 +34,14 @@ const processors = Observable(1)
const seed = Observable(2)
const startdateday = Observable(1)
const startdatemonth = Observable(1)
-const startdateyear = Observable(2022)
+const startdateyear = Observable(2021)
const enddateday = Observable(31)
const enddatemonth = Observable(12)
const enddateyear = Observable(2022)
-const region = Observable("Jena") #XXX alternatives not yet implemented
-#const farmmodel = Observable("FieldManager") #XXX not yet implemented
+const region = Observable("Jena")
+const farmmodel = Observable("BasicFarmer")
const species = Observable("Skylark")
#const targetspecies = Observable() #TODO not sure how to configure a list?
-#const insectmodel = Observable() #TODO not sure how to configure a list?
const cropmodel = Observable("ALMaSS") #XXX alternatives not yet implemented
--
GitLab