hose
timed_float TPT.hose(timed_float expr, timed_float ref, timed_float xtol, timed_float ytol, [int options])
This function generates bounds around the time dependent expression ref(t) and
checks if the expression expr(t) is encapsulated within these bounds. The hose
consists of all the rectangles with the size xtol
(time tolerance) and
ytol
(value tolerance) around every sample point of the reference
ref(t).
The result for a time t is the smallest delta between expr(t) and the hose around
ref(t). When the signal expr(t) is covered by the hose, the result is
0.0, otherwise the smallest (signed) delta between expr(t) and the reference hose
ref(t) will be returned.
If all of the involved values are NaN, the result is 0.0. If some but not all of the involved
values are NaN, the result is {@link #DEVIATION_TO_NAN}
The options parameter specifies the behavior of the hose function:
TPT.HOSE_NORMAL
: will take the ytol (value tolerance) as an absolute tolerance (default)TPT.HOSE_RELATIVE
: will take the ytol (value tolerance) as a relative tolerance in %, following the formula: ((expr(t) - ref) / ref)TPT.HOSE_IGNORE_TIME_BOUNDARIES
: If set the result signal will always be 0.0 at the current context interval boundaries. More precisely, in the intervals [0s, xtol] and [TPT.getEndTime()-xtol, TPT.getEndTime()].TPT.STRICT
: If set the result signal will be 'undefined' at any point in time t where the signalexpr(t)
is undefined too. Otherwise (non-strict), the result signal will 0.0 at those points.TPT.HOSE_RELATIVE|TPT.HOSE_IGNORE_TIME_BOUNDARIES|TPT.STRICT
: Combination of relative value tolerance, ignoring time boundaries, and strict mode can be specified using bit-or.
The figure below shows an example of the hose function: The red signal is expr(t) and the blue signal with dots is the reference signal ref(t). The hose function is built from rectangles depicted in gray. The hose function returns:
- 0.0 when the original signal expr(t) is inside the gray boxes
- the difference between the border of the boxes and the original signal when the signal is outside of the boxes (see red dotted line).
Parameters:
expr Timed float expression that shall be checked
ref Reference timed float expression defining the hose
xtol X tolerance (time tolerance) of hose. (For sampled systems xtol must be at least the step size to be relevant.)
ytol Y tolerance of hose
[options]
(optional)
option settings. Can be one of (or a bit-or combination of)
TPT.HOSE_IGNORE_TIME_BOUNDARIES
, or
This parameter is optional. If omitted, the default is
TPT.HOSE_NORMAL
.
Returns:
Delta between the signal expr
and the hose around
ref
Examples:
# hose function example signal = TPT.DoubleX(); # original ref = TPT.DoubleX(); # reference signal res_ohne = TPT.DoubleX(); res_mit = TPT.DoubleX(); signal(t) := (t); during TPT.regexp([t>=0.5s]): ref(t) := signal(t-0.1); # without ignore time boundaries option res_ohne(t) := TPT.hose(signal(t), ref(t), 0.11, 0); # with ignore time boundaries option res_mit(t) := TPT.hose(signal(t), ref(t), 0.11, 0, TPT.HOSE_IGNORE_TIME_BOUNDARIES);