Fixed poor treatment of non-tweakfiles in vib_analyze.
[calibcant.git] / calibcant / vib_analyze.py
index 4c2843526d91bedf690cb6a848f0b8492e0954bc..283f1ae49d8b389cf549c497162c1c32e6ae7f0a 100755 (executable)
@@ -382,10 +382,9 @@ if __name__ == '__main__' :
                     '2008, W. Trevor King.\n'
                     '\n'
                     'Deflection power spectral density (PSD) data (X^2/Hz)\n'
-                    'and returns the variance in X units (X^2)'
-                    '<input-file> should be whitespace-delimited, 2 column ASCII\n'
-                    'without a header line.\n'
-                    'e.g: "<frequency_Hz>\\t<deflection_psd X^2/Hz>\\n"\n')
+                    'and returns the variance in X units (X^2)\n'
+                    '<input-file> should be 1 column ASCII without a header line.\n'
+                    'e.g: "<deflection bits>\\n..."\n')
     parser = OptionParser(usage=usage_string, version='%prog 0.1')
     parser.add_option('-f', '--sample-freq', dest='freq', default=100e3,
                       help='sample frequency in Hz (default %default)',
@@ -414,6 +413,9 @@ if __name__ == '__main__' :
     parser.add_option('-t', '--tweak-mode', dest='tweakmode', action='store_true',
                       help='Run in tweak-file mode',
                       default=False)
+    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('-v', '--verbose', dest='verbose', action='store_true',
                       help='Print lots of debugging information',
                       default=False)
@@ -439,8 +441,11 @@ if __name__ == '__main__' :
     PLOT_GUESSED_LORENTZIAN = options.plot_guess
 
     if options.tweakmode == False :
-        data = read_data(ifilename)
-        deflection_bits = data['Deflection input']
+        if options.datalogger_mode:
+            data = vib_load(ifilename)
+            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)