Python Program to process experimental data received from Data Acquisition System

Following is the data captured from an experimental setup involving spring , mass and damper system. Accelerometer was used to capture the vibrations generated by disturbing spring-mass-damper system. To capture the data Lab-Jack i.e. data acquisition system was used. Following csv file was created from the .dat file given as output of Lab-Jack system. Save following sample data of first 100 lines as a .csv file in the same folder where program file is saved. 


Time,v0,y00,1.313167,1.3131670.002,1.308109,1.3081090.004,1.313167,1.3131670.006,1.308109,1.3081090.008,1.303051,1.3030510.01,1.303051,1.3030510.012,1.303051,1.3030510.014,1.292935,1.2929350.016,1.297993,1.2979930.018,1.292935,1.2929350.02,1.297993,1.2979930.022,1.287877,1.2878770.024,1.287877,1.2878770.026,1.292935,1.2929350.028,1.282819,1.2828190.03,1.287877,1.2878770.032,1.277761,1.2777610.034,1.287877,1.2878770.036,1.277761,1.2777610.038,1.282819,1.2828190.04,1.282819,1.2828190.042,1.267645,1.2676450.044,1.272703,1.2727030.046,1.272703,1.2727030.048,1.267645,1.2676450.05,1.262587,1.2625870.052,1.267645,1.2676450.054,1.262587,1.2625870.056,1.257529,1.2575290.058,1.257529,1.2575290.06,1.257529,1.2575290.062,1.257529,1.2575290.064,1.257529,1.2575290.066,1.262587,1.2625870.068,1.262587,1.2625870.07,1.262587,1.2625870.072,1.262587,1.2625870.074,1.252471,1.2524710.076,1.262587,1.2625870.078,1.267645,1.2676450.08,1.267645,1.2676450.082,1.267645,1.2676450.084,1.267645,1.2676450.086,1.262587,1.2625870.088,1.267645,1.2676450.09,1.267645,1.2676450.092,1.267645,1.2676450.094,1.267645,1.2676450.096,1.277761,1.2777610.098,1.277761,1.2777610.1,1.272703,1.2727030.102,1.272703,1.2727030.104,1.282819,1.2828190.106,1.277761,1.2777610.108,1.287877,1.2878770.11,1.282819,1.2828190.112,1.287877,1.2878770.114,1.287877,1.2878770.116,1.292935,1.2929350.118,1.292935,1.2929350.12,1.297993,1.2979930.122,1.292935,1.2929350.124,1.292935,1.2929350.126,1.297993,1.2979930.128,1.303051,1.3030510.13,1.303051,1.3030510.132,1.308109,1.3081090.134,1.303051,1.3030510.136,1.313167,1.3131670.138,1.308109,1.3081090.14,1.313167,1.3131670.142,1.313167,1.3131670.144,1.313167,1.3131670.146,1.318225,1.3182250.148,1.328341,1.3283410.15,1.318225,1.3182250.152,1.333399,1.3333990.154,1.338457,1.3384570.156,1.328341,1.3283410.158,1.333399,1.3333990.16,1.338457,1.3384570.162,1.343515,1.3435150.164,1.348573,1.3485730.166,1.348573,1.3485730.168,1.358689,1.3586890.17,1.353631,1.3536310.172,1.363747,1.3637470.174,1.363747,1.3637470.176,1.368805,1.3688050.178,1.363747,1.3637470.18,1.373863,1.3738630.182,1.383979,1.3839790.184,1.373863,1.3738630.186,1.378921,1.3789210.188,1.389037,1.3890370.19,1.368805,1.3688050.192,1.383979,1.3839790.194,1.394095,1.3940950.196,1.389037,1.389037

#Python Program to process above csv data file and print Amplitude v/s Time plot on the output screen

import pandas

import numpy as np

import matplotlib.pyplot as plt

import statistics as st

#read the csv data file and assign df as the object to access the same

df = pandas.read_csv("expt6.csv")

#as per the column heads assign them to two different lists

t = df['Time']

y = df['v0']

#using stats module find the mean of amplitude 

m0 = st.mean(y)

#print the value of time and amplitude

print(t)

print(y)

#plot the amplitude v/s time plot

plt.plot(t,y,color='brown')

plt.axhline(y=m0,color='black',ls='-.')

plt.xlabel('Time in Seconds')

plt.ylabel('Amplitude')

plt.title('Amplitude v/s Time Plot')

plt.show()