%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
fname = 'empty_fs10hz_cleaned.csv'
empty = pd.read_csv(fname,header=None,names=['datetime','adc'],parse_dates=[0])
empty = empty.set_index('datetime')
empty.describe()
empty.plot()
plt.title("String Pot Extended")
plt.ylabel('ADC Value')
plt.xlabel('Elapsed Time')
fname = 'full_fs10hz_cleaned.csv'
full = pd.read_csv(fname,header=None,names=['datetime','adc'],parse_dates=[0])
full = full.set_index('datetime')
full.describe()
full.plot()
plt.title("String Pot Retracted")
plt.ylabel('ADC Value')
plt.xlabel('Elapsed Time')
#Get the transfer function
percent = np.array([0,100])
adc = np.array([empty.adc.max(),full.adc.max()])
np.diff(adc)
m = (np.diff(percent) / np.diff(adc))
b = (percent[0]- m*adc[0])
print(f"percent full = {m[0]}*x + {b[0]}")
fname = 'moving_fs10hz_cleaned.csv'
mov = pd.read_csv(fname,header=None,names=['datetime','bname','calculated position','adcname','adc'],parse_dates=[0])
mov = mov.set_index('datetime')
mov.plot(subplots=True, figsize=[11,8])
plt.suptitle("Moving After Calibration")
plt.xlabel('Elapsed Time');