zpGain Vzp_out / Vzp
zpSensitivity Zp / Vzp
photoSensitivity Vphoto / Zcant
+
+photoSensitivity is measured by bumping the cantilever against the
+surface, where Zp = Zcant (see calibrate.bump_aquire()). The measured
+slope Vphoto/Vout is converted to photoSensitivity with bump_analyze().
"""
import numpy
import data_logger
import z_piezo_utils
import linfit
+from splittable_kwargs import splittableKwargsFunction, \
+ make_splittable_kwargs_function
+#@splittableKwargsFunction((bump_plot, 'data'))
+# Some of the child functions aren't yet defined, so postpone
+# make-splittable until later in the module.
def bump_analyze(data, zpGain=config.zpGain,
zpSensitivity=config.zpSensitivity,
Vzp_out2V=config.Vzp_out2V,
Vphoto_in2V=config.Vphoto_in2V,
- textVerboseFile=None, plotVerbose=False) :
+ **kwargs) :
"""
Return the slope of the bump ;).
Inputs:
and THEN converted, so we're assuming that both conversions are LINEAR.
if they aren't, rewrite to convert before the regression.
"""
+ bump_plot_kwargs, = bump_analyze._splitargs(bump_analyze, kwargs)
scale_Vzp_bits2V = Vzp_out2V(1) - Vzp_out2V(0)
scale_Vphoto_bits2V = Vphoto_in2V(1) - Vphoto_in2V(0)
Vphoto2Vzp_out_bit, intercept = \
linfit.linregress(x=data["Z piezo output"],
y=data["Deflection input"],
- plotVerbose=plotVerbose)
- Vphoto2Vzp_out = Vphoto2Vzp_out_bit * scale_Vphoto_bits2V / scale_Vzp_bits2V
+ plotVerbose=False)
+ Vphoto2Vzp_out = Vphoto2Vzp_out_bit *scale_Vphoto_bits2V / scale_Vzp_bits2V
# 1 / (Vzp/Vzp_out * Zp/Vzp * Zcant/Zp )
Vzp_out2Zcant = 1.0/ (zpGain * zpSensitivity) # * 1
+ bump_plot(data, **bump_plot_kwargs)
return Vphoto2Vzp_out * Vzp_out2Zcant
-def bump_save(data, log_dir) :
+@splittableKwargsFunction()
+def bump_save(data, log_dir=None) :
"Save the dictionary data, using data_logger.data_log()"
if log_dir != None :
log = data_logger.data_log(log_dir, noclobber_logsubdir=False,
data = dl.read_dict_of_arrays(datafile)
return data
-def bump_plot(data, plotVerbose) :
+@splittableKwargsFunction()
+def bump_plot(data, plotVerbose=False) :
"Plot the bump (Vphoto vs Vzp) if plotVerbose or PYLAB_VERBOSE == True"
if plotVerbose or config.PYLAB_VERBOSE :
common._import_pylab()
common._pylab.legend(loc='upper left')
common._flush_plot()
-def bump_load_analyze_tweaked(tweak_file, zpGain=config.zpGain,
- zpSensitivity=config.zpSensitivity,
- Vzp_out2V=config.Vzp_out2V,
- Vphoto_in2V=config.Vphoto_in2V,
- textVerboseFile=None, plotVerbose=False) :
+make_splittable_kwargs_function(bump_analyze, (bump_plot, 'data'))
+
+@splittableKwargsFunction((bump_analyze, 'data'))
+def bump_load_analyze_tweaked(tweak_file, **kwargs):
"Load the output file of tweak_calib_bump.sh, return an array of slopes"
+ bump_analyze_kwargs, = \
+ bump_load_analyze_tweaked._splitargs(bump_load_analyze_tweaked, kwargs)
photoSensitivity = []
for line in file(tweak_file, 'r') :
parsed = line.split()
path = parsed[0].split('\n')[0]
- if textVerboseFile != None :
- print >> textVerboseFile, "Reading data from %s with ranges %s" % (path, parsed[1:])
+ if config.TEXT_VERBOSE :
+ print "Reading data from %s with ranges %s" % (path, parsed[1:])
# read the data
full_data = bump_load(path)
if len(parsed) == 1 :
df.extend(full_data['Deflection input'][starti:stopi])
data = {'Z piezo output': numpy.array(zp),
'Deflection input': numpy.array(df)}
- pSi = bump_analyze(data, zpGain, zpSensitivity,
- Vzp_out2V, Vphoto_in2V, plotVerbose)
+ pSi = bump_analyze(data, **bump_analyze_kwargs)
photoSensitivity.append(pSi)
- bump_plot(data, plotVerbose)
return numpy.array(photoSensitivity, dtype=numpy.float)
# commandline interface functions
ofile = file(options.ofilename, 'w')
else :
ofile = sys.stdout
- if options.verbose == True :
- vfile = sys.stderr
- else :
- vfile = None
config.TEXT_VERBOSE = options.verbose
config.PYLAB_INTERACTIVE = False
config.PYLAB_VERBOSE = options.pylab
# data not very bilinear, so don't cut anything off.
print >> sys.stderr, "use everything"
- photoSensitivity = bump_analyze(data, textVerboseFile=vfile)
+ photoSensitivity = bump_analyze(data)
print >> ofile, photoSensitivity
else : # tweak file mode
- slopes = bump_load_analyze_tweaked(ifilename, textVerboseFile=vfile)
+ slopes = bump_load_analyze_tweaked(ifilename)
if options.comma_out :
sep = ','
else :