Ошибка с именем «b» не определена для scipy.signal.butter. Что случилось?

#filter #scipy #butterworth

Вопрос:

Вчера он работал, но теперь отказывается работать. В код не было внесено никаких изменений. Что случилось?

 # Obtain filter coefficients here.
lowcut = 4400
highcut = 39700
order = 2
nyq = 0.5 * sampling_freq
def butter_bandstop_filter(data, lowcut, highcut, sampling_freq, order):
    low = lowcut / nyq
    high = highcut / nyq
    b, a = scipy.signal.butter(order, [low, high], btype='bandstop', analog=True, output='ba')
    y = lfilter(b, a, data)
    return y
signal_filtered = butter_bandstop_filter(sig, lowcut, highcut, sampling_freq, order)
# Use the filter here.
filtered = signal.filtfilt(b, a, sig)
 

NameError: name 'b' is not defined

Комментарии:

1. b и a находится в локальной области внутри butter_bandstop_filter .