Calculates the group delay at the real frequency f (Fourier) from the univariate function 'LaplaceExpr' of the Laplace variable. If ini.hz == true, the Laplace variable will be replaced with 2*sp.pi*sp.I*ini.frequency. If ini.hz == False, the Laplace variable will be replaced
(LaplaceExpr, f, delta=10**(-ini.disp))
| 982 | return phase |
| 983 | |
| 984 | def _delayFunc_f(LaplaceExpr, f, delta=10**(-ini.disp)): |
| 985 | """ |
| 986 | Calculates the group delay at the real frequency f (Fourier) from the |
| 987 | univariate function 'LaplaceExpr' of the Laplace variable. |
| 988 | |
| 989 | If ini.hz == true, the Laplace variable will be replaced with |
| 990 | 2*sp.pi*sp.I*ini.frequency. |
| 991 | |
| 992 | If ini.hz == False, the Laplace variable will be replaced with |
| 993 | sp.I*ini.frequency. |
| 994 | |
| 995 | :param LaplaceExpr: Univariate function of the Laplace variable. |
| 996 | :type LaplaceExpr: sympy.Expr |
| 997 | |
| 998 | :param f: Frequency value (*float*), or a numpy array with frequency values |
| 999 | (*float*). |
| 1000 | |
| 1001 | :return: Group delay at the specified frequency, or list with group delays |
| 1002 | at the specified frequencies. |
| 1003 | |
| 1004 | :rtype: float, numpy.array |
| 1005 | """ |
| 1006 | if type(f) == list: |
| 1007 | f = np.array(f) |
| 1008 | if ini.hz == True: |
| 1009 | data = LaplaceExpr.xreplace({ini.laplace: 2*sp.pi*sp.I*ini.frequency}) |
| 1010 | else: |
| 1011 | data = LaplaceExpr.xreplace({ini.laplace: sp.I*ini.frequency}) |
| 1012 | if ini.frequency in data.atoms(sp.Symbol): |
| 1013 | data = sp.N(normalizeRational(data, ini.frequency)) |
| 1014 | try: |
| 1015 | func = sp.lambdify(ini.frequency, data, ini.lambdify) |
| 1016 | angle1 = np.angle(func(f)) |
| 1017 | angle2 = np.angle(func(f*(1+delta))) |
| 1018 | except BaseException: |
| 1019 | angle1 = np.array([np.angle(data.xreplace({ini.frequency: f[i]})) |
| 1020 | for i in range(len(f))]) |
| 1021 | angle2 = np.array( |
| 1022 | [np.angle(data.xreplace({ini.frequency: f[i]*(1+delta)})) for i in range(len(f))]) |
| 1023 | try: |
| 1024 | angle1 = np.unwrap(angle1) |
| 1025 | angle2 = np.unwrap(angle2) |
| 1026 | except BaseException: |
| 1027 | pass |
| 1028 | delay = (angle1 - angle2)/delta/f |
| 1029 | if ini.hz == True: |
| 1030 | delay = delay/2/np.pi |
| 1031 | else: |
| 1032 | delay = [0 for i in range(len(f))] |
| 1033 | return delay |
| 1034 | |
| 1035 | def _doCDSint(noiseResult, tau, fmin, fmax, method, points=0): |
| 1036 | """ |
no test coverage detected