Skip to content

Commit

Permalink
Add get_response_tmax top Model class.
Browse files Browse the repository at this point in the history
Closing Issue #201
  • Loading branch information
raoulcollenteur committed Jul 15, 2020
1 parent 32489b9 commit f1886e8
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion pastas/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
get_block_response
get_step_response
get_response_tmax
get_contribution
get_contributions
get_transform_contribution
Expand All @@ -70,6 +71,7 @@
get_tmax
get_tmin
Set Methods
-----------
.. autosummary::
Expand Down Expand Up @@ -601,7 +603,7 @@ def noise(self, parameters=None, tmin=None, tmax=None, freq=None,
weights = self.noisemodel.weights(res, p)
noise = noise * weights
noise.name = "Weighted Noise"

return noise

def noise_weights(self, parameters=None, tmin=None, tmax=None, freq=None,
Expand Down Expand Up @@ -1557,6 +1559,43 @@ def get_step_response(self, name, parameters=None, add_0=False, dt=None,
return self._get_response(block_or_step="step", name=name, dt=dt,
parameters=parameters, add_0=add_0, **kwargs)

def get_response_tmax(self, name, parameters=None, cutoff=0.999):
"""Method to get the tmax used for the response function.
Parameters
----------
name: str
String with the name of the stressmodel.
parameters: list or numpy.ndarray, optional
iterable with the parameters. If none, the optimal parameters are
used when available, initial otherwise.
cutoff: float, optional
float between 0 and 1. Default is 0.999 or 99.9% of the response.
Returns
-------
tmax: float
Float with the number of days.
Example
-------
>>> ml.get_response_tmax("recharge", cutoff=0.99)
>>> 703
This means that after 1053 days, 99% of the response of the
groundwater levels to a recharge pulse has taken place.
"""
if self.stressmodels[name].rfunc is None:
self.logger.warning("Stressmodel {} has no rfunc".format(name))
return None
else:
if parameters is None:
parameters = self.get_parameters(name)
tmax = self.stressmodels[name].rfunc.get_tmax(p=parameters,
cutoff=cutoff)
return tmax

@get_stressmodel
def get_stress(self, name, tmin=None, tmax=None, freq=None, warmup=None,
istress=None, return_warmup=False, parameters=None):
Expand Down

0 comments on commit f1886e8

Please sign in to comment.