Reputation: 15
import os
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import scipy
from scipy import signal
def get_sig_from_txt(directory_path, filename):
with open(directory_path + '\\' + filename) as f:
content = f.readlines()
content = [int(x.strip()) for x in content]
return np.array(content)
for filename in dirr:
signal = get_sig_from_txt(path, filename)
idx_peak = signal.find_peaks_cwt(signal, np.arange(1, 16))
I get the error :AttributeError: 'numpy.ndarray' object has no attribute 'find_peaks_cwt' Process. What can I do?
Upvotes: 0
Views: 1260
Reputation: 95948
You've shadowed your signal
variable, which references the scipy.signal
module.
Just assign the result of your function call to a different name:
for filename in dirr:
sig = get_sig_from_txt(path, filename)
idx_peak = signal.find_peaks_cwt(sig, np.arange(1, 16))
Upvotes: 1