@@ -286,8 +286,8 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
286
286
kvect = np .hstack ((np .linspace (0 , kmax , 50 ), np .real (k_break )))
287
287
kvect .sort ()
288
288
289
- mymat = _RLFindRoots (num , den , kvect )
290
- mymat = _RLSortRoots (mymat )
289
+ root_array = _RLFindRoots (num , den , kvect )
290
+ root_array = _RLSortRoots (root_array )
291
291
open_loop_poles = den .roots
292
292
open_loop_zeros = num .roots
293
293
@@ -297,13 +297,13 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
297
297
open_loop_zeros ,
298
298
np .ones (open_loop_poles .size - open_loop_zeros .size )
299
299
* open_loop_zeros [- 1 ])
300
- mymat_xl = np .append (mymat , open_loop_zeros_xl )
300
+ root_array_xl = np .append (root_array , open_loop_zeros_xl )
301
301
else :
302
- mymat_xl = mymat
302
+ root_array_xl = root_array
303
303
singular_points = np .concatenate ((num .roots , den .roots ), axis = 0 )
304
304
important_points = np .concatenate ((singular_points , real_break ), axis = 0 )
305
305
important_points = np .concatenate ((important_points , np .zeros (2 )), axis = 0 )
306
- mymat_xl = np .append (mymat_xl , important_points )
306
+ root_array_xl = np .append (root_array_xl , important_points )
307
307
308
308
false_gain = float (den .coeffs [0 ]) / float (num .coeffs [0 ])
309
309
if false_gain < 0 and not den .order > num .order :
@@ -312,27 +312,27 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
312
312
"with equal order of numerator and denominator." )
313
313
314
314
if xlim is None and false_gain > 0 :
315
- x_tolerance = 0.05 * (np .max (np .real (mymat_xl ))
316
- - np .min (np .real (mymat_xl )))
317
- xlim = _ax_lim (mymat_xl )
315
+ x_tolerance = 0.05 * (np .max (np .real (root_array_xl ))
316
+ - np .min (np .real (root_array_xl )))
317
+ xlim = _ax_lim (root_array_xl )
318
318
elif xlim is None and false_gain < 0 :
319
319
axmin = np .min (np .real (important_points )) \
320
320
- (np .max (np .real (important_points ))
321
321
- np .min (np .real (important_points )))
322
- axmin = np .min (np .array ([axmin , np .min (np .real (mymat_xl ))]))
322
+ axmin = np .min (np .array ([axmin , np .min (np .real (root_array_xl ))]))
323
323
axmax = np .max (np .real (important_points )) \
324
324
+ np .max (np .real (important_points )) \
325
325
- np .min (np .real (important_points ))
326
- axmax = np .max (np .array ([axmax , np .max (np .real (mymat_xl ))]))
326
+ axmax = np .max (np .array ([axmax , np .max (np .real (root_array_xl ))]))
327
327
xlim = [axmin , axmax ]
328
328
x_tolerance = 0.05 * (axmax - axmin )
329
329
else :
330
330
x_tolerance = 0.05 * (xlim [1 ] - xlim [0 ])
331
331
332
332
if ylim is None :
333
- y_tolerance = 0.05 * (np .max (np .imag (mymat_xl ))
334
- - np .min (np .imag (mymat_xl )))
335
- ylim = _ax_lim (mymat_xl * 1j )
333
+ y_tolerance = 0.05 * (np .max (np .imag (root_array_xl ))
334
+ - np .min (np .imag (root_array_xl )))
335
+ ylim = _ax_lim (root_array_xl * 1j )
336
336
else :
337
337
y_tolerance = 0.05 * (ylim [1 ] - ylim [0 ])
338
338
@@ -345,7 +345,7 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
345
345
tolerance = x_tolerance
346
346
else :
347
347
tolerance = np .min ([x_tolerance , y_tolerance ])
348
- indexes_too_far = _indexes_filt (mymat , tolerance , zoom_xlim , zoom_ylim )
348
+ indexes_too_far = _indexes_filt (root_array , tolerance , zoom_xlim , zoom_ylim )
349
349
350
350
# Add more points into the root locus for points that are too far apart
351
351
while len (indexes_too_far ) > 0 and kvect .size < 5000 :
@@ -354,27 +354,27 @@ def _default_gains(num, den, xlim, ylim, zoom_xlim=None, zoom_ylim=None):
354
354
new_gains = np .linspace (kvect [index ], kvect [index + 1 ], 5 )
355
355
new_points = _RLFindRoots (num , den , new_gains [1 :4 ])
356
356
kvect = np .insert (kvect , index + 1 , new_gains [1 :4 ])
357
- mymat = np .insert (mymat , index + 1 , new_points , axis = 0 )
357
+ root_array = np .insert (root_array , index + 1 , new_points , axis = 0 )
358
358
359
- mymat = _RLSortRoots (mymat )
360
- indexes_too_far = _indexes_filt (mymat , tolerance , zoom_xlim , zoom_ylim )
359
+ root_array = _RLSortRoots (root_array )
360
+ indexes_too_far = _indexes_filt (root_array , tolerance , zoom_xlim , zoom_ylim )
361
361
362
362
new_gains = kvect [- 1 ] * np .hstack ((np .logspace (0 , 3 , 4 )))
363
363
new_points = _RLFindRoots (num , den , new_gains [1 :4 ])
364
364
kvect = np .append (kvect , new_gains [1 :4 ])
365
- mymat = np .concatenate ((mymat , new_points ), axis = 0 )
366
- mymat = _RLSortRoots (mymat )
367
- return kvect , mymat , xlim , ylim
365
+ root_array = np .concatenate ((root_array , new_points ), axis = 0 )
366
+ root_array = _RLSortRoots (root_array )
367
+ return kvect , root_array , xlim , ylim
368
368
369
369
370
- def _indexes_filt (mymat , tolerance , zoom_xlim = None , zoom_ylim = None ):
370
+ def _indexes_filt (root_array , tolerance , zoom_xlim = None , zoom_ylim = None ):
371
371
"""Calculate the distance between points and return the indexes.
372
372
373
373
Filter the indexes so only the resolution of points within the xlim and
374
374
ylim is improved when zoom is used.
375
375
376
376
"""
377
- distance_points = np .abs (np .diff (mymat , axis = 0 ))
377
+ distance_points = np .abs (np .diff (root_array , axis = 0 ))
378
378
indexes_too_far = list (np .unique (np .where (distance_points > tolerance )[0 ]))
379
379
380
380
if zoom_xlim is not None and zoom_ylim is not None :
@@ -386,23 +386,23 @@ def _indexes_filt(mymat, tolerance, zoom_xlim=None, zoom_ylim=None):
386
386
indexes_too_far_filtered = []
387
387
388
388
for index in indexes_too_far_zoom :
389
- for point in mymat [index ]:
389
+ for point in root_array [index ]:
390
390
if (zoom_xlim [0 ] <= point .real <= zoom_xlim [1 ]) and \
391
391
(zoom_ylim [0 ] <= point .imag <= zoom_ylim [1 ]):
392
392
indexes_too_far_filtered .append (index )
393
393
break
394
394
395
395
# Check if zoom box is not overshot & insert points where neccessary
396
- if len (indexes_too_far_filtered ) == 0 and len (mymat ) < 500 :
396
+ if len (indexes_too_far_filtered ) == 0 and len (root_array ) < 500 :
397
397
limits = [zoom_xlim [0 ], zoom_xlim [1 ], zoom_ylim [0 ], zoom_ylim [1 ]]
398
398
for index , limit in enumerate (limits ):
399
399
if index <= 1 :
400
- asign = np .sign (real (mymat )- limit )
400
+ asign = np .sign (real (root_array )- limit )
401
401
else :
402
- asign = np .sign (imag (mymat ) - limit )
402
+ asign = np .sign (imag (root_array ) - limit )
403
403
signchange = ((np .roll (asign , 1 , axis = 0 )
404
404
- asign ) != 0 ).astype (int )
405
- signchange [0 ] = np .zeros ((len (mymat [0 ])))
405
+ signchange [0 ] = np .zeros ((len (root_array [0 ])))
406
406
if len (np .where (signchange == 1 )[0 ]) > 0 :
407
407
indexes_too_far_filtered .append (
408
408
np .where (signchange == 1 )[0 ][0 ]- 1 )
@@ -411,7 +411,7 @@ def _indexes_filt(mymat, tolerance, zoom_xlim=None, zoom_ylim=None):
411
411
if indexes_too_far_filtered [0 ] != 0 :
412
412
indexes_too_far_filtered .insert (
413
413
0 , indexes_too_far_filtered [0 ]- 1 )
414
- if not indexes_too_far_filtered [- 1 ] + 1 >= len (mymat ) - 2 :
414
+ if not indexes_too_far_filtered [- 1 ] + 1 >= len (root_array ) - 2 :
415
415
indexes_too_far_filtered .append (
416
416
indexes_too_far_filtered [- 1 ] + 1 )
417
417
@@ -441,10 +441,10 @@ def _break_points(num, den):
441
441
return k_break , real_break_pts
442
442
443
443
444
- def _ax_lim (mymat ):
444
+ def _ax_lim (root_array ):
445
445
"""Utility to get the axis limits"""
446
- axmin = np .min (np .real (mymat ))
447
- axmax = np .max (np .real (mymat ))
446
+ axmin = np .min (np .real (root_array ))
447
+ axmax = np .max (np .real (root_array ))
448
448
if axmax != axmin :
449
449
deltax = (axmax - axmin ) * 0.02
450
450
else :
@@ -564,11 +564,11 @@ def _RLZoomDispatcher(event, sys, ax_rlocus, plotstr):
564
564
nump , denp = _systopoly1d (sys_loop )
565
565
xlim , ylim = ax_rlocus .get_xlim (), ax_rlocus .get_ylim ()
566
566
567
- kvect , mymat , xlim , ylim = _default_gains (
567
+ kvect , root_array , xlim , ylim = _default_gains (
568
568
nump , denp , xlim = None , ylim = None , zoom_xlim = xlim , zoom_ylim = ylim )
569
569
_removeLine ('rootlocus' , ax_rlocus )
570
570
571
- for i , col in enumerate (mymat .T ):
571
+ for i , col in enumerate (root_array .T ):
572
572
ax_rlocus .plot (real (col ), imag (col ), plotstr , label = 'rootlocus' ,
573
573
scalex = False , scaley = False )
574
574
@@ -640,10 +640,10 @@ def _RLFeedbackClicksPoint(event, sys, fig, ax_rlocus, sisotool=False):
640
640
641
641
# Visualise clicked point, display all roots for sisotool mode
642
642
if sisotool :
643
- mymat = _RLFindRoots (nump , denp , K .real )
643
+ root_array = _RLFindRoots (nump , denp , K .real )
644
644
ax_rlocus .plot (
645
- [root .real for root in mymat ],
646
- [root .imag for root in mymat ],
645
+ [root .real for root in root_array ],
646
+ [root .imag for root in root_array ],
647
647
marker = 's' , markersize = 6 , zorder = 20 , label = 'gain_point' , color = 'k' )
648
648
else :
649
649
ax_rlocus .plot (s .real , s .imag , 'k.' , marker = 's' , markersize = 8 ,
0 commit comments