Mar-01-2018, 05:41 PM
Hello,
I am trying to filter fourier amplitude using Savitzky-Golay Filter. Can you please help me with the the following code. I get an error saying "TypeError: '_io.TextIOWrapper' object is not subscriptable". The file is attached Thank you
I am trying to filter fourier amplitude using Savitzky-Golay Filter. Can you please help me with the the following code. I get an error saying "TypeError: '_io.TextIOWrapper' object is not subscriptable". The file is attached Thank you
import numpy as np import plotly.plotly as py import plotly.graph_objs as go import numpy as np import pandas as pd import scipy from scipy import signal outputFile=r'C:\Users\muhsi\Desktop\data' directory=outputFile+'\\data.txt' frequency=[] amplitude=[] file=open(directory,'r') file.readline() data=file.readline().split() frequency=file[1] amplitude=file[2] trace1 = go.Scatter( x=frequency, y= signal.savgol_filter(amplitude, 53, 3), mode='markers', marker=dict( size=6, color='#C190F0', symbol='triangle' ), name='Savitzky-Golay' ) layout = go.Layout( showlegend=True ) data = [trace1] fig = go.Figure(data=data, layout=layout) py.iplot(fig, filename='smoothing-savitzky-golay-filter')
Attached Files