Vphoto_in2V is a function converting Vphoto values from bits to Volts.
This function is assumed linear, see bump_analyze().
"""
+ if config.TEXT_VERBOSE :
+ print "Calculating the naive (raw) variance"
Vphoto_std_bits = deflection_bits.std()
Vphoto_std = Vphoto_in2V(Vphoto_std_bits + zeroVphoto_bits)
+ if config.TEXT_VERBOSE :
+ print "Average deflection (Volts):", Vphoto_in2V(deflection_bits.mean())
return Vphoto_std**2
#@splittableKwargsFunction((fit_psd, 'freq_axis', 'psd_data'),
'minFreq', 'maxFreq'))
@splittableKwargsFunction((vib_analyze, 'deflection_bits', 'freq'))
-def vib_load_analyze_tweaked(tweak_file, **kwargs) :
+def vib_load_analyze_tweaked(tweak_file, analyze=vib_analyze, **kwargs) :
"""
Read the vib files listed in tweak_file.
Return an array of Vphoto variances (due to the cantilever) in Volts**2
"""
- vib_analyze_kwargs, = \
+ analyze_kwargs, = \
vib_load_analyze_tweaked._splitargs(vib_load_analyze_tweaked, kwargs)
dl = data_logger.data_load()
Vphoto_var = []
if config.TEXT_VERBOSE :
print "Analyzing '%s' at %g Hz" % (path, freq)
# analyze
- Vphoto_var.append(vib_analyze(deflection_bits, freq,
- **vib_analyze_kwargs))
+ if 'freq' in analyze._kwargs(analyze):
+ var = analyze(deflection_bits, freq, **analyze_kwargs)
+ else:
+ var = analyze(deflection_bits, **analyze_kwargs)
+ Vphoto_var.append(var)
return numpy.array(Vphoto_var, dtype=numpy.float)
# commandline interface functions
parser.add_option('-d', '--datalogger-mode', dest='datalogger_mode', action='store_true',
help='Read input files with datalogger.read_dict_of_arrays(). This is useful, for example, to test a single line from a tweakfile.',
default=False)
+ parser.add_option('-s', '--disable-spectrum-fitting', dest='spectrum_fitting',
+ action='store_false',
+ help='Disable PSD fitting, just use the raw variance',
+ default=True)
parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
help='Print lots of debugging information',
default=False)
config.PYLAB_VERBOSE = options.pylab
config.GNUPLOT_VERBOSE = options.gnuplot
PLOT_GUESSED_LORENTZIAN = options.plot_guess
+ if options.spectrum_fitting == True:
+ analyze = vib_analyze
+ analyze_args = {'freq':options.freq,
+ 'minFreq':options.min_freq,
+ 'maxFreq':options.max_freq}
+ else:
+ analyze = vib_analyze_naive
+ analyze_args = dict()
+ make_splittable_kwargs_function(vib_load_analyze_tweaked,
+ (vib_analyze, 'deflection_bits'))
if options.tweakmode == False : # single file mode
if options.datalogger_mode:
deflection_bits = data['Deflection input']
else:
deflection_bits = read_data(ifilename)
- Vphoto_var = vib_analyze(deflection_bits, freq=options.freq,
- minFreq=options.min_freq,
- maxFreq=options.max_freq)
+ Vphoto_var = analyze(deflection_bits, **analyze_args)
print >> ofile, Vphoto_var
else : # tweak mode
- Vphoto_vars = vib_load_analyze_tweaked(ifilename,
- minFreq=options.min_freq,
- maxFreq=options.max_freq)
+ if 'freq' in analyze_args:
+ analyze_args.pop('freq') # freq extracted from vib file names
+ Vphoto_vars = vib_load_analyze_tweaked(ifilename, analyze=analyze,
+ **analyze_args)
if options.comma_out :
sep = ','
else :