Rémi Pauchet 4 years ago
parent
commit
7aeb7c583b
2 changed files with 11 additions and 10 deletions
  1. 11 10
      bodeplot.py
  2. BIN
      doc/klonetonemin.png

+ 11 - 10
bodeplot.py

@@ -4,7 +4,7 @@ from scipy import interpolate
 from si_prefix import si_format
 import numpy as np
 
-def bodeplot(f, g, p):
+def bodeplot(f, g, p, with_fc=False):
 
     fig, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 6))
     fig.subplots_adjust(hspace=0.5)
@@ -17,16 +17,17 @@ def bodeplot(f, g, p):
     ax1.semilogx(f, g, 'C2')
     ax1.axhline(y=-3.0)
 
-    try:
-        # find fc at -3db
-        yreduced = np.array(g) - (-3.0)
-        freduced = interpolate.UnivariateSpline(f, yreduced, s=0)
-        fc = freduced.roots()[0]
+    if with_fc:
+        try:
+            # find fc at -3db
+            yreduced = np.array(g) - (-3.0)
+            freduced = interpolate.UnivariateSpline(f, yreduced, s=0)
+            fc = freduced.roots()[0]
 
-        ax1.scatter([fc], [-3.0], c = 'red')
-        ax1.annotate("fc=" + si_format(fc, precision=2) + "Hz", xy= (fc, -3.0), xytext=(fc, -2.5) )
-    except:
-        print("Warning: can't find fc")
+            ax1.scatter([fc], [-3.0], c = 'red')
+            ax1.annotate("fc=" + si_format(fc, precision=2) + "Hz", xy= (fc, -3.0), xytext=(fc, -2.5) )
+        except:
+            print("Warning: can't find fc")
     
     ax2.set_ylabel('phase (°)')
     ax2.set_xlabel('f (Hz)')

BIN
doc/klonetonemin.png