Skip to content

Commit

Permalink
Add overwriteable user parameters via command line
Browse files Browse the repository at this point in the history
  • Loading branch information
leonfoks committed Jan 10, 2024
1 parent d4504aa commit 3f425e1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions geobipy/src/inversion/user_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Parent handler for user defined parameters. Checks that the input user parameters match for a given data point.
This provides a bit more robust checking when the user is new to the codes, and must modify an input parameter class file.
"""
#from ..base import Error as Err
from os.path import join
from numpy import float64, asarray

from ..classes.core.myObject import myObject
Expand All @@ -14,7 +14,7 @@
from ..classes.data.datapoint.FdemDataPoint import FdemDataPoint
from ..classes.data.datapoint.TdemDataPoint import TdemDataPoint
from ..classes.data.datapoint.Tempest_datapoint import Tempest_datapoint
# from ..classes.statistics.Hitmap2D import Hitmap2D

import numpy as np
from ..base.utilities import isInt

Expand Down Expand Up @@ -44,6 +44,12 @@ def __init__(self, **kwargs):
kwargs['covariance_scaling'] = float64(1.0) if kwargs.get('covariance_scaling') is None else kwargs.get('covariance_scaling')
# kwargs['parameter_limits'] = np.r_[1e-10, 1e10] if kwargs.get('parameter_limits') is None else kwargs.get('parameter_limits')

kwargs['data_filename'] = join(kwargs['data_directory'], kwargs['data_filename'])
if isinstance(kwargs['system_filename'], list):
kwargs['system_filename'] = [join(kwargs['data_directory'], x) for x in kwargs['system_filename']]
else:
kwargs['system_filename'] = join(kwargs['data_directory'], kwargs['system_filename'])

for key, value in kwargs.items():
self[key] = value

Expand Down Expand Up @@ -74,7 +80,7 @@ def required_keys(self):
)

@classmethod
def read(cls, filename):
def read(cls, filename, **kwargs):
options = {}
# Load user parameters
with open(filename, 'r') as f:
Expand All @@ -86,4 +92,8 @@ def read(cls, filename):
if not isinstance(value[0], str):
options[key] = asarray(value)

for key, value in kwargs.items():
if value is not None:
options[key] = value

return cls(**options)

0 comments on commit 3f425e1

Please sign in to comment.