Coverage for D:\Ralf Gerlich\git\modypy\modypy\blocks\discont.py : 0%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""Blocks for modelling discontinuities"""
2from functools import partial
4import numpy as np
6from modypy.model import Signal
9def _saturation_function(input_signal, lower_limit, upper_limit, data):
10 """Function to return a saturated signal"""
12 return np.minimum(np.maximum(input_signal(data), lower_limit), upper_limit)
15def saturation(input_signal, lower_limit, upper_limit):
16 """
17 Limit a signal to lower and upper limits.
19 Args:
20 input_signal: The input signal
21 lower_limit: The lower limit
22 upper_limit: The upper limit
24 Returns:
25 The output signal with the limited value
26 """
28 return Signal(shape=input_signal.shape,
29 value=partial(_saturation_function,
30 input_signal,
31 lower_limit,
32 upper_limit))