Skip to content

Commit

Permalink
Add possibility to load a default user configuration file in IFS.Redu…
Browse files Browse the repository at this point in the history
…ction()

Progress on #73
  • Loading branch information
Arthur Vigan committed Jun 13, 2022
1 parent 4c7c5c5 commit 0f737d5
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions sphere/IFS.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class Reduction(object):
# Constructor
##################################################

def __new__(cls, path, log_level='info', sphere_handler=None):
def __new__(cls, path, log_level='info', user_config=None, sphere_handler=None):
'''
Custom instantiation for the class
Expand All @@ -407,9 +407,13 @@ def __new__(cls, path, log_level='info', sphere_handler=None):
path : str
Path to the directory containing the dataset
level : {'debug', 'info', 'warning', 'error', 'critical'}
log_level : {'debug', 'info', 'warning', 'error', 'critical'}
The log level of the handler
user_config : str
Path to a user-provided configuration. Default is None, i.e. the
reduction will use the package default configuration parameters
sphere_handler : log handler
Higher-level SPHERE.Dataset log handler
'''
Expand Down Expand Up @@ -496,7 +500,6 @@ def __new__(cls, path, log_level='info', sphere_handler=None):
reduction._default_center = np.array(eval(cfgparser.get('calibration', 'default_center')))
reduction._orientation_offset = eval(cfgparser.get('calibration', 'orientation_offset'))

# reduction parameters
# reduction parameters
cfg = {}
items = dict(cfgparser.items('reduction'))
Expand All @@ -508,6 +511,12 @@ def __new__(cls, path, log_level='info', sphere_handler=None):
cfg[key] = val
reduction._config = utils.Configuration(reduction._path, reduction._logger, cfg)

# load user-provided default configuration parameters
if user_config:
user_config = Path(user_config)

reduction._config.load_from_file(user_config)

#
# reduction adn recipes status
#
Expand Down

0 comments on commit 0f737d5

Please sign in to comment.