|
14 | 14 | import matplotlib.pyplot as plt
|
15 | 15 | import control as ct
|
16 | 16 |
|
17 |
| -# In interactive mode, turn on ipython interactive graphics |
18 |
| -plt.ion() |
19 |
| - |
20 | 17 |
|
21 | 18 | # Utility function for counting unstable poles of open loop (P in FBS)
|
22 | 19 | def _P(sys, indent='right'):
|
@@ -255,34 +252,38 @@ def test_nyquist_exceptions():
|
255 | 252 | ct.nyquist_plot(sys, np.logspace(-2, 3))
|
256 | 253 |
|
257 | 254 |
|
258 |
| -# |
259 |
| -# Interactive mode: generate plots for manual viewing |
260 |
| -# |
261 |
| -# Running this script in python (or better ipython) will show a collection of |
262 |
| -# figures that should all look OK on the screeen. |
263 |
| -# |
| 255 | +if __name__ == "__main__": |
| 256 | + # |
| 257 | + # Interactive mode: generate plots for manual viewing |
| 258 | + # |
| 259 | + # Running this script in python (or better ipython) will show a collection of |
| 260 | + # figures that should all look OK on the screeen. |
| 261 | + # |
| 262 | + |
| 263 | + # In interactive mode, turn on ipython interactive graphics |
| 264 | + plt.ion() |
264 | 265 |
|
265 |
| -# Start by clearing existing figures |
266 |
| -plt.close('all') |
| 266 | + # Start by clearing existing figures |
| 267 | + plt.close('all') |
267 | 268 |
|
268 |
| -print("Nyquist examples from FBS") |
269 |
| -test_nyquist_fbs_examples() |
| 269 | + print("Nyquist examples from FBS") |
| 270 | + test_nyquist_fbs_examples() |
270 | 271 |
|
271 |
| -print("Arrow test") |
272 |
| -test_nyquist_arrows(None) |
273 |
| -test_nyquist_arrows(1) |
274 |
| -test_nyquist_arrows(3) |
275 |
| -test_nyquist_arrows([0.1, 0.5, 0.9]) |
| 272 | + print("Arrow test") |
| 273 | + test_nyquist_arrows(None) |
| 274 | + test_nyquist_arrows(1) |
| 275 | + test_nyquist_arrows(3) |
| 276 | + test_nyquist_arrows([0.1, 0.5, 0.9]) |
276 | 277 |
|
277 |
| -print("Stability checks") |
278 |
| -test_nyquist_encirclements() |
| 278 | + print("Stability checks") |
| 279 | + test_nyquist_encirclements() |
279 | 280 |
|
280 |
| -print("Indentation checks") |
281 |
| -test_nyquist_indent() |
| 281 | + print("Indentation checks") |
| 282 | + test_nyquist_indent() |
282 | 283 |
|
283 |
| -print("Unusual Nyquist plot") |
284 |
| -sys = ct.tf([1], [1, 3, 2]) * ct.tf([1], [1, 0, 1]) |
285 |
| -plt.figure() |
286 |
| -plt.title("Poles: %s" % np.array2string(sys.pole(), precision=2, separator=',')) |
287 |
| -count = ct.nyquist_plot(sys) |
288 |
| -assert _Z(sys) == count + _P(sys) |
| 284 | + print("Unusual Nyquist plot") |
| 285 | + sys = ct.tf([1], [1, 3, 2]) * ct.tf([1], [1, 0, 1]) |
| 286 | + plt.figure() |
| 287 | + plt.title("Poles: %s" % np.array2string(sys.pole(), precision=2, separator=',')) |
| 288 | + count = ct.nyquist_plot(sys) |
| 289 | + assert _Z(sys) == count + _P(sys) |
0 commit comments