From f6e8b02624c56bc3128c15de2b870ea4a92c686f Mon Sep 17 00:00:00 2001
From: Daniel Vedder <daniel.vedder@idiv.de>
Date: Mon, 29 May 2023 00:19:02 +0200
Subject: [PATCH] Created `[world]` settings section

---
 src/Persefone.jl          | 4 +++-
 src/core/input.jl         | 2 +-
 src/core/output.jl        | 4 ++--
 src/core/simulation.jl    | 2 +-
 src/parameters.toml       | 6 ++++--
 test/io_tests.jl          | 4 ++--
 test/landscape_tests.jl   | 4 ++--
 test/paramscan.toml       | 6 ++++--
 test/test_parameters.toml | 6 ++++--
 9 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/src/Persefone.jl b/src/Persefone.jl
index c249054..65c3b29 100644
--- a/src/Persefone.jl
+++ b/src/Persefone.jl
@@ -74,7 +74,9 @@ export
 ## b references something from file a, it must be included later)
 include("core/input.jl")
 include("core/output.jl")
-include("core/landscape.jl")
+
+include("world/landscape.jl")
+include("world/weather.jl")
 
 include("farm/farm.jl")
 include("crop/crops.jl")
diff --git a/src/core/input.jl b/src/core/input.jl
index f34ff04..b08dc61 100644
--- a/src/core/input.jl
+++ b/src/core/input.jl
@@ -143,7 +143,7 @@ function parsecommandline()
     versionstring = """
             Persefone $(pkgversion(Persefone))
             © 2022-2023 Daniel Vedder, Lea Kolb (MIT license)
-            https://git.idiv.de/xo30xoqa/persephone
+            https://git.idiv.de/xo30xoqa/persefone
             """
     s = ArgParseSettings(add_version=true, version=versionstring)
     @add_arg_table! s begin
diff --git a/src/core/output.jl b/src/core/output.jl
index 74b5b47..9dea302 100644
--- a/src/core/output.jl
+++ b/src/core/output.jl
@@ -88,8 +88,8 @@ function saveinputfiles(model::AgentBasedModel)
         TOML.print(f, prepareTOML(model.settings))
     end
     # Copy the map files to the output folder
-    lcmap = @param(core.landcovermap)
-    ffmap = @param(core.farmfieldsmap)
+    lcmap = @param(world.landcovermap)
+    ffmap = @param(world.farmfieldsmap)
     #TODO replace errors with exceptions
     !(isfile(lcmap)) && Base.error("The map file $(lcmap) doesn't exist.")
     !(isfile(ffmap)) && Base.error("The map file $(ffmap) doesn't exist.")
diff --git a/src/core/simulation.jl b/src/core/simulation.jl
index 3ee9f0e..18c0dd0 100644
--- a/src/core/simulation.jl
+++ b/src/core/simulation.jl
@@ -64,7 +64,7 @@ function initmodel(settings::Dict{String, Any})
     with_logger(logger) do
         events = Vector{FarmEvent}()
         dataoutputs = Vector{DataOutput}()
-        landscape = initlandscape(settings["core.landcovermap"], settings["core.farmfieldsmap"])
+        landscape = initlandscape(settings["world.landcovermap"], settings["world.farmfieldsmap"])
         space = GridSpace(size(landscape), periodic=false)
         properties = Dict{Symbol,Any}(:settings=>settings,
                                       :logger=>logger,
diff --git a/src/parameters.toml b/src/parameters.toml
index d1e3db2..4e888a4 100644
--- a/src/parameters.toml
+++ b/src/parameters.toml
@@ -8,8 +8,6 @@
 
 [core]
 configfile = "src/parameters.toml" # location of the configuration file
-landcovermap = "data/landcover_jena.tif" # location of the landcover map
-farmfieldsmap = "data/fields_jena.tif" # location of the field geometry map
 outdir = "results" # location and name of the output folder
 overwrite = "ask" # overwrite the output directory? (true/false/"ask")
 loglevel = "debug" # verbosity level: "debug", "info", "warn"
@@ -20,6 +18,10 @@ startdate = 2022-01-01
 #enddate = 2022-03-31
 enddate = 2022-12-31
 
+[world]
+landcovermap = "data/landcover_jena.tif" # location of the landcover map
+farmfieldsmap = "data/fields_jena.tif" # location of the field geometry map
+	
 [farm]
 farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented)
 
