Calculates the phase angle 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)
| 929 | return result |
| 930 | |
| 931 | def _phaseFunc_f(LaplaceExpr, f): |
| 932 | """ |
| 933 | Calculates the phase angle at the real frequency f (Fourier) from the |
| 934 | univariate function 'LaplaceExpr' of the Laplace variable. |
| 935 | |
| 936 | If ini.hz == true, the Laplace variable will be replaced with |
| 937 | 2*sp.pi*sp.I*ini.frequency. |
| 938 | |
| 939 | If ini.hz == False, the Laplace variable will be replaced with |
| 940 | sp.I*ini.frequency. |
| 941 | |
| 942 | :param LaplaceExpr: Univariate function of the Laplace variable. |
| 943 | :type LaplaceExpr: sympy.Expr |
| 944 | |
| 945 | :param f: Frequency value (*float*), or a numpy array with frequency values |
| 946 | (*float*). |
| 947 | |
| 948 | :return: Angle at the specified frequency, or list with angles at |
| 949 | the specified frequencies. |
| 950 | |
| 951 | :rtype: float, numpy.array |
| 952 | """ |
| 953 | LaplaceExpr = normalizeRational(sp.N(LaplaceExpr)) |
| 954 | if type(f) == list: |
| 955 | f = np.array(f) |
| 956 | if ini.hz == True: |
| 957 | data = LaplaceExpr.xreplace({ini.laplace: 2*sp.pi*sp.I*ini.frequency}) |
| 958 | else: |
| 959 | data = LaplaceExpr.xreplace({ini.laplace: sp.I*ini.frequency}) |
| 960 | data = sp.N(normalizeRational(data, ini.frequency)) |
| 961 | if ini.frequency in data.atoms(sp.Symbol): |
| 962 | try: |
| 963 | func = sp.lambdify(ini.frequency, data, ini.lambdify) |
| 964 | phase = np.angle(func(f)) |
| 965 | except BaseException: |
| 966 | phase = [] |
| 967 | for i in range(len(f)): |
| 968 | try: |
| 969 | phase.append(np.angle(data.xreplace({ini.frequency: f[i]}))) |
| 970 | except BaseException: |
| 971 | phase.append(0) |
| 972 | elif data >= 0: |
| 973 | phase = [0 for i in range(len(f))] |
| 974 | elif data < 0: |
| 975 | phase = [np.pi for i in range(len(f))] |
| 976 | try: |
| 977 | phase = np.unwrap(phase) |
| 978 | except BaseException: |
| 979 | pass |
| 980 | if ini.hz: |
| 981 | phase = phase * 180/np.pi |
| 982 | return phase |
| 983 | |
| 984 | def _delayFunc_f(LaplaceExpr, f, delta=10**(-ini.disp)): |
| 985 | """ |
no test coverage detected