vibration_analyze: Only highlight the frequency range if we have a config
authorW. Trevor King <wking@tremily.us>
Sat, 4 May 2013 22:16:24 +0000 (18:16 -0400)
committerW. Trevor King <wking@tremily.us>
Sat, 4 May 2013 22:16:24 +0000 (18:16 -0400)
You shouldn't have to mock up a config dictionary just to plot the
PSD.  With this commit, you can skip config if you just want a
quick-and-dirty plot.

calibcant/vibration_analyze.py

index 9d2fa29b0d402ea8e4b03856eb9f1fb8f9c0b6f0..487d027ce88509185b2432c5fdc7001231b807cd 100644 (file)
@@ -536,12 +536,13 @@ def plot(deflection=None, freq_axis=None, power=None, A=None, B=None,
         freq_axes.autoscale(tight=True)
         xmin,xmax = freq_axes.get_xbound()
         ymin,ymax = freq_axes.get_ybound()
-    
+
         # highlight the region we're fitting
-        freq_axes.axvspan(
-            config['minimum-fit-frequency'],
-            config['maximum-fit-frequency'],
-            facecolor='g', alpha=0.1, zorder=-2)
+        if config:
+            freq_axes.axvspan(
+                config['minimum-fit-frequency'],
+                config['maximum-fit-frequency'],
+                facecolor='g', alpha=0.1, zorder=-2)
 
         if A is not None:
             fitdata = breit_wigner(freq_axis, A, B, C, D)