-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 115 raise an error if input parameter has a wrong numerical value #134
Open
jerabekjak
wants to merge
22
commits into
master
Choose a base branch
from
issue_115-raise-an-error-if-input-parameter-has-a-wrong-numerical-value
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
1eeaeb7
add error for too low and too large values #115
jerabekjak 9b504ff
prepare checking values function
jerabekjak 73e80ac
fix typo #115
jerabekjak bf41a86
check values of parameters (2 paramters TODO)#115
jerabekjak f1dc20f
move method to superior class #115
jerabekjak 3452e15
add retention margins
jerabekjak 6daf703
add check for critical tau ne v
jerabekjak 51ac005
add documentation of check parameters function
jerabekjak edae6da
simplified errors for values check in data praperation
jerabekjak 80458e3
all checks must be after rr and rc are created
jerabekjak 3581805
check valus in rr and rc loop
jerabekjak 2bf08d1
put rr and rc in checking function for paramter values
jerabekjak 1da2b1e
retentino values from m to mm during a check
jerabekjak a56f598
add mesage that values were checked
jerabekjak 38ee22d
typo in info msg
jerabekjak dc42fd4
name error accoring to conventions
jerabekjak 3d6b231
Merge branch 'master' into issue_115-raise-an-error-if-input-paramete…
pesekon2 793c4bd
Update smoderp2d/exceptions.py
jerabekjak c49a3d5
Update smoderp2d/exceptions.py
jerabekjak 72c25a0
Update smoderp2d/exceptions.py
jerabekjak 00c24a9
Update smoderp2d/exceptions.py
jerabekjak 518f149
Merge branch 'master' into issue_115-raise-an-error-if-input-paramete…
pesekon2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ | |
from smoderp2d.core import CompType | ||
from smoderp2d.core.general import GridGlobals, Globals | ||
from smoderp2d.providers.base import Logger | ||
from smoderp2d.providers.base.exceptions import DataPreparationError, \ | ||
DataPreparationInvalidInput | ||
from smoderp2d.providers.base.exceptions import SmallParameterValueError, \ | ||
LargeParameterValueError, DataPreparationError, DataPreparationInvalidInput | ||
|
||
|
||
class PrepareDataBase(ABC): | ||
|
@@ -133,7 +133,6 @@ def _get_inf_combinat_index(r, c, mat_k, mat_s): | |
|
||
return mat_inf_index, combinatIndex | ||
|
||
@staticmethod | ||
def _get_mat_nan(r, c, no_data_value, mat_slope, mat_dem): | ||
# vyrezani krajnich bunek, kde byly chyby, je to vyrazeno u | ||
# sklonu a acc | ||
|
@@ -172,7 +171,6 @@ def _get_rr_rc(r, c, mat_boundary): | |
for i in nr: | ||
one_col = [] | ||
for j in nc: | ||
|
||
if mat_boundary[i][j] == -99: | ||
one_col.append(j) | ||
rr_insert = True | ||
|
@@ -186,6 +184,41 @@ def _get_rr_rc(r, c, mat_boundary): | |
rr_insert = False | ||
rc.append(one_col) | ||
|
||
# all checks must be after rr and rc are created. check Ks and S for | ||
# infiltraiton | ||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'Ks', | ||
all_attrib[0], [0,1]) | ||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'S', | ||
all_attrib[1], [0,1]) | ||
|
||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'X', | ||
all_attrib[7], [1,200]) | ||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'Y', | ||
all_attrib[8], [0.01,1]) | ||
# check the critical tension and velocity | ||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'tau', | ||
all_attrib[9], [1,100]) | ||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'v', | ||
all_attrib[10], [0.1,5]) | ||
|
||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'n', | ||
self.data['mat_n'], [0,10]) | ||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'pi', | ||
self.data['mat_pi'], [0,10]) | ||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'ppl', | ||
self.data['mat_ppl'], [0,1]) | ||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'reten', | ||
self.data['mat_reten'], [0,100]) | ||
self._check_parameter_value(self.data['rr'], self.data['rc'], 'b', | ||
self.data['mat_b'], [1,2.5]) | ||
|
||
|
||
self.data['mfda'] = False | ||
self.data['mat_boundary'] = None | ||
self.data['spix'] = None | ||
self.data['vpix'] = None | ||
#Logger.progress(100) | ||
|
||
return rr, rc | ||
|
||
|
||
|
@@ -260,6 +293,30 @@ def __init__(self, writter): | |
self.fieldnames['channel_q365'] | ||
] | ||
|
||
def _check_parameter_value(self, rr, rc, name, arr, range_): | ||
jerabekjak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" check the parameter margins | ||
|
||
:param list rr: list of i indices in the computaion domain | ||
:param list rc: list of j indices in the computaion domain | ||
:param str name: name of the variable | ||
:param np.array arr: the array holding the parameter values | ||
:param list range_: range of appropriate parameters | ||
""" | ||
|
||
for i in rr: | ||
for j in rc[i]: | ||
val = arr[i][j] | ||
if (range_[0] > val) : raise SmallParameterValueError(name, val, range_[0]) | ||
if (range_[1] < val) : raise LargeParameterValueError(name, val, range_[1]) | ||
|
||
Logger.info('{} parameter values checked.'.format(name)) | ||
|
||
|
||
def _set_output_data(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where is this new method called? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it is more of a rhetoric question, but the answer is nowhere (at least at this moment). |
||
""" | ||
Creates dictionary to which model parameters are computed. | ||
""" | ||
# output data | ||
self.data = { | ||
'mat_boundary': None, | ||
'outletCells': None, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong or large?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"{} parameter value is too large ({} > {})"