From 24deacae2e8c451f78c4aaa594c73b56ca26fb1d Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 26 Nov 2008 16:45:54 -0500 Subject: [PATCH] Plot span of fitted frequencies in vib_anayze.py. --- calibcant/vib_analyze.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/calibcant/vib_analyze.py b/calibcant/vib_analyze.py index cfa2c3e..4c28435 100755 --- a/calibcant/vib_analyze.py +++ b/calibcant/vib_analyze.py @@ -98,7 +98,7 @@ def vib_analyze(deflection_bits, freq, minFreq=500, maxFreq=7000, 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 @@ -182,7 +182,7 @@ def fit_psd(freq_axis, psd_data, minFreq=500, maxFreq=7000) : 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() @@ -248,7 +248,7 @@ def vib_load(datafile=None) : 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), @@ -290,10 +290,16 @@ def vib_plot(deflection_bits, freq_axis, power, A, B, C, 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]) -- 2.26.2