sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def solve_dv_dt_v1(self):
"""Solve the differential equation of HydPy-L.
At the moment, HydPy-L only implements a simple numerical solution of
its underlying ordinary differential equation. To increase the accuracy
(or sometimes even to prevent instability) of this approximation, one
can set the v... | Solve the differential equation of HydPy-L.
At the moment, HydPy-L only implements a simple numerical solution of
its underlying ordinary differential equation. To increase the accuracy
(or sometimes even to prevent instability) of this approximation, one
can set the value of parameter |MaxDT| to a va... | entailment |
def calc_vq_v1(self):
"""Calculate the auxiliary term.
Required derived parameters:
|Seconds|
|NmbSubsteps|
Required flux sequence:
|QZ|
Required aide sequence:
|llake_aides.V|
Calculated aide sequence:
|llake_aides.VQ|
Basic equation:
:math:`VQ = 2 \\cdo... | Calculate the auxiliary term.
Required derived parameters:
|Seconds|
|NmbSubsteps|
Required flux sequence:
|QZ|
Required aide sequence:
|llake_aides.V|
Calculated aide sequence:
|llake_aides.VQ|
Basic equation:
:math:`VQ = 2 \\cdot V + \\frac{Seconds}{NmbSubs... | entailment |
def interp_qa_v1(self):
"""Calculate the lake outflow based on linear interpolation.
Required control parameters:
|N|
|llake_control.Q|
Required derived parameters:
|llake_derived.TOY|
|llake_derived.VQ|
Required aide sequence:
|llake_aides.VQ|
Calculated aide seque... | Calculate the lake outflow based on linear interpolation.
Required control parameters:
|N|
|llake_control.Q|
Required derived parameters:
|llake_derived.TOY|
|llake_derived.VQ|
Required aide sequence:
|llake_aides.VQ|
Calculated aide sequence:
|llake_aides.QA|
... | entailment |
def calc_v_qa_v1(self):
"""Update the stored water volume based on the equation of continuity.
Note that for too high outflow values, which would result in overdraining
the lake, the outflow is trimmed.
Required derived parameters:
|Seconds|
|NmbSubsteps|
Required flux sequence:
... | Update the stored water volume based on the equation of continuity.
Note that for too high outflow values, which would result in overdraining
the lake, the outflow is trimmed.
Required derived parameters:
|Seconds|
|NmbSubsteps|
Required flux sequence:
|QZ|
Updated aide sequenc... | entailment |
def interp_w_v1(self):
"""Calculate the actual water stage based on linear interpolation.
Required control parameters:
|N|
|llake_control.V|
|llake_control.W|
Required state sequence:
|llake_states.V|
Calculated state sequence:
|llake_states.W|
Examples:
Pr... | Calculate the actual water stage based on linear interpolation.
Required control parameters:
|N|
|llake_control.V|
|llake_control.W|
Required state sequence:
|llake_states.V|
Calculated state sequence:
|llake_states.W|
Examples:
Prepare a model object:
... | entailment |
def corr_dw_v1(self):
"""Adjust the water stage drop to the highest value allowed and correct
the associated fluxes.
Note that method |corr_dw_v1| calls the method `interp_v` of the
respective application model. Hence the requirements of the actual
`interp_v` need to be considered additionally.
... | Adjust the water stage drop to the highest value allowed and correct
the associated fluxes.
Note that method |corr_dw_v1| calls the method `interp_v` of the
respective application model. Hence the requirements of the actual
`interp_v` need to be considered additionally.
Required control parameter... | entailment |
def modify_qa_v1(self):
"""Add water to or remove water from the calculated lake outflow.
Required control parameter:
|Verzw|
Required derived parameter:
|llake_derived.TOY|
Updated flux sequence:
|llake_fluxes.QA|
Basic Equation:
:math:`QA = QA* - Verzw`
Examples:
... | Add water to or remove water from the calculated lake outflow.
Required control parameter:
|Verzw|
Required derived parameter:
|llake_derived.TOY|
Updated flux sequence:
|llake_fluxes.QA|
Basic Equation:
:math:`QA = QA* - Verzw`
Examples:
In preparation for the f... | entailment |
def pass_q_v1(self):
"""Update the outlet link sequence."""
flu = self.sequences.fluxes.fastaccess
out = self.sequences.outlets.fastaccess
out.q[0] += flu.qa | Update the outlet link sequence. | entailment |
def thresholds(self):
"""Threshold values of the response functions."""
return numpy.array(
sorted(self._key2float(key) for key in self._coefs), dtype=float) | Threshold values of the response functions. | entailment |
def prepare_arrays(sim=None, obs=None, node=None, skip_nan=False):
"""Prepare and return two |numpy| arrays based on the given arguments.
Note that many functions provided by module |statstools| apply function
|prepare_arrays| internally (e.g. |nse|). But you can also apply it
manually, as shown in th... | Prepare and return two |numpy| arrays based on the given arguments.
Note that many functions provided by module |statstools| apply function
|prepare_arrays| internally (e.g. |nse|). But you can also apply it
manually, as shown in the following examples.
Function |prepare_arrays| can extract time seri... | entailment |
def nse(sim=None, obs=None, node=None, skip_nan=False):
"""Calculate the efficiency criteria after Nash & Sutcliffe.
If the simulated values predict the observed values as well
as the average observed value (regarding the the mean square
error), the NSE value is zero:
>>> from hydpy import nse
... | Calculate the efficiency criteria after Nash & Sutcliffe.
If the simulated values predict the observed values as well
as the average observed value (regarding the the mean square
error), the NSE value is zero:
>>> from hydpy import nse
>>> nse(sim=[2.0, 2.0, 2.0], obs=[1.0, 2.0, 3.0])
0.0
... | entailment |
def bias_abs(sim=None, obs=None, node=None, skip_nan=False):
"""Calculate the absolute difference between the means of the simulated
and the observed values.
>>> from hydpy import round_
>>> from hydpy import bias_abs
>>> round_(bias_abs(sim=[2.0, 2.0, 2.0], obs=[1.0, 2.0, 3.0]))
0.0
>>> ro... | Calculate the absolute difference between the means of the simulated
and the observed values.
>>> from hydpy import round_
>>> from hydpy import bias_abs
>>> round_(bias_abs(sim=[2.0, 2.0, 2.0], obs=[1.0, 2.0, 3.0]))
0.0
>>> round_(bias_abs(sim=[5.0, 2.0, 2.0], obs=[1.0, 2.0, 3.0]))
1.0
... | entailment |
def std_ratio(sim=None, obs=None, node=None, skip_nan=False):
"""Calculate the ratio between the standard deviation of the simulated
and the observed values.
>>> from hydpy import round_
>>> from hydpy import std_ratio
>>> round_(std_ratio(sim=[1.0, 2.0, 3.0], obs=[1.0, 2.0, 3.0]))
0.0
>>> ... | Calculate the ratio between the standard deviation of the simulated
and the observed values.
>>> from hydpy import round_
>>> from hydpy import std_ratio
>>> round_(std_ratio(sim=[1.0, 2.0, 3.0], obs=[1.0, 2.0, 3.0]))
0.0
>>> round_(std_ratio(sim=[1.0, 1.0, 1.0], obs=[1.0, 2.0, 3.0]))
-1.0
... | entailment |
def corr(sim=None, obs=None, node=None, skip_nan=False):
"""Calculate the product-moment correlation coefficient after Pearson.
>>> from hydpy import round_
>>> from hydpy import corr
>>> round_(corr(sim=[0.5, 1.0, 1.5], obs=[1.0, 2.0, 3.0]))
1.0
>>> round_(corr(sim=[4.0, 2.0, 0.0], obs=[1.0, 2... | Calculate the product-moment correlation coefficient after Pearson.
>>> from hydpy import round_
>>> from hydpy import corr
>>> round_(corr(sim=[0.5, 1.0, 1.5], obs=[1.0, 2.0, 3.0]))
1.0
>>> round_(corr(sim=[4.0, 2.0, 0.0], obs=[1.0, 2.0, 3.0]))
-1.0
>>> round_(corr(sim=[1.0, 2.0, 1.0], obs... | entailment |
def hsepd_pdf(sigma1, sigma2, xi, beta,
sim=None, obs=None, node=None, skip_nan=False):
"""Calculate the probability densities based on the
heteroskedastic skewed exponential power distribution.
For convenience, the required parameters of the probability density
function as well as the si... | Calculate the probability densities based on the
heteroskedastic skewed exponential power distribution.
For convenience, the required parameters of the probability density
function as well as the simulated and observed values are stored
in a dictonary:
>>> import numpy
>>> from hydpy import ro... | entailment |
def hsepd_manual(sigma1, sigma2, xi, beta,
sim=None, obs=None, node=None, skip_nan=False):
"""Calculate the mean of the logarithmised probability densities of the
'heteroskedastic skewed exponential power distribution.
The following examples are taken from the documentation of function
... | Calculate the mean of the logarithmised probability densities of the
'heteroskedastic skewed exponential power distribution.
The following examples are taken from the documentation of function
|hsepd_pdf|, which is used by function |hsepd_manual|. The first
one deals with a heteroscedastic normal dist... | entailment |
def hsepd(sim=None, obs=None, node=None, skip_nan=False,
inits=None, return_pars=False, silent=True):
"""Calculate the mean of the logarithmised probability densities of the
'heteroskedastic skewed exponential power distribution.
Function |hsepd| serves the same purpose as function |hsepd_manual|... | Calculate the mean of the logarithmised probability densities of the
'heteroskedastic skewed exponential power distribution.
Function |hsepd| serves the same purpose as function |hsepd_manual|,
but tries to estimate the parameters of the heteroscedastic skewed
exponential distribution via an optimizati... | entailment |
def calc_mean_time(timepoints, weights):
"""Return the weighted mean of the given timepoints.
With equal given weights, the result is simply the mean of the given
time points:
>>> from hydpy import calc_mean_time
>>> calc_mean_time(timepoints=[3., 7.],
... weights=[2., 2.])
... | Return the weighted mean of the given timepoints.
With equal given weights, the result is simply the mean of the given
time points:
>>> from hydpy import calc_mean_time
>>> calc_mean_time(timepoints=[3., 7.],
... weights=[2., 2.])
5.0
With different weights, the resulting m... | entailment |
def calc_mean_time_deviation(timepoints, weights, mean_time=None):
"""Return the weighted deviation of the given timepoints from their mean
time.
With equal given weights, the is simply the standard deviation of the
given time points:
>>> from hydpy import calc_mean_time_deviation
>>> calc_mea... | Return the weighted deviation of the given timepoints from their mean
time.
With equal given weights, the is simply the standard deviation of the
given time points:
>>> from hydpy import calc_mean_time_deviation
>>> calc_mean_time_deviation(timepoints=[3., 7.],
... wei... | entailment |
def evaluationtable(nodes, criteria, nodenames=None,
critnames=None, skip_nan=False):
"""Return a table containing the results of the given evaluation
criteria for the given |Node| objects.
First, we define two nodes with different simulation and observation
data (see function |prep... | Return a table containing the results of the given evaluation
criteria for the given |Node| objects.
First, we define two nodes with different simulation and observation
data (see function |prepare_arrays| for some explanations):
>>> from hydpy import pub, Node, nan
>>> pub.timegrids = '01.01.2000... | entailment |
def set_primary_parameters(self, **kwargs):
"""Set all primary parameters at once."""
given = sorted(kwargs.keys())
required = sorted(self._PRIMARY_PARAMETERS)
if given == required:
for (key, value) in kwargs.items():
setattr(self, key, value)
else:
... | Set all primary parameters at once. | entailment |
def primary_parameters_complete(self):
"""True/False flag that indicates wheter the values of all primary
parameters are defined or not."""
for primpar in self._PRIMARY_PARAMETERS.values():
if primpar.__get__(self) is None:
return False
return True | True/False flag that indicates wheter the values of all primary
parameters are defined or not. | entailment |
def update(self):
"""Delete the coefficients of the pure MA model and also all MA and
AR coefficients of the ARMA model. Also calculate or delete the values
of all secondary iuh parameters, depending on the completeness of the
values of the primary parameters.
"""
del se... | Delete the coefficients of the pure MA model and also all MA and
AR coefficients of the ARMA model. Also calculate or delete the values
of all secondary iuh parameters, depending on the completeness of the
values of the primary parameters. | entailment |
def delay_response_series(self):
"""A tuple of two numpy arrays, which hold the time delays and the
associated iuh values respectively."""
delays = []
responses = []
sum_responses = 0.
for t in itertools.count(self.dt_response/2., self.dt_response):
delays.app... | A tuple of two numpy arrays, which hold the time delays and the
associated iuh values respectively. | entailment |
def plot(self, threshold=None, **kwargs):
"""Plot the instanteneous unit hydrograph.
The optional argument allows for defining a threshold of the cumulative
sum uf the hydrograph, used to adjust the largest value of the x-axis.
It must be a value between zero and one.
"""
... | Plot the instanteneous unit hydrograph.
The optional argument allows for defining a threshold of the cumulative
sum uf the hydrograph, used to adjust the largest value of the x-axis.
It must be a value between zero and one. | entailment |
def moment1(self):
"""The first time delay weighted statistical moment of the
instantaneous unit hydrograph."""
delays, response = self.delay_response_series
return statstools.calc_mean_time(delays, response) | The first time delay weighted statistical moment of the
instantaneous unit hydrograph. | entailment |
def moment2(self):
"""The second time delay weighted statistical momens of the
instantaneous unit hydrograph."""
moment1 = self.moment1
delays, response = self.delay_response_series
return statstools.calc_mean_time_deviation(
delays, response, moment1) | The second time delay weighted statistical momens of the
instantaneous unit hydrograph. | entailment |
def calc_secondary_parameters(self):
"""Determine the values of the secondary parameters `a` and `b`."""
self.a = self.x/(2.*self.d**.5)
self.b = self.u/(2.*self.d**.5) | Determine the values of the secondary parameters `a` and `b`. | entailment |
def calc_secondary_parameters(self):
"""Determine the value of the secondary parameter `c`."""
self.c = 1./(self.k*special.gamma(self.n)) | Determine the value of the secondary parameter `c`. | entailment |
def trim(self, lower=None, upper=None):
"""Trim values in accordance with :math:`WAeS \\leq PWMax \\cdot WATS`,
or at least in accordance with if :math:`WATS \\geq 0`.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(7)
>>> pwmax(2.0)
>>> sta... | Trim values in accordance with :math:`WAeS \\leq PWMax \\cdot WATS`,
or at least in accordance with if :math:`WATS \\geq 0`.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(7)
>>> pwmax(2.0)
>>> states.waes = -1., 0., 1., -1., 5., 10., 20.
>... | entailment |
def trim(self, lower=None, upper=None):
"""Trim values in accordance with :math:`WAeS \\leq PWMax \\cdot WATS`.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(7)
>>> pwmax(2.)
>>> states.wats = 0., 0., 0., 5., 5., 5., 5.
>>> states.waes(-1.... | Trim values in accordance with :math:`WAeS \\leq PWMax \\cdot WATS`.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(7)
>>> pwmax(2.)
>>> states.wats = 0., 0., 0., 5., 5., 5., 5.
>>> states.waes(-1., 0., 1., -1., 5., 10., 20.)
>>> states.wae... | entailment |
def trim(self, lower=None, upper=None):
"""Trim values in accordance with :math:`BoWa \\leq NFk`.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(5)
>>> nfk(200.)
>>> states.bowa(-100.,0., 100., 200., 300.)
>>> states.bowa
bowa(0.0, ... | Trim values in accordance with :math:`BoWa \\leq NFk`.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(5)
>>> nfk(200.)
>>> states.bowa(-100.,0., 100., 200., 300.)
>>> states.bowa
bowa(0.0, 0.0, 100.0, 200.0, 200.0) | entailment |
def post(self, request, pk):
""" Clean the data and save opening hours in the database.
Old opening hours are purged before new ones are saved.
"""
location = self.get_object()
# open days, disabled widget data won't make it into request.POST
present_prefixes = [x.split('... | Clean the data and save opening hours in the database.
Old opening hours are purged before new ones are saved. | entailment |
def get(self, request, pk):
""" Initialize the editing form
1. Build opening_hours, a lookup dictionary to populate the form
slots: keys are day numbers, values are lists of opening
hours for that day.
2. Build days, a list of days with 2 slot forms each.
3. Build ... | Initialize the editing form
1. Build opening_hours, a lookup dictionary to populate the form
slots: keys are day numbers, values are lists of opening
hours for that day.
2. Build days, a list of days with 2 slot forms each.
3. Build form initials for the 2 slots padding/tr... | entailment |
def calc_qjoints_v1(self):
"""Apply the routing equation.
Required derived parameters:
|NmbSegments|
|C1|
|C2|
|C3|
Updated state sequence:
|QJoints|
Basic equation:
:math:`Q_{space+1,time+1} =
c1 \\cdot Q_{space,time+1} +
c2 \\cdot Q_{space,time} +
... | Apply the routing equation.
Required derived parameters:
|NmbSegments|
|C1|
|C2|
|C3|
Updated state sequence:
|QJoints|
Basic equation:
:math:`Q_{space+1,time+1} =
c1 \\cdot Q_{space,time+1} +
c2 \\cdot Q_{space,time} +
c3 \\cdot Q_{space+1,time}`
... | entailment |
def pick_q_v1(self):
"""Assign the actual value of the inlet sequence to the upper joint
of the subreach upstream."""
inl = self.sequences.inlets.fastaccess
new = self.sequences.states.fastaccess_new
new.qjoints[0] = 0.
for idx in range(inl.len_q):
new.qjoints[0] += inl.q[idx][0] | Assign the actual value of the inlet sequence to the upper joint
of the subreach upstream. | entailment |
def pass_q_v1(self):
"""Assing the actual value of the lower joint of of the subreach
downstream to the outlet sequence."""
der = self.parameters.derived.fastaccess
new = self.sequences.states.fastaccess_new
out = self.sequences.outlets.fastaccess
out.q[0] += new.qjoints[der.nmbsegments] | Assing the actual value of the lower joint of of the subreach
downstream to the outlet sequence. | entailment |
def _detect_encoding(data=None):
"""Return the default system encoding. If data is passed, try
to decode the data with the default system encoding or from a short
list of encoding types to test.
Args:
data - list of lists
Returns:
enc - system encoding
"""
import locale
... | Return the default system encoding. If data is passed, try
to decode the data with the default system encoding or from a short
list of encoding types to test.
Args:
data - list of lists
Returns:
enc - system encoding | entailment |
def parameterstep(timestep=None):
"""Define a parameter time step size within a parameter control file.
Argument:
* timestep(|Period|): Time step size.
Function parameterstep should usually be be applied in a line
immediately behind the model import. Defining the step size of time
dependent... | Define a parameter time step size within a parameter control file.
Argument:
* timestep(|Period|): Time step size.
Function parameterstep should usually be be applied in a line
immediately behind the model import. Defining the step size of time
dependent parameters is a prerequisite to access a... | entailment |
def reverse_model_wildcard_import():
"""Clear the local namespace from a model wildcard import.
Calling this method should remove the critical imports into the local
namespace due the last wildcard import of a certain application model.
It is thought for securing the successive preperation of different... | Clear the local namespace from a model wildcard import.
Calling this method should remove the critical imports into the local
namespace due the last wildcard import of a certain application model.
It is thought for securing the successive preperation of different
types of models via wildcard imports. ... | entailment |
def prepare_model(module: Union[types.ModuleType, str],
timestep: PeriodABC.ConstrArg = None):
"""Prepare and return the model of the given module.
In usual HydPy projects, each hydrological model instance is prepared
in an individual control file. This allows for "polluting" the
nam... | Prepare and return the model of the given module.
In usual HydPy projects, each hydrological model instance is prepared
in an individual control file. This allows for "polluting" the
namespace with different model attributes. There is no danger of
name conflicts, as long as no other (wildcard) import... | entailment |
def simulationstep(timestep):
""" Define a simulation time step size for testing purposes within a
parameter control file.
Using |simulationstep| only affects the values of time dependent
parameters, when `pub.timegrids.stepsize` is not defined. It thus has
no influence on usual hydpy simulations ... | Define a simulation time step size for testing purposes within a
parameter control file.
Using |simulationstep| only affects the values of time dependent
parameters, when `pub.timegrids.stepsize` is not defined. It thus has
no influence on usual hydpy simulations at all. Use it just to check
your... | entailment |
def controlcheck(controldir='default', projectdir=None, controlfile=None):
"""Define the corresponding control file within a condition file.
Function |controlcheck| serves similar purposes as function
|parameterstep|. It is the reason why one can interactively
access the state and/or the log sequences... | Define the corresponding control file within a condition file.
Function |controlcheck| serves similar purposes as function
|parameterstep|. It is the reason why one can interactively
access the state and/or the log sequences within condition files
as `land_dill.py` of the example project `LahnH`. It ... | entailment |
def update(self):
"""Update |RelSoilArea| based on |Area|, |ZoneArea|, and |ZoneType|.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> nmbzones(4)
>>> zonetype(FIELD, FOREST, GLACIER, ILAKE)
>>> area(100.0)
>>> zonearea(10.0, 20.0, 30.0, 40.0)
... | Update |RelSoilArea| based on |Area|, |ZoneArea|, and |ZoneType|.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> nmbzones(4)
>>> zonetype(FIELD, FOREST, GLACIER, ILAKE)
>>> area(100.0)
>>> zonearea(10.0, 20.0, 30.0, 40.0)
>>> derived.relsoilarea... | entailment |
def update(self):
"""Update |TTM| based on :math:`TTM = TT+DTTM`.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> nmbzones(1)
>>> zonetype(FIELD)
>>> tt(1.0)
>>> dttm(-2.0)
>>> derived.ttm.update()
>>> derived.ttm
ttm(-1.0... | Update |TTM| based on :math:`TTM = TT+DTTM`.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> nmbzones(1)
>>> zonetype(FIELD)
>>> tt(1.0)
>>> dttm(-2.0)
>>> derived.ttm.update()
>>> derived.ttm
ttm(-1.0) | entailment |
def update(self):
"""Update |UH| based on |MaxBaz|.
.. note::
This method also updates the shape of log sequence |QUH|.
|MaxBaz| determines the end point of the triangle. A value of
|MaxBaz| being not larger than the simulation step size is
identical with applying... | Update |UH| based on |MaxBaz|.
.. note::
This method also updates the shape of log sequence |QUH|.
|MaxBaz| determines the end point of the triangle. A value of
|MaxBaz| being not larger than the simulation step size is
identical with applying no unit hydrograph at all:
... | entailment |
def update(self):
"""Update |QFactor| based on |Area| and the current simulation
step size.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> simulationstep('12h')
>>> area(50.0)
>>> derived.qfactor.update()
>>> derived.qfactor
qfac... | Update |QFactor| based on |Area| and the current simulation
step size.
>>> from hydpy.models.hland import *
>>> parameterstep('1d')
>>> simulationstep('12h')
>>> area(50.0)
>>> derived.qfactor.update()
>>> derived.qfactor
qfactor(1.157407) | entailment |
def nmb_neurons(self) -> Tuple[int, ...]:
"""Number of neurons of the hidden layers.
>>> from hydpy import ANN
>>> ann = ANN(None)
>>> ann(nmb_inputs=2, nmb_neurons=(2, 1), nmb_outputs=3)
>>> ann.nmb_neurons
(2, 1)
>>> ann.nmb_neurons = (3,)
>>> ann.nmb_n... | Number of neurons of the hidden layers.
>>> from hydpy import ANN
>>> ann = ANN(None)
>>> ann(nmb_inputs=2, nmb_neurons=(2, 1), nmb_outputs=3)
>>> ann.nmb_neurons
(2, 1)
>>> ann.nmb_neurons = (3,)
>>> ann.nmb_neurons
(3,)
>>> del ann.nmb_neurons
... | entailment |
def shape_weights_hidden(self) -> Tuple[int, int, int]:
"""Shape of the array containing the activation of the hidden neurons.
The first integer value is the number of connection between the
hidden layers, the second integer value is maximum number of
neurons of all hidden layers feedin... | Shape of the array containing the activation of the hidden neurons.
The first integer value is the number of connection between the
hidden layers, the second integer value is maximum number of
neurons of all hidden layers feeding information into another
hidden layer (all except the las... | entailment |
def nmb_weights_hidden(self) -> int:
"""Number of hidden weights.
>>> from hydpy import ANN
>>> ann = ANN(None)
>>> ann(nmb_inputs=2, nmb_neurons=(4, 3, 2), nmb_outputs=3)
>>> ann.nmb_weights_hidden
18
"""
nmb = 0
for idx_layer in range(self.nmb_l... | Number of hidden weights.
>>> from hydpy import ANN
>>> ann = ANN(None)
>>> ann(nmb_inputs=2, nmb_neurons=(4, 3, 2), nmb_outputs=3)
>>> ann.nmb_weights_hidden
18 | entailment |
def verify(self) -> None:
"""Raise a |RuntimeError| if the network's shape is not defined
completely.
>>> from hydpy import ANN
>>> ANN(None).verify()
Traceback (most recent call last):
...
RuntimeError: The shape of the the artificial neural network \
parameter ... | Raise a |RuntimeError| if the network's shape is not defined
completely.
>>> from hydpy import ANN
>>> ANN(None).verify()
Traceback (most recent call last):
...
RuntimeError: The shape of the the artificial neural network \
parameter `ann` of element `?` has not been def... | entailment |
def assignrepr(self, prefix) -> str:
"""Return a string representation of the actual |anntools.ANN| object
that is prefixed with the given string."""
prefix = '%s%s(' % (prefix, self.name)
blanks = len(prefix)*' '
lines = [
objecttools.assignrepr_value(
... | Return a string representation of the actual |anntools.ANN| object
that is prefixed with the given string. | entailment |
def plot(self, xmin, xmax, idx_input=0, idx_output=0, points=100,
**kwargs) -> None:
"""Plot the relationship between a certain input (`idx_input`) and a
certain output (`idx_output`) variable described by the actual
|anntools.ANN| object.
Define the lower and the upper bou... | Plot the relationship between a certain input (`idx_input`) and a
certain output (`idx_output`) variable described by the actual
|anntools.ANN| object.
Define the lower and the upper bound of the x axis via arguments
`xmin` and `xmax`. The number of plotting points can be modified
... | entailment |
def refresh(self) -> None:
"""Prepare the actual |anntools.SeasonalANN| object for calculations.
Dispite all automated refreshings explained in the general
documentation on class |anntools.SeasonalANN|, it is still possible
to destroy the inner consistency of a |anntools.SeasonalANN| in... | Prepare the actual |anntools.SeasonalANN| object for calculations.
Dispite all automated refreshings explained in the general
documentation on class |anntools.SeasonalANN|, it is still possible
to destroy the inner consistency of a |anntools.SeasonalANN| instance,
as it stores its |annt... | entailment |
def verify(self) -> None:
"""Raise a |RuntimeError| and removes all handled neural networks,
if the they are defined inconsistently.
Dispite all automated safety checks explained in the general
documentation on class |anntools.SeasonalANN|, it is still possible
to destroy the in... | Raise a |RuntimeError| and removes all handled neural networks,
if the they are defined inconsistently.
Dispite all automated safety checks explained in the general
documentation on class |anntools.SeasonalANN|, it is still possible
to destroy the inner consistency of a |anntools.Season... | entailment |
def shape(self) -> Tuple[int, ...]:
"""The shape of array |anntools.SeasonalANN.ratios|."""
return tuple(int(sub) for sub in self.ratios.shape) | The shape of array |anntools.SeasonalANN.ratios|. | entailment |
def _set_shape(self, shape):
"""Private on purpose."""
try:
shape = (int(shape),)
except TypeError:
pass
shp = list(shape)
shp[0] = timetools.Period('366d')/self.simulationstep
shp[0] = int(numpy.ceil(round(shp[0], 10)))
getattr(self.fastac... | Private on purpose. | entailment |
def toys(self) -> Tuple[timetools.TOY, ...]:
"""A sorted |tuple| of all contained |TOY| objects."""
return tuple(toy for (toy, _) in self) | A sorted |tuple| of all contained |TOY| objects. | entailment |
def plot(self, xmin, xmax, idx_input=0, idx_output=0, points=100,
**kwargs) -> None:
"""Call method |anntools.ANN.plot| of all |anntools.ANN| objects
handled by the actual |anntools.SeasonalANN| object.
"""
for toy, ann_ in self:
ann_.plot(xmin, xmax,
... | Call method |anntools.ANN.plot| of all |anntools.ANN| objects
handled by the actual |anntools.SeasonalANN| object. | entailment |
def specstring(self):
"""The string corresponding to the current values of `subgroup`,
`state`, and `variable`.
>>> from hydpy.core.itemtools import ExchangeSpecification
>>> spec = ExchangeSpecification('hland_v1', 'fluxes.qt')
>>> spec.specstring
'fluxes.qt'
>>... | The string corresponding to the current values of `subgroup`,
`state`, and `variable`.
>>> from hydpy.core.itemtools import ExchangeSpecification
>>> spec = ExchangeSpecification('hland_v1', 'fluxes.qt')
>>> spec.specstring
'fluxes.qt'
>>> spec.series = True
>>> ... | entailment |
def collect_variables(self, selections) -> None:
"""Apply method |ExchangeItem.insert_variables| to collect the
relevant target variables handled by the devices of the given
|Selections| object.
We prepare the `LahnH` example project to be able to use its
|Selections| object:
... | Apply method |ExchangeItem.insert_variables| to collect the
relevant target variables handled by the devices of the given
|Selections| object.
We prepare the `LahnH` example project to be able to use its
|Selections| object:
>>> from hydpy.core.examples import prepare_full_exam... | entailment |
def insert_variables(
self, device2variable, exchangespec, selections) -> None:
"""Determine the relevant target or base variables (as defined by
the given |ExchangeSpecification| object ) handled by the given
|Selections| object and insert them into the given `device2variable`
... | Determine the relevant target or base variables (as defined by
the given |ExchangeSpecification| object ) handled by the given
|Selections| object and insert them into the given `device2variable`
dictionary. | entailment |
def update_variable(self, variable, value) -> None:
"""Assign the given value(s) to the given target or base variable.
If the assignment fails, |ChangeItem.update_variable| raises an
error like the following:
>>> from hydpy.core.examples import prepare_full_example_2
>>> hp, pu... | Assign the given value(s) to the given target or base variable.
If the assignment fails, |ChangeItem.update_variable| raises an
error like the following:
>>> from hydpy.core.examples import prepare_full_example_2
>>> hp, pub, TestIO = prepare_full_example_2()
>>> item = SetItem... | entailment |
def update_variables(self) -> None:
"""Assign the current objects |ChangeItem.value| to the values
of the target variables.
We use the `LahnH` project in the following:
>>> from hydpy.core.examples import prepare_full_example_2
>>> hp, pub, TestIO = prepare_full_example_2()
... | Assign the current objects |ChangeItem.value| to the values
of the target variables.
We use the `LahnH` project in the following:
>>> from hydpy.core.examples import prepare_full_example_2
>>> hp, pub, TestIO = prepare_full_example_2()
In the first example, a 0-dimensional |Se... | entailment |
def collect_variables(self, selections) -> None:
"""Apply method |ChangeItem.collect_variables| of the base class
|ChangeItem| and also apply method |ExchangeItem.insert_variables|
of class |ExchangeItem| to collect the relevant base variables
handled by the devices of the given |Selecti... | Apply method |ChangeItem.collect_variables| of the base class
|ChangeItem| and also apply method |ExchangeItem.insert_variables|
of class |ExchangeItem| to collect the relevant base variables
handled by the devices of the given |Selections| object.
>>> from hydpy.core.examples import pr... | entailment |
def update_variables(self) -> None:
"""Add the general |ChangeItem.value| with the |Device| specific base
variable and assign the result to the respective target variable.
>>> from hydpy.core.examples import prepare_full_example_2
>>> hp, pub, TestIO = prepare_full_example_2()
>... | Add the general |ChangeItem.value| with the |Device| specific base
variable and assign the result to the respective target variable.
>>> from hydpy.core.examples import prepare_full_example_2
>>> hp, pub, TestIO = prepare_full_example_2()
>>> from hydpy.models.hland_v1 import FIELD
... | entailment |
def collect_variables(self, selections) -> None:
"""Apply method |ExchangeItem.collect_variables| of the base class
|ExchangeItem| and determine the `ndim` attribute of the current
|ChangeItem| object afterwards.
The value of `ndim` depends on whether the values of the target
va... | Apply method |ExchangeItem.collect_variables| of the base class
|ExchangeItem| and determine the `ndim` attribute of the current
|ChangeItem| object afterwards.
The value of `ndim` depends on whether the values of the target
variable or its time series is of interest:
>>> from ... | entailment |
def yield_name2value(self, idx1=None, idx2=None) \
-> Iterator[Tuple[str, str]]:
"""Sequentially return name-value-pairs describing the current state
of the target variables.
The names are automatically generated and contain both the name of
the |Device| of the respective |V... | Sequentially return name-value-pairs describing the current state
of the target variables.
The names are automatically generated and contain both the name of
the |Device| of the respective |Variable| object and the target
description:
>>> from hydpy.core.examples import prepare... | entailment |
def iso_day_to_weekday(d):
"""
Returns the weekday's name given a ISO weekday number;
"today" if today is the same weekday.
"""
if int(d) == utils.get_now().isoweekday():
return _("today")
for w in WEEKDAYS:
if w[0] == int(d):
return w[1] | Returns the weekday's name given a ISO weekday number;
"today" if today is the same weekday. | entailment |
def is_open(location=None, attr=None):
"""
Returns False if the location is closed, or the OpeningHours object
to show the location is currently open.
"""
obj = utils.is_open(location)
if obj is False:
return False
if attr is not None:
return getattr(obj, attr)
return obj | Returns False if the location is closed, or the OpeningHours object
to show the location is currently open. | entailment |
def is_open_now(location=None, attr=None):
"""
Returns False if the location is closed, or the OpeningHours object
to show the location is currently open.
Same as `is_open` but passes `now` to `utils.is_open` to bypass `get_now()`.
"""
obj = utils.is_open(location, now=datetime.datetime.now())
... | Returns False if the location is closed, or the OpeningHours object
to show the location is currently open.
Same as `is_open` but passes `now` to `utils.is_open` to bypass `get_now()`. | entailment |
def opening_hours(location=None, concise=False):
"""
Creates a rendered listing of hours.
"""
template_name = 'openinghours/opening_hours_list.html'
days = [] # [{'hours': '9:00am to 5:00pm', 'name': u'Monday'}, {'hours...
# Without `location`, choose the first company.
if location:
... | Creates a rendered listing of hours. | entailment |
def prepare_everything(self):
"""Convenience method to make the actual |HydPy| instance runable."""
self.prepare_network()
self.init_models()
self.load_conditions()
with hydpy.pub.options.warnmissingobsfile(False):
self.prepare_nodeseries()
self.prepare_models... | Convenience method to make the actual |HydPy| instance runable. | entailment |
def prepare_network(self):
"""Load all network files as |Selections| (stored in module |pub|)
and assign the "complete" selection to the |HydPy| object."""
hydpy.pub.selections = selectiontools.Selections()
hydpy.pub.selections += hydpy.pub.networkmanager.load_files()
self.update... | Load all network files as |Selections| (stored in module |pub|)
and assign the "complete" selection to the |HydPy| object. | entailment |
def save_controls(self, parameterstep=None, simulationstep=None,
auxfiler=None):
"""Call method |Elements.save_controls| of the |Elements| object
currently handled by the |HydPy| object.
We use the `LahnH` example project to demonstrate how to write
a complete set ... | Call method |Elements.save_controls| of the |Elements| object
currently handled by the |HydPy| object.
We use the `LahnH` example project to demonstrate how to write
a complete set parameter control files. For convenience, we let
function |prepare_full_example_2| prepare a fully functi... | entailment |
def networkproperties(self):
"""Print out some properties of the network defined by the |Node| and
|Element| objects currently handled by the |HydPy| object."""
print('Number of nodes: %d' % len(self.nodes))
print('Number of elements: %d' % len(self.elements))
print('Number of en... | Print out some properties of the network defined by the |Node| and
|Element| objects currently handled by the |HydPy| object. | entailment |
def numberofnetworks(self):
"""The number of distinct networks defined by the|Node| and
|Element| objects currently handled by the |HydPy| object."""
sels1 = selectiontools.Selections()
sels2 = selectiontools.Selections()
complete = selectiontools.Selection('complete',
... | The number of distinct networks defined by the|Node| and
|Element| objects currently handled by the |HydPy| object. | entailment |
def endnodes(self):
"""|Nodes| object containing all |Node| objects currently handled by
the |HydPy| object which define a downstream end point of a network."""
endnodes = devicetools.Nodes()
for node in self.nodes:
for element in node.exits:
if ((element in s... | |Nodes| object containing all |Node| objects currently handled by
the |HydPy| object which define a downstream end point of a network. | entailment |
def variables(self):
"""Sorted list of strings summarizing all variables handled by the
|Node| objects"""
variables = set([])
for node in self.nodes:
variables.add(node.variable)
return sorted(variables) | Sorted list of strings summarizing all variables handled by the
|Node| objects | entailment |
def simindices(self):
"""Tuple containing the start and end index of the simulation period
regarding the initialization period defined by the |Timegrids| object
stored in module |pub|."""
return (hydpy.pub.timegrids.init[hydpy.pub.timegrids.sim.firstdate],
hydpy.pub.timeg... | Tuple containing the start and end index of the simulation period
regarding the initialization period defined by the |Timegrids| object
stored in module |pub|. | entailment |
def open_files(self, idx=0):
"""Call method |Devices.open_files| of the |Nodes| and |Elements|
objects currently handled by the |HydPy| object."""
self.elements.open_files(idx=idx)
self.nodes.open_files(idx=idx) | Call method |Devices.open_files| of the |Nodes| and |Elements|
objects currently handled by the |HydPy| object. | entailment |
def update_devices(self, selection=None):
"""Determines the order, in which the |Node| and |Element| objects
currently handled by the |HydPy| objects need to be processed during
a simulation time step. Optionally, a |Selection| object for defining
new |Node| and |Element| objects can be... | Determines the order, in which the |Node| and |Element| objects
currently handled by the |HydPy| objects need to be processed during
a simulation time step. Optionally, a |Selection| object for defining
new |Node| and |Element| objects can be passed. | entailment |
def methodorder(self):
"""A list containing all methods of all |Node| and |Element| objects
that need to be processed during a simulation time step in the
order they must be called."""
funcs = []
for node in self.nodes:
if node.deploymode == 'oldsim':
... | A list containing all methods of all |Node| and |Element| objects
that need to be processed during a simulation time step in the
order they must be called. | entailment |
def doit(self):
"""Perform a simulation run over the actual simulation time period
defined by the |Timegrids| object stored in module |pub|."""
idx_start, idx_end = self.simindices
self.open_files(idx_start)
methodorder = self.methodorder
for idx in printtools.progressbar... | Perform a simulation run over the actual simulation time period
defined by the |Timegrids| object stored in module |pub|. | entailment |
def pic_inflow_v1(self):
"""Update the inlet link sequence.
Required inlet sequence:
|dam_inlets.Q|
Calculated flux sequence:
|Inflow|
Basic equation:
:math:`Inflow = Q`
"""
flu = self.sequences.fluxes.fastaccess
inl = self.sequences.inlets.fastaccess
flu.inflow = in... | Update the inlet link sequence.
Required inlet sequence:
|dam_inlets.Q|
Calculated flux sequence:
|Inflow|
Basic equation:
:math:`Inflow = Q` | entailment |
def pic_inflow_v2(self):
"""Update the inlet link sequences.
Required inlet sequences:
|dam_inlets.Q|
|dam_inlets.S|
|dam_inlets.R|
Calculated flux sequence:
|Inflow|
Basic equation:
:math:`Inflow = Q + S + R`
"""
flu = self.sequences.fluxes.fastaccess
inl = ... | Update the inlet link sequences.
Required inlet sequences:
|dam_inlets.Q|
|dam_inlets.S|
|dam_inlets.R|
Calculated flux sequence:
|Inflow|
Basic equation:
:math:`Inflow = Q + S + R` | entailment |
def pic_totalremotedischarge_v1(self):
"""Update the receiver link sequence."""
flu = self.sequences.fluxes.fastaccess
rec = self.sequences.receivers.fastaccess
flu.totalremotedischarge = rec.q[0] | Update the receiver link sequence. | entailment |
def pic_loggedrequiredremoterelease_v1(self):
"""Update the receiver link sequence."""
log = self.sequences.logs.fastaccess
rec = self.sequences.receivers.fastaccess
log.loggedrequiredremoterelease[0] = rec.d[0] | Update the receiver link sequence. | entailment |
def pic_loggedrequiredremoterelease_v2(self):
"""Update the receiver link sequence."""
log = self.sequences.logs.fastaccess
rec = self.sequences.receivers.fastaccess
log.loggedrequiredremoterelease[0] = rec.s[0] | Update the receiver link sequence. | entailment |
def pic_loggedallowedremoterelieve_v1(self):
"""Update the receiver link sequence."""
log = self.sequences.logs.fastaccess
rec = self.sequences.receivers.fastaccess
log.loggedallowedremoterelieve[0] = rec.r[0] | Update the receiver link sequence. | entailment |
def update_loggedtotalremotedischarge_v1(self):
"""Log a new entry of discharge at a cross section far downstream.
Required control parameter:
|NmbLogEntries|
Required flux sequence:
|TotalRemoteDischarge|
Calculated flux sequence:
|LoggedTotalRemoteDischarge|
Example:
... | Log a new entry of discharge at a cross section far downstream.
Required control parameter:
|NmbLogEntries|
Required flux sequence:
|TotalRemoteDischarge|
Calculated flux sequence:
|LoggedTotalRemoteDischarge|
Example:
The following example shows that, with each new method... | entailment |
def calc_waterlevel_v1(self):
"""Determine the water level based on an artificial neural network
describing the relationship between water level and water stage.
Required control parameter:
|WaterVolume2WaterLevel|
Required state sequence:
|WaterVolume|
Calculated aide sequence:
... | Determine the water level based on an artificial neural network
describing the relationship between water level and water stage.
Required control parameter:
|WaterVolume2WaterLevel|
Required state sequence:
|WaterVolume|
Calculated aide sequence:
|WaterLevel|
Example:
... | entailment |
def calc_allowedremoterelieve_v2(self):
"""Calculate the allowed maximum relieve another location
is allowed to discharge into the dam.
Required control parameters:
|HighestRemoteRelieve|
|WaterLevelRelieveThreshold|
Required derived parameter:
|WaterLevelRelieveSmoothPar|
Requi... | Calculate the allowed maximum relieve another location
is allowed to discharge into the dam.
Required control parameters:
|HighestRemoteRelieve|
|WaterLevelRelieveThreshold|
Required derived parameter:
|WaterLevelRelieveSmoothPar|
Required aide sequence:
|WaterLevel|
Calc... | entailment |
def calc_requiredremotesupply_v1(self):
"""Calculate the required maximum supply from another location
that can be discharged into the dam.
Required control parameters:
|HighestRemoteSupply|
|WaterLevelSupplyThreshold|
Required derived parameter:
|WaterLevelSupplySmoothPar|
Requ... | Calculate the required maximum supply from another location
that can be discharged into the dam.
Required control parameters:
|HighestRemoteSupply|
|WaterLevelSupplyThreshold|
Required derived parameter:
|WaterLevelSupplySmoothPar|
Required aide sequence:
|WaterLevel|
Cal... | entailment |
def calc_naturalremotedischarge_v1(self):
"""Try to estimate the natural discharge of a cross section far downstream
based on the last few simulation steps.
Required control parameter:
|NmbLogEntries|
Required log sequences:
|LoggedTotalRemoteDischarge|
|LoggedOutflow|
Calculate... | Try to estimate the natural discharge of a cross section far downstream
based on the last few simulation steps.
Required control parameter:
|NmbLogEntries|
Required log sequences:
|LoggedTotalRemoteDischarge|
|LoggedOutflow|
Calculated flux sequence:
|NaturalRemoteDischarge|
... | entailment |
def calc_remotedemand_v1(self):
"""Estimate the discharge demand of a cross section far downstream.
Required control parameter:
|RemoteDischargeMinimum|
Required derived parameters:
|dam_derived.TOY|
Required flux sequence:
|dam_derived.TOY|
Calculated flux sequence:
|Rem... | Estimate the discharge demand of a cross section far downstream.
Required control parameter:
|RemoteDischargeMinimum|
Required derived parameters:
|dam_derived.TOY|
Required flux sequence:
|dam_derived.TOY|
Calculated flux sequence:
|RemoteDemand|
Basic equation:
:... | entailment |
def calc_remotefailure_v1(self):
"""Estimate the shortfall of actual discharge under the required discharge
of a cross section far downstream.
Required control parameters:
|NmbLogEntries|
|RemoteDischargeMinimum|
Required derived parameters:
|dam_derived.TOY|
Required log sequen... | Estimate the shortfall of actual discharge under the required discharge
of a cross section far downstream.
Required control parameters:
|NmbLogEntries|
|RemoteDischargeMinimum|
Required derived parameters:
|dam_derived.TOY|
Required log sequence:
|LoggedTotalRemoteDischarge|
... | entailment |
def calc_requiredremoterelease_v1(self):
"""Guess the required release necessary to not fall below the threshold
value at a cross section far downstream with a certain level of certainty.
Required control parameter:
|RemoteDischargeSafety|
Required derived parameters:
|RemoteDischargeSmoot... | Guess the required release necessary to not fall below the threshold
value at a cross section far downstream with a certain level of certainty.
Required control parameter:
|RemoteDischargeSafety|
Required derived parameters:
|RemoteDischargeSmoothPar|
|dam_derived.TOY|
Required flux... | entailment |
def calc_requiredremoterelease_v2(self):
"""Get the required remote release of the last simulation step.
Required log sequence:
|LoggedRequiredRemoteRelease|
Calculated flux sequence:
|RequiredRemoteRelease|
Basic equation:
:math:`RequiredRemoteRelease = LoggedRequiredRemoteRelease`... | Get the required remote release of the last simulation step.
Required log sequence:
|LoggedRequiredRemoteRelease|
Calculated flux sequence:
|RequiredRemoteRelease|
Basic equation:
:math:`RequiredRemoteRelease = LoggedRequiredRemoteRelease`
Example:
>>> from hydpy.models.da... | entailment |
def calc_allowedremoterelieve_v1(self):
"""Get the allowed remote relieve of the last simulation step.
Required log sequence:
|LoggedAllowedRemoteRelieve|
Calculated flux sequence:
|AllowedRemoteRelieve|
Basic equation:
:math:`AllowedRemoteRelieve = LoggedAllowedRemoteRelieve`
... | Get the allowed remote relieve of the last simulation step.
Required log sequence:
|LoggedAllowedRemoteRelieve|
Calculated flux sequence:
|AllowedRemoteRelieve|
Basic equation:
:math:`AllowedRemoteRelieve = LoggedAllowedRemoteRelieve`
Example:
>>> from hydpy.models.dam imp... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.