Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Savitzky-Golay Filter
#1
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

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

.txt   data.txt (Size: 197.96 KB / Downloads: 63)
Reply


Messages In This Thread
Savitzky-Golay Filter - by muhsin - Mar-01-2018, 05:41 PM
RE: Savitzky-Golay Filter - by ka06059 - Mar-02-2018, 02:04 AM
RE: Savitzky-Golay Filter - by muhsin - Mar-02-2018, 02:10 AM
RE: Savitzky-Golay Filter - by ka06059 - Mar-02-2018, 11:15 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020