Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,22 @@ def prepare_mapping(nVeg, ConfigFile):
with open(ConfigFile, 'r') as conf:
MappingConf = yaml.safe_load(conf)

# At the moment, the only thing that requires defaults is the input to
# output vegetation mapping. By default, it maps in a 1-to-1 manner, i.e.
# By default, the vegetation maps in a 1-to-1 manner, i.e.
# vegetation type 1 in the old vegetation map maps to vegetation type 1 in
# the new vegetation map.
VegetationMapping = {i: [i] for i in range(nVeg)}

# It may be that the user removes either per_tile or per_cell entries in
# the config- apply default values (empty list) that are iterable in that
# case. Also, ensure that it's a list instance
MappingConf['per_cell'] = MappingConf.get('per_cell') or []
if not isinstance(MappingConf['per_cell'], list):
MappingConf['per_cell'] = [MappingConf['per_cell']]

MappingConf['per_tile'] = MappingConf.get('per_tile') or []
if not isinstance(MappingConf['per_tile'], list):
MappingConf['per_tile'] = [MappingConf['per_tile']]

# Apply the supplied mappings
if 'vegetation_map' in MappingConf:
for OutVegType, InVegTypes in MappingConf['vegetation_map'].items():
Expand Down
Loading