The format of the configuration file is expected to contain 6 space-separated columns representing, in order:
- site_name
Name of simulated site. This is used, for example, when an output file is created.
- run_name
Name of this simulation run. Used to differentiate between different runs at the same site. Can be
-
to indicate no particular name, in which case nothing will be appended in the resulting output file.- year(s)
Specification of years to be simulated. Either a single number or a sequence in R's
:
notation, i.e.2013:2022
to indicate all years from 2013 to (including) 2022.- param_file
Filename (not full path) of parameter file to use. The file is assumed to be located in input_dir (confer documentation for that parameter).
- weather_file
Filename (not full path) of weather file. See also param_file.
- management_file
Filename (not full path) of management file. See also param_file. Can be set to
high
,middle
,low
or-
if no management data is to be used and the autocut routine shall be employed to simulate cutting events.
Rows starting with a #
are skipped.
Value
A list of ModvegeEnvironment instances corresponding to the configurations in the order they appear in config_file.
Examples
# First, we set up the expected directory structure in a temporary place
tmp = file.path(tempdir(), "test-read_config")
dir.create(tmp)
# We need `force = TRUE` here in order to make the example work in
# non-interactive settings.
setup_directory(root = tmp, include_examples = TRUE, force = TRUE)
#> [INFO]Initialized directory structure in `/tmp/RtmpxPgtzx/test-read_config`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/posieux_weather.txt` to `/tmp/RtmpxPgtzx/test-read_config/input/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/posieux_parameters.csv` to `/tmp/RtmpxPgtzx/test-read_config/input/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/posieux_management1.txt` to `/tmp/RtmpxPgtzx/test-read_config/input/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/posieux_management2.txt` to `/tmp/RtmpxPgtzx/test-read_config/input/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/sorens_weather.txt` to `/tmp/RtmpxPgtzx/test-read_config/input/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/sorens_parameters.csv` to `/tmp/RtmpxPgtzx/test-read_config/input/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/sorens_management1.txt` to `/tmp/RtmpxPgtzx/test-read_config/input/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/sorens_management2.txt` to `/tmp/RtmpxPgtzx/test-read_config/input/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/posieux1.csv` to `/tmp/RtmpxPgtzx/test-read_config/data/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/posieux2.csv` to `/tmp/RtmpxPgtzx/test-read_config/data/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/sorens1.csv` to `/tmp/RtmpxPgtzx/test-read_config/data/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/sorens2.csv` to `/tmp/RtmpxPgtzx/test-read_config/data/`.
#> [INFO]Copying `/home/runner/work/_temp/Library/growR/extdata/example_config.txt` to `/tmp/RtmpxPgtzx/test-read_config`.
#> [INFO]Copied example files to respective directories.
# Now we can test `read_config`.
read_config(file.path(tmp, "example_config.txt"),
input_dir = file.path(tmp, "input"))
#> [[1]]
#> <ModvegeEnvironment>
#> Public:
#> clone: function (deep = FALSE)
#> get_environment_for_year: function (year)
#> initialize: function (site_name, run_name = "-", years = NULL, param_file = "-",
#> input_dir: /tmp/RtmpxPgtzx/test-read_config/input
#> load_inputs: function ()
#> make_filename_for_run: function (run_name)
#> management: ManagementData, R6
#> management_file: sorens_management1.txt
#> param_file: sorens_parameters.csv
#> parameters: ModvegeParameters, R6
#> run_name: -
#> run_name_in_filename:
#> set_run_name: function (run_name)
#> site_name: sorens1
#> weather: WeatherData, R6
#> weather_file: sorens_weather.txt
#> years: 2013 2014 2015
#>
#> [[2]]
#> <ModvegeEnvironment>
#> Public:
#> clone: function (deep = FALSE)
#> get_environment_for_year: function (year)
#> initialize: function (site_name, run_name = "-", years = NULL, param_file = "-",
#> input_dir: /tmp/RtmpxPgtzx/test-read_config/input
#> load_inputs: function ()
#> make_filename_for_run: function (run_name)
#> management: ManagementData, R6
#> management_file: posieux_management1.txt
#> param_file: posieux_parameters.csv
#> parameters: ModvegeParameters, R6
#> run_name: -
#> run_name_in_filename:
#> set_run_name: function (run_name)
#> site_name: posieux1
#> weather: WeatherData, R6
#> weather_file: posieux_weather.txt
#> years: 2013 2014 2015
#>