Also fixed spacing in analyze.py from last change and removed some
.pyc files from versioning.
import common # common module for the calibcant package
import config # config module for the calibcant package
import data_logger
import common # common module for the calibcant package
import config # config module for the calibcant package
import data_logger
import linfit
def C_to_K(celsius) :
import linfit
def C_to_K(celsius) :
T_r = T_s / T_m
one_o_Vphoto2_r = one_o_Vphoto2_s / one_o_Vphoto2_m
string = "Variable (units) : mean +/- std. dev. (relative error)\n"
T_r = T_s / T_m
one_o_Vphoto2_r = one_o_Vphoto2_s / one_o_Vphoto2_m
string = "Variable (units) : mean +/- std. dev. (relative error)\n"
- string += "Cantilever k (N/m) : %g +/- %g (%g)\n" \
+ string += "Cantilever k (N/m) : %g +/- %g (%g)\n" \
% (k_m, k_s, k_r)
string += "photoSensitivity**2 (V/nm)**2 : %g +/- %g (%g)\n" \
% (photoSensitivity2_m, photoSensitivity2_s, photoSensitivity2_r)
% (k_m, k_s, k_r)
string += "photoSensitivity**2 (V/nm)**2 : %g +/- %g (%g)\n" \
% (photoSensitivity2_m, photoSensitivity2_s, photoSensitivity2_r)
_flush_plot = None
_final_flush_plot = None
_pylab = None
_flush_plot = None
_final_flush_plot = None
_pylab = None
def _import_pylab() :
"""Import pylab plotting functions for when we need to plot. This
def _import_pylab() :
"""Import pylab plotting functions for when we need to plot. This
if config.PYLAB_INTERACTIVE :
_flush_plot = _pylab.draw
else :
if config.PYLAB_INTERACTIVE :
_flush_plot = _pylab.draw
else :
- def _flush_plot () : pass
+ _flush_plot = _pylab.show #_dummy_fn
if _final_flush_plot == None :
if config.PYLAB_INTERACTIVE :
_final_flush_plot = _pylab.draw
else :
if _final_flush_plot == None :
if config.PYLAB_INTERACTIVE :
_final_flush_plot = _pylab.draw
else :
- _final_flush_plot = _pylab.show
+ _final_flush_plot = _dummy_fn # _pylab.show
def write_array(ofile, array, seperator):
"""Erite an iterable array seperated by seperator.
def write_array(ofile, array, seperator):
"""Erite an iterable array seperated by seperator.
"""Define some variables to configure the package for a particular lab
and workflow."""
"""Define some variables to configure the package for a particular lab
and workflow."""
DEFAULT_TEMP = 22 # assume 22 deg C
LOG_DATA = True # quietly grab all real-world data and log to LOG_DIR
DEFAULT_TEMP = 22 # assume 22 deg C
LOG_DATA = True # quietly grab all real-world data and log to LOG_DIR
BASE_FIGNUM = 20 # to avoid writing to already existing figures
# zpGain zpiezo applied voltage per output Volt
BASE_FIGNUM = 20 # to avoid writing to already existing figures
# zpGain zpiezo applied voltage per output Volt
-zpGain = z_piezo_utils._usual_zpGain
+zpGain = z_piezo.DEFAULT_GAIN
# zpSensitivity nm zpiezo response per applied Volt
# zpSensitivity nm zpiezo response per applied Volt
-zpSensitivity = z_piezo_utils._usual_zpSensitivity
+zpSensitivity = z_piezo.DEFAULT_SENSITIVITY
# Vzp_out2V function that converts output DAC bits to Volts
# Vzp_out2V function that converts output DAC bits to Volts
-Vzp_out2V = z_piezo_utils._usual_Vzp_out2V
+Vzp_out2V = z_piezo.DEFAULT_VZP_OUT_2_VOLTS
# Vphoto_in2V function that converts input ADC bits to Volts
# Vphoto_in2V function that converts input ADC bits to Volts
-Vphoto_in2V = z_piezo_utils._usual_Vphoto_in2V
+Vphoto_in2V = z_piezo.DEFAULT_VPHOTO_IN_2_VOLTS
# zeroVphoto_bits ADC bit output for a 0V input
# zeroVphoto_bits ADC bit output for a 0V input
-zeroVphoto_bits = z_piezo_utils._usual_zeroVphoto_bits
+zeroVphoto_bits = z_piezo.DEFAULT_ZERO_PHOTODIODE_BITS
FFTed Vphoto data (Vphoto vs Frequency) (show major noise components).
"""
if plotVerbose or config.PYLAB_VERBOSE :
FFTed Vphoto data (Vphoto vs Frequency) (show major noise components).
"""
if plotVerbose or config.PYLAB_VERBOSE :
+ common._pylab.figure(config.BASE_FIGNUM+2)
common._pylab.hold(False)
common._pylab.hold(False)
- common._pylab.figure(BASE_FIGNUM+2)
# plot time series
common._pylab.subplot(311)
# plot time series
common._pylab.subplot(311)
- common._pylab.plot(data["Deflection input"], 'r.')
+ common._pylab.plot(deflection_bits, 'r.')
common._pylab.title("free oscillation")
# plot histogram distribution and gaussian fit
common._pylab.subplot(312)
n, bins, patches = \
common._pylab.title("free oscillation")
# plot histogram distribution and gaussian fit
common._pylab.subplot(312)
n, bins, patches = \
- common._pylab.hist(data["Deflection input"], bins=30,
- normed=1, align='center')
+ common._pylab.hist(deflection_bits, bins=30,
+ normed=1, align='center')
gaus = numpy.zeros((len(bins),))
gaus = numpy.zeros((len(bins),))
- mean = data["Deflection input"].mean()
- std = data["Deflection input"].std()
+ mean = deflection_bits.mean()
+ std = deflection_bits.std()
pi = numpy.pi
exp = numpy.exp
for i in range(len(bins)) :
pi = numpy.pi
exp = numpy.exp
for i in range(len(bins)) :
common._pylab.subplot(313)
common._pylab.semilogy(freq_axis, power, 'r.-')
common._flush_plot()
common._pylab.subplot(313)
common._pylab.semilogy(freq_axis, power, 'r.-')
common._flush_plot()
- if (plotVerbose or config.GNUPLOT_VERBOSE) and False : # TODO, clean up and double check...
+ if (plotVerbose or config.GNUPLOT_VERBOSE):
# write all the ft data now
fd = file(datafilename, 'w')
for i in range(len(freq_axis)) :
# write all the ft data now
fd = file(datafilename, 'w')
for i in range(len(freq_axis)) :
parser.add_option('-g', '--gnuplot', dest='gnuplot', action='store_true',
help='Print gnuplot fit check script to stderr',
default=False)
parser.add_option('-g', '--gnuplot', dest='gnuplot', action='store_true',
help='Print gnuplot fit check script to stderr',
default=False)
+ parser.add_option('-p', '--pylab', dest='pylab', action='store_true',
+ help='Produce pylab fit checks during execution',
+ default=False)
parser.add_option('-t', '--tweak-mode', dest='tweakmode', action='store_true',
help='Run in tweak-file mode',
default=False)
parser.add_option('-t', '--tweak-mode', dest='tweakmode', action='store_true',
help='Run in tweak-file mode',
default=False)
else :
vfile = None
config.TEXT_VERBOSE = options.verbose
else :
vfile = None
config.TEXT_VERBOSE = options.verbose
- config.PYLAB_VERBOSE = False
+ config.PYLAB_INTERACTIVE = False
+ config.PYLAB_VERBOSE = options.pylab
config.GNUPLOT_VERBOSE = options.gnuplot
if options.tweakmode == False :
config.GNUPLOT_VERBOSE = options.gnuplot
if options.tweakmode == False :
sep = '\n'
common.write_array(ofile, Vphoto_vars, sep)
sep = '\n'
common.write_array(ofile, Vphoto_vars, sep)
+ if common._final_flush_plot != None:
+ common._final_flush_plot()
+
if options.ofilename != None :
ofile.close()
if options.ofilename != None :
ofile.close()