Skip to content
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

Correct Checks for TarsoModel #51

Merged
merged 6 commits into from
Dec 10, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions pastastore/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ def _parse_model_dict(self, mdict: dict,
mdict["oseries"]["settings"]["tmax"] = \
mdict['oseries']['series'].index[-1]

# StressModel, StressModel2, WellModel
# StressModel, WellModel
for ts in mdict["stressmodels"].values():
if "stress" in ts.keys():
for stress in ts["stress"]:
Expand All @@ -1015,7 +1015,7 @@ def _parse_model_dict(self, mdict: dict,
stress["settings"]["tmax"] = \
stress['series'].index[-1]

# RechargeModel
# RechargeModel, TarsoModel
if ("prec" in ts.keys()) and ("evap" in ts.keys()):
for stress in [ts["prec"], ts["evap"]]:
if 'series' not in stress:
Expand Down Expand Up @@ -1095,28 +1095,28 @@ def _set_series_name(series, name):

@staticmethod
def _check_model_series_names_for_store(ml):
prec_evap_model = ["RechargeModel", "TarsoModel"]
if isinstance(ml, ps.Model):
series_names = [istress.series.name
for sm in ml.stressmodels.values()
if sm._name != "RechargeModel"
if sm._name not in prec_evap_model
for istress in sm.stress]
if "RechargeModel" in [i._name for i in ml.stressmodels.values()]:
if prec_evap_model in [i._name for i in ml.stressmodels.values()]:
dbrakenhoff marked this conversation as resolved.
Show resolved Hide resolved
series_names += [istress.series.name
for sm in ml.stressmodels.values()
if sm._name == "RechargeModel"
if sm._name in prec_evap_model
dbrakenhoff marked this conversation as resolved.
Show resolved Hide resolved
for istress in sm.stress]
elif isinstance(ml, dict):
# non RechargeModel stressmodels
series_names = [istress["name"] for sm in
ml["stressmodels"].values()
if sm["stressmodel"] != "RechargeModel"
if sm["stressmodel"] not in prec_evap_model
for istress in sm["stress"]]
# RechargeModel
if "RechargeModel" in [i["stressmodel"] for i in
ml["stressmodels"].values()]:
if ["RechargeModel", "TarsoModel"] in [i["stressmodel"] for i in ml["stressmodels"].values()]:
series_names += [istress["name"] for sm in
ml["stressmodels"].values()
if sm["stressmodel"] == "RechargeModel"
if sm["stressmodel"] in prec_evap_model
for istress in [sm["prec"], sm["evap"]]]
else:
raise TypeError("Expected pastas.Model or dict!")
Expand Down Expand Up @@ -1160,9 +1160,10 @@ def _check_stresses_in_store(self, ml: Union[ps.Model, dict]):
ml : Union[ps.Model, dict]
pastas Model
"""
prec_evap_model = ["RechargeModel", "TarsoModel"]
if isinstance(ml, ps.Model):
for sm in ml.stressmodels.values():
if sm._name == "RechargeModel":
if sm._name in prec_evap_model:
stresses = [sm.prec, sm.evap]
else:
stresses = sm.stress
Expand All @@ -1179,7 +1180,7 @@ def _check_stresses_in_store(self, ml: Union[ps.Model, dict]):
f"'{s.name}' is different from stored stress!")
elif isinstance(ml, dict):
for sm in ml["stressmodels"].values():
if sm["stressmodel"] == "RechargeModel":
if sm["stressmodel"] in prec_evap_model:
stresses = [sm["prec"], sm["evap"]]
else:
stresses = sm["stress"]
Expand Down