@@ -55,12 +55,22 @@ def prepare_mapping(nVeg, ConfigFile):
5555 with open (ConfigFile , 'r' ) as conf :
5656 MappingConf = yaml .safe_load (conf )
5757
58- # At the moment, the only thing that requires defaults is the input to
59- # output vegetation mapping. By default, it maps in a 1-to-1 manner, i.e.
58+ # By default, the vegetation maps in a 1-to-1 manner, i.e.
6059 # vegetation type 1 in the old vegetation map maps to vegetation type 1 in
6160 # the new vegetation map.
6261 VegetationMapping = {i : [i ] for i in range (nVeg )}
6362
63+ # It may be that the user removes either per_tile or per_cell entries in
64+ # the config- apply default values (empty list) that are iterable in that
65+ # case. Also, ensure that it's a list instance
66+ MappingConf ['per_cell' ] = MappingConf .get ('per_cell' ) or []
67+ if not isinstance (MappingConf ['per_cell' ], list ):
68+ MappingConf ['per_cell' ] = [MappingConf ['per_cell' ]]
69+
70+ MappingConf ['per_tile' ] = MappingConf .get ('per_tile' ) or []
71+ if not isinstance (MappingConf ['per_tile' ], list ):
72+ MappingConf ['per_tile' ] = [MappingConf ['per_tile' ]]
73+
6474 # Apply the supplied mappings
6575 if 'vegetation_map' in MappingConf :
6676 for OutVegType , InVegTypes in MappingConf ['vegetation_map' ].items ():
0 commit comments