@@ -56,20 +56,19 @@ def init(opts):
5656 config .optionxform = str
5757 config .read (opts .config )
5858 conf = OrderedDict (config ['MetSim' ])
59- conf ['forcing_vars' ] = OrderedDict (config ['forcing_vars' ])
60- conf ['domain_vars' ] = OrderedDict (config ['domain_vars' ])
61- conf ['state_vars' ] = OrderedDict (config ['state_vars' ])
62- conf ['chunks' ] = OrderedDict (config ['chunks' ])
63- out_dir = os .path .abspath (conf ['out_dir' ])
64- out_state = conf .get ('out_state' , None )
65- if out_state is None :
66- out_state = os .path .join (out_dir , 'state.nc' )
6759
68- method = conf ['method' ]
60+ def invert_dict (d ):
61+ return OrderedDict ({v : k for k , v in d .items ()})
6962
70- prec_type = conf .get ('prec_type' , None )
71- if prec_type is None :
72- prec_type = 'uniform'
63+ def to_list (s ):
64+ return json .loads (s .replace ("'" , '"' ))
65+
66+ conf ['forcing_vars' ] = OrderedDict (config ['forcing_vars' ])
67+ if conf ['forcing_fmt' ] != 'binary' :
68+ conf ['forcing_vars' ] = invert_dict (conf ['forcing_vars' ])
69+ conf ['domain_vars' ] = invert_dict (OrderedDict (config ['domain_vars' ]))
70+ conf ['state_vars' ] = invert_dict (OrderedDict (config ['state_vars' ]))
71+ conf ['chunks' ] = OrderedDict (config ['chunks' ])
7372
7473 # If the forcing variable is a directory, scan it for files
7574 if os .path .isdir (conf ['forcing' ]):
@@ -78,26 +77,14 @@ def init(opts):
7877 else :
7978 forcing_files = conf ['forcing' ]
8079
81- # We assume there is only one domain file and one state file
82- domain_file = conf ['domain' ]
83- state_file = conf ['state' ]
84- chunks = conf ['chunks' ]
85-
86- def to_list (s ):
87- return json .loads (s .replace ("'" , '"' ))
88-
80+ # Update the full configuration
8981 conf .update ({"calendar" : conf .get ('calendar' , 'standard' ),
9082 "scheduler" : opts .scheduler ,
9183 "num_workers" : opts .num_workers ,
92- "method" : method ,
93- "out_dir" : out_dir ,
94- "out_state" : out_state ,
95- "state" : state_file ,
96- "domain" : domain_file ,
97- "forcing" : forcing_files ,
98- "chunks" : chunks ,
9984 "verbose" : logging .DEBUG if opts .verbose else logging .INFO ,
100- "prec_type" : prec_type })
85+ "forcing" : forcing_files ,
86+ "out_dir" : os .path .abspath (conf ['out_dir' ]),
87+ "prec_type" : conf .get ('prec_type' , 'uniform' )})
10188 conf ['out_vars' ] = to_list (conf .get ('out_vars' , '[]' ))
10289 conf ['iter_dims' ] = to_list (conf .get ('iter_dims' , '["lat", "lon"]' ))
10390 conf = {k : v for k , v in conf .items () if v != []}
0 commit comments