@@ -378,29 +378,45 @@ def initialize_minimal(file=None, logging_level='INFO', params=None):
378378 Parameters
379379 ----------
380380 file : str
381- path to the configuration file (default: OGGM params.cfg)
381+ path to a user configuration file. The parameters provided in this file
382+ will override the default settings in `OGGM params.cfg`. The file does
383+ not need to include all parameters.
382384 logging_level : str
383385 set a logging level. See :func:`set_logging_config` for options.
384386 params : dict
385- overrides for specific parameters from the config file
387+ overrides for specific parameters from the config file. Overrules a
388+ potential provided file.
386389 """
387390 global IS_INITIALIZED
388391 global PARAMS
389392 global PATHS
390393
391394 set_logging_config (logging_level = logging_level )
392395
393- is_default = False
394- if file is None :
395- file = os .path .join (os .path .abspath (os .path .dirname (__file__ )),
396- 'params.cfg' )
397- is_default = True
396+ # Open default params file
397+ is_default = True
398+ file_default = os .path .join (os .path .abspath (os .path .dirname (__file__ )),
399+ 'params.cfg' )
398400 try :
399- cp = ConfigObj (file , file_error = True )
401+ cp = ConfigObj (file_default , file_error = True )
400402 except (ConfigObjError , IOError ) as e :
401- log .critical ('Config file could not be parsed (%s): %s' , file , e )
403+ log .critical ('Config file could not be parsed (%s): %s' ,
404+ file_default , e )
402405 sys .exit ()
403406
407+ # If provided open user params file and overwrite defaults
408+ if file :
409+ is_default = False
410+ try :
411+ cp_user = ConfigObj (file , file_error = True )
412+ except (ConfigObjError , IOError ) as e :
413+ log .critical ('Config file could not be parsed (%s): %s' ,
414+ file , e )
415+ sys .exit ()
416+
417+ for k , v in cp_user .items ():
418+ cp [k ] = v
419+
404420 if is_default :
405421 log .workflow ('Reading default parameters from the OGGM `params.cfg` '
406422 'configuration file.' )
@@ -411,7 +427,7 @@ def initialize_minimal(file=None, logging_level='INFO', params=None):
411427 # Static Paths
412428 oggm_static_paths ()
413429
414- # Apply code-side manual params overrides
430+ # Apply code-side manual params overrides, overrules provided params file
415431 if params :
416432 for k , v in params .items ():
417433 cp [k ] = v
0 commit comments