import data_logger
import FFT_tools
+PLOT_GUESSED_LORENTZIAN=False
+
def vib_analyze_naive(deflection_bits, Vphoto_in2V=config.Vphoto_in2V,
zeroVphoto_bits=config.zeroVphoto_bits) :
"""
# For some values of A and B (non-underdamped), W is imaginary or negative.
if config.TEXT_VERBOSE :
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)
# fit Lorentzian using Gnuplot's 'fit' command
g = GnuplotBiDir.Gnuplot()
FFTed Vphoto data (Vphoto vs Frequency) (show major noise components).
"""
if plotVerbose or config.PYLAB_VERBOSE :
- print "plotting"
common._import_pylab()
common._pylab.figure(config.BASE_FIGNUM+2)
- # plot time series
- common._pylab.subplot(311)
- common._pylab.hold(False)
- common._pylab.plot(deflection_bits, 'r.')
- common._pylab.title("free oscillation")
-
- # plot histogram distribution and gaussian fit
- common._pylab.subplot(312)
- common._pylab.hold(False)
- n, bins, patches = \
- common._pylab.hist(deflection_bits, bins=30,
- normed=1, align='center')
- gaus = numpy.zeros((len(bins),), dtype=numpy.float)
- mean = deflection_bits.mean()
- std = deflection_bits.std()
- pi = numpy.pi
- exp = numpy.exp
- for i in range(len(bins)) :
- gaus[i] = (2*pi)**(-.5)/std * exp(-0.5*((bins[i]-mean)/std)**2)
- common._pylab.hold(True)
- common._pylab.plot(bins, gaus, 'r-');
- common._pylab.hold(False)
-
- # plot FFTed data
- axes = common._pylab.subplot(313)
+ if deflection_bits != None:
+ # plot time series
+ common._pylab.subplot(311)
+ common._pylab.hold(False)
+ common._pylab.plot(deflection_bits, 'r.')
+ common._pylab.title("free oscillation")
+
+ # plot histogram distribution and gaussian fit
+ common._pylab.subplot(312)
+ common._pylab.hold(False)
+ n, bins, patches = \
+ common._pylab.hist(deflection_bits, bins=30,
+ normed=1, align='center')
+ gaus = numpy.zeros((len(bins),), dtype=numpy.float)
+ mean = deflection_bits.mean()
+ std = deflection_bits.std()
+ pi = numpy.pi
+ exp = numpy.exp
+ for i in range(len(bins)) :
+ gaus[i] = (2*pi)**(-.5)/std * exp(-0.5*((bins[i]-mean)/std)**2)
+ common._pylab.hold(True)
+ common._pylab.plot(bins, gaus, 'r-');
+ common._pylab.hold(False)
+
+ # plot FFTed data
+ axes = common._pylab.subplot(313)
+ else:
+ # use a nice big subplot just for the FFTed data
+ 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)
axes.axis([xmin,xmax,ymin,ymax])
common._flush_plot()
- if (plotVerbose or config.GNUPLOT_VERBOSE): # TODO: cleanup and test
+ if (plotVerbose or config.GNUPLOT_VERBOSE) and False: # TODO: cleanup and test
# write all the ft data now
fd = file(datafilename, 'w')
for i in range(len(freq_axis)) :
parser.add_option('-p', '--pylab', dest='pylab', action='store_true',
help='Produce pylab fit checks during execution',
default=False)
+ parser.add_option('-G', '--plot-guess', dest='plot_guess', action='store_true',
+ help='Produce plots of the pre-fit Lorentzian',
+ default=False)
parser.add_option('-t', '--tweak-mode', dest='tweakmode', action='store_true',
help='Run in tweak-file mode',
default=False)
config.PYLAB_INTERACTIVE = False
config.PYLAB_VERBOSE = options.pylab
config.GNUPLOT_VERBOSE = options.gnuplot
+ PLOT_GUESSED_LORENTZIAN = options.plot_guess
if options.tweakmode == False :
data = read_data(ifilename)