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

Created `[world]` settings section

parent 71800e6b
Branches
Tags
No related merge requests found
...@@ -74,7 +74,9 @@ export ...@@ -74,7 +74,9 @@ export
## b references something from file a, it must be included later) ## b references something from file a, it must be included later)
include("core/input.jl") include("core/input.jl")
include("core/output.jl") include("core/output.jl")
include("core/landscape.jl")
include("world/landscape.jl")
include("world/weather.jl")
include("farm/farm.jl") include("farm/farm.jl")
include("crop/crops.jl") include("crop/crops.jl")
......
...@@ -143,7 +143,7 @@ function parsecommandline() ...@@ -143,7 +143,7 @@ function parsecommandline()
versionstring = """ versionstring = """
Persefone $(pkgversion(Persefone)) Persefone $(pkgversion(Persefone))
© 2022-2023 Daniel Vedder, Lea Kolb (MIT license) © 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) s = ArgParseSettings(add_version=true, version=versionstring)
@add_arg_table! s begin @add_arg_table! s begin
......
...@@ -88,8 +88,8 @@ function saveinputfiles(model::AgentBasedModel) ...@@ -88,8 +88,8 @@ function saveinputfiles(model::AgentBasedModel)
TOML.print(f, prepareTOML(model.settings)) TOML.print(f, prepareTOML(model.settings))
end end
# Copy the map files to the output folder # Copy the map files to the output folder
lcmap = @param(core.landcovermap) lcmap = @param(world.landcovermap)
ffmap = @param(core.farmfieldsmap) ffmap = @param(world.farmfieldsmap)
#TODO replace errors with exceptions #TODO replace errors with exceptions
!(isfile(lcmap)) && Base.error("The map file $(lcmap) doesn't exist.") !(isfile(lcmap)) && Base.error("The map file $(lcmap) doesn't exist.")
!(isfile(ffmap)) && Base.error("The map file $(ffmap) doesn't exist.") !(isfile(ffmap)) && Base.error("The map file $(ffmap) doesn't exist.")
......
...@@ -64,7 +64,7 @@ function initmodel(settings::Dict{String, Any}) ...@@ -64,7 +64,7 @@ function initmodel(settings::Dict{String, Any})
with_logger(logger) do with_logger(logger) do
events = Vector{FarmEvent}() events = Vector{FarmEvent}()
dataoutputs = Vector{DataOutput}() 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) space = GridSpace(size(landscape), periodic=false)
properties = Dict{Symbol,Any}(:settings=>settings, properties = Dict{Symbol,Any}(:settings=>settings,
:logger=>logger, :logger=>logger,
......
...@@ -8,8 +8,6 @@ ...@@ -8,8 +8,6 @@
[core] [core]
configfile = "src/parameters.toml" # location of the configuration file 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 outdir = "results" # location and name of the output folder
overwrite = "ask" # overwrite the output directory? (true/false/"ask") overwrite = "ask" # overwrite the output directory? (true/false/"ask")
loglevel = "debug" # verbosity level: "debug", "info", "warn" loglevel = "debug" # verbosity level: "debug", "info", "warn"
...@@ -20,6 +18,10 @@ startdate = 2022-01-01 ...@@ -20,6 +18,10 @@ startdate = 2022-01-01
#enddate = 2022-03-31 #enddate = 2022-03-31
enddate = 2022-12-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] [farm]
farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented) farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented)
......
...@@ -27,8 +27,8 @@ end ...@@ -27,8 +27,8 @@ end
@test_logs((:debug, "Setting up output directory results_testsuite."), @test_logs((:debug, "Setting up output directory results_testsuite."),
min_level=Logging.Debug, match_mode=:any, min_level=Logging.Debug, match_mode=:any,
Ps.saveinputfiles(model)) Ps.saveinputfiles(model))
@test isfile(joinpath(outdir, @param(core.landcovermap))) @test isfile(joinpath(outdir, @param(world.landcovermap)))
@test isfile(joinpath(outdir, @param(core.farmfieldsmap))) @test isfile(joinpath(outdir, @param(world.farmfieldsmap)))
@test isfile(joinpath(outdir, @param(core.configfile))) @test isfile(joinpath(outdir, @param(core.configfile)))
@test isfile(joinpath(outdir, Ps.LOGFILE)) @test isfile(joinpath(outdir, Ps.LOGFILE))
# check whether the overwrite warning/protection works # check whether the overwrite warning/protection works
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
@testset "Landscape initialisation" begin @testset "Landscape initialisation" begin
# initialise the landscape part of the model # initialise the landscape part of the model
landscape = Ps.initlandscape(TESTSETTINGS["core.landcovermap"], landscape = Ps.initlandscape(TESTSETTINGS["world.landcovermap"],
TESTSETTINGS["core.farmfieldsmap"]) TESTSETTINGS["world.farmfieldsmap"])
space = GridSpace(size(landscape), periodic=false) space = GridSpace(size(landscape), periodic=false)
properties = Dict{Symbol,Any}(:landscape=>landscape, :settings=>TESTSETTINGS) properties = Dict{Symbol,Any}(:landscape=>landscape, :settings=>TESTSETTINGS)
model = AgentBasedModel(FarmPlot, space, properties=properties, warn=false) model = AgentBasedModel(FarmPlot, space, properties=properties, warn=false)
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
[core] [core]
configfile = "test/paramscan.toml" # location of the configuration file 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 outdir = "results_test_paramscan" # location and name of the output folder
overwrite = ["ask",true] # overwrite the output directory? (true/false/"ask") overwrite = ["ask",true] # overwrite the output directory? (true/false/"ask")
loglevel = ["warn", "info"] # verbosity level: "debug", "info", "warn" loglevel = ["warn", "info"] # verbosity level: "debug", "info", "warn"
...@@ -17,6 +15,10 @@ seed = [1,2,3] # seed value for the RNG (0 -> random value) ...@@ -17,6 +15,10 @@ seed = [1,2,3] # seed value for the RNG (0 -> random value)
startdate = 2022-01-01 startdate = 2022-01-01
enddate = 2022-01-02 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] [farm]
farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented) farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented)
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
[core] [core]
configfile = "test_parameters.toml" # location of the configuration file 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 outdir = "results_testsuite" # location and name of the output folder
overwrite = true # overwrite the output directory? (true/false/"ask") overwrite = true # overwrite the output directory? (true/false/"ask")
loglevel = "warn" # verbosity level: "debug", "info", "warn" loglevel = "warn" # verbosity level: "debug", "info", "warn"
...@@ -18,6 +16,10 @@ seed = 1 # seed value for the RNG (0 -> random value) ...@@ -18,6 +16,10 @@ seed = 1 # seed value for the RNG (0 -> random value)
startdate = 2022-02-01 startdate = 2022-02-01
enddate = 2022-03-31 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] [farm]
farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented) farmmodel = "FieldManager" # which version of the farm model to use (not yet implemented)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment