fixed bug in new smoothing algorithm
This commit is contained in:
parent
9aaa63512c
commit
ea0edd2817
@ -136,7 +136,7 @@ def smoothSpectralData(freq, M, sw: SmoothingWidth,
|
|||||||
x0 = 1 if freq[0] == 0 else 0 # Skip first data point if zero frequency
|
x0 = 1 if freq[0] == 0 else 0 # Skip first data point if zero frequency
|
||||||
Psm[0] = P[0] # Reuse old value in case first data..
|
Psm[0] = P[0] # Reuse old value in case first data..
|
||||||
# ..point is skipped. Not plotted any way.
|
# ..point is skipped. Not plotted any way.
|
||||||
P[-1] = P[-2] # Last data point (Nyquist f) often invalid
|
P[-1] = P[-2] # Last data point (Nyquist f) can be invalid
|
||||||
|
|
||||||
# Loop through data points
|
# Loop through data points
|
||||||
for x in range(x0, L):
|
for x in range(x0, L):
|
||||||
@ -165,6 +165,10 @@ def smoothSpectralData(freq, M, sw: SmoothingWidth,
|
|||||||
xl = bisect.bisect_left(freq, fl) # index corresponding to fl
|
xl = bisect.bisect_left(freq, fl) # index corresponding to fl
|
||||||
xu = bisect.bisect_left(freq, fu)
|
xu = bisect.bisect_left(freq, fu)
|
||||||
|
|
||||||
|
# Guarantee window length of at least 1
|
||||||
|
if xu - xl <= 0:
|
||||||
|
xl = xu - 1
|
||||||
|
|
||||||
# Calculate window
|
# Calculate window
|
||||||
g = np.zeros(xu-xl)
|
g = np.zeros(xu-xl)
|
||||||
for n, xi in enumerate(range(xl, xu)):
|
for n, xi in enumerate(range(xl, xu)):
|
||||||
|
Loading…
Reference in New Issue
Block a user