diff --git a/test/io_tests.jl b/test/io_tests.jl
index fb8c17d..66c1718 100644
--- a/test/io_tests.jl
+++ b/test/io_tests.jl
@@ -27,8 +27,8 @@ end
     @test_logs((:debug, "Setting up output directory results_testsuite."),
                min_level=Logging.Debug, match_mode=:any,
                Ps.saveinputfiles(model))
-    @test isfile(joinpath(outdir, @param(core.landcovermap)))
-    @test isfile(joinpath(outdir, @param(core.farmfieldsmap)))
+    @test isfile(joinpath(outdir, @param(world.landcovermap)))
+    @test isfile(joinpath(outdir, @param(world.farmfieldsmap)))
     @test isfile(joinpath(outdir, @param(core.configfile)))
     @test isfile(joinpath(outdir, Ps.LOGFILE))
     # check whether the overwrite warning/protection works
diff --git a/test/landscape_tests.jl b/test/landscape_tests.jl
index fb97af0..2f4ceeb 100644
--- a/test/landscape_tests.jl
+++ b/test/landscape_tests.jl
@@ -5,8 +5,8 @@
 
 @testset "Landscape initialisation" begin
     # initialise the landscape part of the model
-    landscape = Ps.initlandscape(TESTSETTINGS["core.landcovermap"],
-                                 TESTSETTINGS["core.farmfieldsmap"])
+    landscape = Ps.initlandscape(TESTSETTINGS["world.landcovermap"],
+                                 TESTSETTINGS["world.farmfieldsmap"])
     space = GridSpace(size(landscape), periodic=false)
     properties = Dict{Symbol,Any}(:landscape=>landscape, :settings=>TESTSETTINGS)
     model = AgentBasedModel(FarmPlot, space, properties=properties, warn=false)
diff --git a/test/paramscan.toml b/test/paramscan.toml
index 045ed41..a5c08c4 100644
--- a/test/paramscan.toml
+++ b/test/paramscan.toml
@@ -7,8 +7,6 @@
 	
 [core]
 configfile = "test/paramscan.toml" # location of the configuration file
-landcovermap = "landcover_jena.tif" # location of the landcover map
-farmfieldsmap = "fields_jena.tif" # location of the field geometry map
 outdir = "results_test_paramscan" # location and name of the output folder
 overwrite = ["ask",true] # overwrite the output directory? (true/false/"ask")
 loglevel = ["warn", "info"] # verbosity level: "debug", "info", "warn"
@@ -17,6 +15,10 @@ seed = [1,2,3] # seed value for the RNG (0 -> random value)
 startdate = 2022-01-01
 enddate = 2022-01-02
 
+[world]
+landcovermap = "landcover_jena.tif" # location of the landcover map
+farmfieldsmap = "fields_jena.tif" # location of the field geometry map
+
 [farm]
 farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented)
 
diff --git a/test/test_parameters.toml b/test/test_parameters.toml
index 2b2dfbe..f4cc679 100644
--- a/test/test_parameters.toml
+++ b/test/test_parameters.toml
@@ -7,8 +7,6 @@
 	
 [core]
 configfile = "test_parameters.toml" # location of the configuration file
-landcovermap = "landcover_jena.tif" # location of the landcover map
-farmfieldsmap = "fields_jena.tif" # location of the field geometry map
 outdir = "results_testsuite" # location and name of the output folder
 overwrite = true # overwrite the output directory? (true/false/"ask")
 loglevel = "warn" # verbosity level: "debug", "info", "warn"
@@ -18,6 +16,10 @@ seed = 1 # seed value for the RNG (0 -> random value)
 startdate = 2022-02-01
 enddate = 2022-03-31
 
+[world]
+landcovermap = "landcover_jena.tif" # location of the landcover map
+farmfieldsmap = "fields_jena.tif" # location of the field geometry map
+
 [farm]
 farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented)
 
-- 
GitLab