print "A = %g, \t B = %g, \t C = %g" % (A, B, C)
vib_plot(deflection_bits, freq_axis, power, A, B, C,
- plotVerbose=plotVerbose)
+ minFreq, maxFreq, plotVerbose=plotVerbose)
# Our A is in uV**2, so convert back to Volts**2
return lorentzian_area(A,B,C) * 1e-12
print "guesses : %g, %g, %g" % (A_guess, B_guess, C_guess)
if PLOT_GUESSED_LORENTZIAN:
vib_plot(None, freq_axis, psd_data, A_guess, B_guess, C_guess,
- plotVerbose=True)
+ minFreq, maxFreq, plotVerbose=True)
# fit Lorentzian using Gnuplot's 'fit' command
g = GnuplotBiDir.Gnuplot()
return data
def vib_plot(deflection_bits, freq_axis, power, A, B, C,
- plotVerbose=True) :
+ minFreq=None, maxFreq=None, plotVerbose=True) :
"""
If plotVerbose or config.PYLAB_VERBOSE == True, plot 3 subfigures:
Time series (Vphoto vs sample index) (show any major drift events),
axes = common._pylab.subplot(111)
common._pylab.hold(False)
common._pylab.semilogy(freq_axis, power, 'r.-')
- fitdata = C / ((A**2-freq_axis**2)**2 + (B*freq_axis)**2)
+ common._pylab.hold(True)
xmin,xmax = axes.get_xbound()
ymin,ymax = axes.get_ybound()
- common._pylab.hold(True)
+
+ if minFreq is not None and maxFreq is not None:
+ # highlight the region we're fitting in
+ common._pylab.axvspan(minFreq, maxFreq, facecolor='g', alpha=0.1,
+ zorder = -1)
+
+ fitdata = C / ((A**2-freq_axis**2)**2 + (B*freq_axis)**2)
common._pylab.plot(freq_axis, fitdata, 'b-');
common._pylab.hold(False)
axes.axis([xmin,xmax,ymin,ymax])