0
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?

0

1 Answer 1

1

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))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.