plot.py
Go to the documentation of this file.
00001 import numpy as np, math
00002 import pylab as pl
00003 
00004 ar = [[  0, 104 ],
00005       [  1, 104 ],
00006       [  2, 104 ],
00007       [  3, 104 ],
00008       [  4, 104 ],
00009       [  8, 100 ],
00010       [  9,  97 ],
00011       [ 10,  96 ],
00012       [ 11,  95 ],
00013       [ 12,  93 ],
00014       [ 13,  91 ],
00015       [ 14,  90 ],
00016       [ 15,  89 ],
00017       [ 16,  87 ],
00018       [ 17,  85 ],
00019       [ 18,  84 ],
00020       [ 19,  83 ],
00021       [ 20,  81 ],
00022       [ 21,  80 ],
00023       [ 22,  78 ],
00024       [ 23,  77 ],
00025       [ 24,  74 ],
00026       [ 25,  73 ],
00027       [ 26,  71 ]]
00028 
00029 ar = np.array( ar ).T
00030 ar[0] *= -1.0   # Change attenuation to be negative.
00031 
00032 # Linear least squares
00033 a = ar[0,4:] # Start at attn = -4 to avoid including saturation region.
00034 a = np.column_stack([ a, np.ones(len(a)) ])
00035 b = ar[1,4:]
00036 m,b = np.linalg.lstsq( a, b )[0]
00037 
00038 xs = np.linspace( -27, -3, 100 )
00039 ys = xs * m + b
00040 
00041 if __name__ == '__main__':
00042     
00043     pl.plot( ar[0], ar[1], 'bo', linewidth=2.0 )
00044     pl.hold( True )
00045 
00046     pl.plot( xs, ys, 'g-', linewidth = 2.0 )
00047 
00048     pl.xlabel( 'Attenuator Setting (dB)')
00049     pl.ylabel( 'RSSI' )
00050     pl.legend([ 'Measurements', 'Linear Fit' ], loc='upper left')
00051 
00052     pl.savefig( 'Attenuator_RSSI_measurements.png' )               
00053     pl.show()
00054 


rfid_datacapture
Author(s): Travis Deyle
autogenerated on Wed Nov 27 2013 12:11:16