Closed johanvdw closed 7 years ago
I would combine this with a very tiny cli
that provides the option to run niche from command line, using this config file, something like
niche.py config_file.txt -o outputfoldername
and a small help when no command line options.
I'm planning to implement this like this:
msw: "input/msw.asc"
mhw: input/mhw.asc
# anything starting with # is considered a comment. Lines starting with # are ignored
soil_code:input/bodem.tif
# optional values can be left empty
inundation_vegetation:
#or can have a fixed value
rainwater: 0
# it is also possible to overwrite codetables used
ct_vegetation: new_vegetation.csv
# any other options can be specified as well
deviation: 1 # generate deviation maps
simple_model: 1 # use only mhw, mlw and soil_code
output: "c:/nicheoutput"
Which basically means I can use pandas to open the file like I do for the code tables (with comment and seperator set)
Why not use a YAML document for the configuration file?
name : my_model_name
input layers:
- soil_code : ./input/bodem.tif
- msw : ./input/msw.asc #no quotes should be required
- mhw : ./input/mhw.asc
- inundation_vegetation : # optional values can be left empty
- rainwater: 0 #or can have a fixed value
- ...
code tables:
- ct_vegetation : new_vegetation.csv # it is also possible to overwrite codetables used
model options:
- deviation maps: True # generate deviation maps
- output maps folder: c:/nicheoutput
@peterdesmet comments?
Some questions:
type: value
? This means to use a continuous value for the layer?simple_model:
should this not be retrieved from the way input layers are provided? Or is this an additional check?We should proper explain the format in the documentation, see #36
P.S. if you want to store the config in a df, something like this should work (maybe looks a bit odd to use the json_normalize ;-)
import pandas as pd
import yaml
with open('nich_config.yaml', 'r') as f:
df = pd.io.json.json_normalize(yaml.load(f))
print(df.head())
Note that for previous versions of niche these values are stored (manually I think -should check) in an excel file "parameters.xlsx"
Yes, in the previous version the user manually added the names of the input layers in the excel file.
@cecileherr would you be fine to use the text format proposed here instead of the xls-file?
@stijnvanhoey - regarding your questions:
It would be OK (or even easier) for us to use a text file, but I think we should still have some kind of GUI / front end for (some) users. An unexperienced user must also be able to see what the possible options to run NICHE Vlaanderen are and ideally find some information for each possible choice.
Can't say much about the content of the settings file, but agree that a YAML file would be great.
@cecileherr : I created a seperate issue for the GUI.
@stijnvanhoey Disadvantage of yaml (with categories) vs simple key-value pairs is that it may be slightly harder to use for the user. Eg
input_layers:
mhw: data/mhw_small.asc
mlw: ../testcase/grobbendonk/mlw.asc
soil_code: ../testcase/grobbendonk/soil_code.asc
May be valid while
input_layers:
mhw: data/mhw_small.asc
mlw: ../testcase/grobbendonk/mlw.asc
soil_code: ../testcase/grobbendonk/soil_code.asc
would not be and
input_layers:
- mhw: data/mhw_small.asc
- mlw: ../testcase/grobbendonk/mlw.asc
- soil_code: ../testcase/grobbendonk/soil_code.asc
Would not be either (if we decide to use dict rather than lists).
I will implement it like this anyway:
input_layers:
mhw: data/mhw_small.asc
mlw: ../testcase/grobbendonk/mlw.asc
soil_code: ../testcase/grobbendonk/soil_code.asc
If it turns out to be an issue during user testing - we can still adopt with small changes. Not being sloppy on configuration file formatting can also be considered a plus.
Rather hard on the file formatting with sufficient feedback to user on why things fail (+ proper examples of configuration files) than trying to capture all possibilities user potentially could define ;-)
Closed as of 3e55dc83a6bdc1e41af3bbde739bd2204e4ba9ec and previous commits.
Note that support for codetables is not yet included (#32 )
Rather than using set_input it should also be possible to create a niche model based on a configuration input file.
Both options are useful.