|
12 | 12 | from ..lti import LTI |
13 | 13 | from ..exception import ControlArgument |
14 | 14 |
|
15 | | -__all__ = ['bode', 'nyquist', 'ngrid', 'dcgain', 'connect'] |
| 15 | +__all__ = ['bode', 'nyquist', 'ngrid', 'rlocus', 'pzmap', 'dcgain', 'connect'] |
16 | 16 |
|
17 | 17 | def bode(*args, **kwargs): |
18 | 18 | """bode(syslist[, omega, dB, Hz, deg, ...]) |
19 | 19 |
|
20 | 20 | Bode plot of the frequency response. |
21 | 21 |
|
22 | | - Plots a bode gain and phase diagram |
| 22 | + Plots a bode gain and phase diagram. |
23 | 23 |
|
24 | 24 | Parameters |
25 | 25 | ---------- |
@@ -195,6 +195,104 @@ def _parse_freqplot_args(*args): |
195 | 195 | return syslist, omega, plotstyle, other |
196 | 196 |
|
197 | 197 |
|
| 198 | +def rlocus(*args, **kwargs): |
| 199 | + """rlocus(sys[, klist, xlim, ylim, ...]) |
| 200 | +
|
| 201 | + Root locus diagram. |
| 202 | +
|
| 203 | + Calculate the root locus by finding the roots of 1 + k * G(s) where G |
| 204 | + is a linear system with transfer function num(s)/den(s) and each k is |
| 205 | + an element of kvect. |
| 206 | +
|
| 207 | + Parameters |
| 208 | + ---------- |
| 209 | + sys : LTI object |
| 210 | + Linear input/output systems (SISO only, for now). |
| 211 | + kvect : array_like, optional |
| 212 | + Gains to use in computing plot of closed-loop poles. |
| 213 | + xlim : tuple or list, optional |
| 214 | + Set limits of x axis, normally with tuple |
| 215 | + (see :doc:`matplotlib:api/axes_api`). |
| 216 | + ylim : tuple or list, optional |
| 217 | + Set limits of y axis, normally with tuple |
| 218 | + (see :doc:`matplotlib:api/axes_api`). |
| 219 | +
|
| 220 | + Returns |
| 221 | + ------- |
| 222 | + roots : ndarray |
| 223 | + Closed-loop root locations, arranged in which each row corresponds |
| 224 | + to a gain in gains. |
| 225 | + gains : ndarray |
| 226 | + Gains used. Same as kvect keyword argument if provided. |
| 227 | +
|
| 228 | + Notes |
| 229 | + ----- |
| 230 | + This function is a wrapper for :func:`~control.root_locus_plot`, |
| 231 | + with legacy return arguments. |
| 232 | +
|
| 233 | + """ |
| 234 | + from ..rlocus import root_locus_plot |
| 235 | + |
| 236 | + # Use the plot keyword to get legacy behavior |
| 237 | + kwargs = dict(kwargs) # make a copy since we modify this |
| 238 | + if 'plot' not in kwargs: |
| 239 | + kwargs['plot'] = True |
| 240 | + |
| 241 | + # Turn off deprecation warning |
| 242 | + with warnings.catch_warnings(): |
| 243 | + warnings.filterwarnings( |
| 244 | + 'ignore', message='.* return values of .* is deprecated', |
| 245 | + category=DeprecationWarning) |
| 246 | + retval = root_locus_plot(*args, **kwargs) |
| 247 | + |
| 248 | + return retval |
| 249 | + |
| 250 | + |
| 251 | +def pzmap(*args, **kwargs): |
| 252 | + """pzmap(sys[, grid, plot]) |
| 253 | +
|
| 254 | + Plot a pole/zero map for a linear system. |
| 255 | +
|
| 256 | + Parameters |
| 257 | + ---------- |
| 258 | + sys: LTI (StateSpace or TransferFunction) |
| 259 | + Linear system for which poles and zeros are computed. |
| 260 | + plot: bool, optional |
| 261 | + If ``True`` a graph is generated with Matplotlib, |
| 262 | + otherwise the poles and zeros are only computed and returned. |
| 263 | + grid: boolean (default = False) |
| 264 | + If True plot omega-damping grid. |
| 265 | +
|
| 266 | + Returns |
| 267 | + ------- |
| 268 | + poles: array |
| 269 | + The system's poles. |
| 270 | + zeros: array |
| 271 | + The system's zeros. |
| 272 | +
|
| 273 | + Notes |
| 274 | + ----- |
| 275 | + This function is a wrapper for :func:`~control.pole_zero_plot`, |
| 276 | + with legacy return arguments. |
| 277 | +
|
| 278 | + """ |
| 279 | + from ..pzmap import pole_zero_plot |
| 280 | + |
| 281 | + # Use the plot keyword to get legacy behavior |
| 282 | + kwargs = dict(kwargs) # make a copy since we modify this |
| 283 | + if 'plot' not in kwargs: |
| 284 | + kwargs['plot'] = True |
| 285 | + |
| 286 | + # Turn off deprecation warning |
| 287 | + with warnings.catch_warnings(): |
| 288 | + warnings.filterwarnings( |
| 289 | + 'ignore', message='.* return values of .* is deprecated', |
| 290 | + category=DeprecationWarning) |
| 291 | + retval = pole_zero_plot(*args, **kwargs) |
| 292 | + |
| 293 | + return retval |
| 294 | + |
| 295 | + |
198 | 296 | from ..nichols import nichols_grid |
199 | 297 | def ngrid(): |
200 | 298 | return nichols_grid() |
@@ -254,6 +352,7 @@ def dcgain(*args): |
254 | 352 |
|
255 | 353 | from ..bdalg import connect as ct_connect |
256 | 354 | def connect(*args): |
| 355 | + |
257 | 356 | """Index-based interconnection of an LTI system. |
258 | 357 |
|
259 | 358 | The system `sys` is a system typically constructed with `append`, with |
|
0 commit comments