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

Wrote `setting()` function

parent 61d605c7
No related branches found
No related tags found
No related merge requests found
### Persephone - a socio-economic-ecological model of European agricultural landscapes.
###
### This is an example configuration file for development.
### Note: the reference version is at src/parameters.toml
###
[core]
configfile = "data/config.toml" # location of the configuration file
mapfile = "data/region_hohenlohe.tif" # location of the map file
outdir = "results" # location and name of the output folder
logfile = "simulation.log" # name of the log file
loglevel = "debug" # verbosity level: "debug", "normal", "errors"
quietmode = false # if true, only print log statements to file, not the screen
runtime = 5 # duration in days that the simulation will run for
seed = 0 # seed value for the RNG (0 -> random value)
[farm]
[ecology]
[crop]
cropmodel = "linear" # crop growth model to use, "linear" or "aquacrop" (not yet implemented)
......@@ -4,7 +4,7 @@
### Lea Kolb <lea-deborah.kolb@idiv.de>
### (c) 2022, licensed under the terms of the MIT license
###
### This file defines the module (= "library") for the Persephone model.
### This file defines the module/package for the Persephone model.
### To run the model, either execute `run.jl` from the commandline,
### or import the module using your own wrapper script or software.
###
......@@ -24,7 +24,8 @@ using
export
simulate,
initsim,
runsim
stepsim,
finalisesim
## The file that stores all default parameters
const paramfile = "src/parameters.toml"
......
......@@ -6,6 +6,27 @@
## Note: some of this code was adapted from the GeMM model
## (https://github.com/CCTB-Ecomods/gemm/blob/master/src/input.jl)
let settings::Dict{String, Dict{String, Any}}
"""
initsettings(configfile)
Initialise the global model settings for this run.
"""
global function initsettings(configfile::String)
settings = getsettings(configfile)
end
"""
setting(domain, param)
Return a configuration parameter from the global settings.
Domain may be any of "core", "ecology", "farm", or "crop".
"""
global function setting(domain::String, param::String)
settings[domain][param]
end
end
"""
getsettings(configfile)
......@@ -91,3 +112,11 @@ function parsecommandline()
args
end
"""
readtiffmapfile(filename)
Read in a TIFF map file and return it as an array.
"""
function readtiffmapfile(filename)
#TODO
end
......@@ -4,19 +4,27 @@
###
function initsim(config::String)
settings = getsettings(config)
TOML.print(settings)
Random.seed!(settings["core"]["seed"])
initsettings(config)
Random.seed!(setting("core", "seed"))
#TODO create output folder
#TODO create world
end
function stepsim()
println("Simulating another day.")
#TODO
end
function runsim()
function finalisesim()
println("Simulation ran. Nothing happened. But it will!")
#TODO
end
function simulate(config::String=paramfile)
initsim(config)
runsim()
println("Simulation ran. Nothing happened. But it will!")
for day in 1:setting("core", "runtime")
stepsim()
end
finalisesim()
#TODO
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment