Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- import plotly
- import plotly.offline as offline
- import plotly.graph_objs as go
- import scipy
- import numpy
- time = []
- voltage = []
- data_file = open("data_0.dat")
- with data_file as csvfile:
- reader = csv.reader(data_file, delimiter = ",")
- for row in reader:
- time.append(row[0])
- voltage.append(row[1])
- N = len(voltage)
- #rate = 2500
- array = numpy.array(voltage)
- xplot = time
- yplot = numpy.fft.fft(voltage)
- freq = numpy.fft.fftfreq(N, .01923)
- mask = freq > 0
- trace_accel = go.Scatter(
- x = freq[mask],
- y = numpy.abs(yplot[mask]),
- name = 'Ampl vs Freq',
- line = dict(
- color = ('rgb(255,0,0)'),
- width = 1))
- data = [trace_accel]
- layout = dict(title = "Amplitude vs. Frequency",
- xaxis = dict(title = 'Frequency (Hz)'),
- yaxis = dict(title = 'Amplitude'),
- font = dict(size=16))
- fig = dict(data=data, layout=layout)
- offline.plot(fig,
- image_height='1275', image_width='1650', image='png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement