Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Persefone.jl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
31c8338b
Commit
31c8338b
authored
2 years ago
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
Wrote `setting()` function
parent
61d605c7
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
data/config.toml
+24
-0
24 additions, 0 deletions
data/config.toml
src/Persephone.jl
+3
-2
3 additions, 2 deletions
src/Persephone.jl
src/core/input.jl
+29
-0
29 additions, 0 deletions
src/core/input.jl
src/core/simulation.jl
+14
-6
14 additions, 6 deletions
src/core/simulation.jl
with
70 additions
and
8 deletions
data/config.toml
0 → 100644
+
24
−
0
View file @
31c8338b
### 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)
This diff is collapsed.
Click to expand it.
src/Persephone.jl
+
3
−
2
View file @
31c8338b
...
...
@@ -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"
...
...
This diff is collapsed.
Click to expand it.
src/core/input.jl
+
29
−
0
View file @
31c8338b
...
...
@@ -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
This diff is collapsed.
Click to expand it.
src/core/simulation.jl
+
14
−
6
View file @
31c8338b
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment