Returns the integral from ini.frequency = f_min to ini.frequency = f_max, of a noise spectrum after multiplying it with (2*sin(pi*ini.frequency*tau))^2 :param noiseResult: sympy expression of a noise density spectrum in V^2/Hz or A^2/Hz :type noiseResult: sympy.Expr, sympy.Symbol,
(noiseResult, tau, fmin, fmax, method, points=0)
| 1033 | return delay |
| 1034 | |
| 1035 | def _doCDSint(noiseResult, tau, fmin, fmax, method, points=0): |
| 1036 | """ |
| 1037 | Returns the integral from ini.frequency = f_min to ini.frequency = f_max, |
| 1038 | of a noise spectrum after multiplying it with (2*sin(pi*ini.frequency*tau))^2 |
| 1039 | |
| 1040 | :param noiseResult: sympy expression of a noise density spectrum in V^2/Hz or A^2/Hz |
| 1041 | :type noiseResult: sympy.Expr, sympy.Symbol, int or float |
| 1042 | |
| 1043 | :param tau: Time between two samples |
| 1044 | :type tau: sympy.Expr, sympy.Symbol, int or float |
| 1045 | |
| 1046 | :param fmin: Lower limit of the integral |
| 1047 | :type fmin: sympy.Expr, sympy.Symbol, int or float |
| 1048 | |
| 1049 | :param fmax: Upper limit of the integral |
| 1050 | :type fmax: sympy.Expr, sympy.Symbol, int or float |
| 1051 | |
| 1052 | - "auto": automatic selection of integration method |
| 1053 | - "symbolic": forces symbolic integration |
| 1054 | - "scipy": numeric integration using scipy.integrate.quad |
| 1055 | - "log": numeric integration using numpy.trapezoid with a |
| 1056 | logarithmic frequency sweep from f_min to f_max |
| 1057 | and the number of points set by points |
| 1058 | - "lin": numeric integration using numpy.trapezoid with a |
| 1059 | linear frequency sweep from fmin to fmax |
| 1060 | and dx=(fmax-fmin)/points |
| 1061 | - "list": numeric integration using numpy.trapezoid with frequency |
| 1062 | points taken from points. |
| 1063 | |
| 1064 | Defaults to 'auto' |
| 1065 | |
| 1066 | :type method: str |
| 1067 | |
| 1068 | :param points: Number of frequency points for integration for method="lin" |
| 1069 | and method="log", or a list with points. Defaults to 0. |
| 1070 | If type(points) == list f_min, and f_max will be ignored. |
| 1071 | :type points: int, list |
| 1072 | |
| 1073 | :return: integral of the spectrum from f_min to f_max after corelated double sampling |
| 1074 | :rtype: sympy.Expr, sympy.Symbol, int or float |
| 1075 | """ |
| 1076 | # method is determined by parent routine |
| 1077 | _phi = sp.Symbol('_phi', positive=True) |
| 1078 | lim_l = sp.simplify(fmin*tau*sp.pi) |
| 1079 | lim_u = sp.simplify(fmax*tau*sp.pi) |
| 1080 | noiseResult *= ((2*sp.sin(sp.pi*ini.frequency*tau)))**2 |
| 1081 | noiseResult = noiseResult.xreplace({ini.frequency: _phi/tau/sp.pi}) |
| 1082 | if method == "symbolic": |
| 1083 | try: |
| 1084 | noiseResult = assumePosParams(noiseResult) |
| 1085 | noiseResultCDSint = sp.integrate( |
| 1086 | sp.simplify(noiseResult/sp.pi/tau), (_phi, lim_l, lim_u)) |
| 1087 | except: |
| 1088 | print("ERROR: cannot evaluate integral symbolically.") |
| 1089 | noiseResultCDSint = None |
| 1090 | else: |
| 1091 | # Use numeric integration |
| 1092 | noise_spectrum = sp.lambdify( _phi, sp.N(noiseResult/sp.pi/tau)) |
no test coverage detected