Commit 3331b8eb authored by Hannah Middleton's avatar Hannah Middleton
Browse files

adding command line argument

parent ac1c6cef
'''
plots results of ARLS with fake data
'''
import numpy as np
import matplotlib
#matplotlib.use('Agg')
import matplotlib.pyplot as plt
import scipy.fftpack
import argparse
#time prim ref filt#
data = np.genfromtxt('../../ARLS/here/filteredData.dat', names=True)
injectedData = np.genfromtxt('../../makeFakeData/data.dat',names=True)
injected = injectedData['injected']
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('--results', '-r', dest='pathToResultsFile', type=str,
required=True, help='The path to the results file to be plotted')
args = parser.parse_args()
import scipy.fftpack
print (data['prim'])
# read in the data
data = np.genfromtxt(args.pathToResultsFile, names=True)
# make FFTs (real)
pf = scipy.fftpack.rfft(data['prim'])
ff = scipy.fftpack.rfft(data['filt'])
rf = scipy.fftpack.rfft(data['ref'])
injf = scipy.fftpack.rfft(injected)
T = data['time'][1]-data['time'][0]
sampleRate = int(1./T)
......@@ -25,16 +33,17 @@ N=len(data['time'])
xf = scipy.fftpack.rfftfreq(N, 1/sampleRate)
plt.axvline(59.995)
plt.plot(xf,np.abs(pf),alpha=0.5)
plt.plot(xf,np.abs(ff),alpha=0.5)
plt.xlim(59.5,60.5)
#plt.plot(xf,np.abs(rf),alpha=0.5)
#plt.plot(xf,np.abs(injf),ls='--')
# plotting FFT
#plt.axvline(59.999, alpha=0.2, ls='--')
plt.plot(xf,np.abs(pf),alpha=0.5,label='primary')
plt.plot(xf,np.abs(ff),alpha=0.5,label='filtered',ls='--')
plt.xlim(59.9,60.1)
plt.ylabel('FFT')
plt.xlabel('Frequency (Hz)')
plt.legend()
plt.show()
#
plt.clf()
plt.plot(xf, np.abs(pf)-np.abs(ff))
plt.xlim(59.5,60.5)
plt.xlim(59.9,60.1)
plt.show()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment