Skip to content

Commit 61d203c

Browse files
committed
* Restructured documentation (not completed)
* Added in code from Ryan Krauss for operation when slycot is missing * Updated version number to 0.5b * See ChangeLog for a more detailed list of changes
1 parent f012566 commit 61d203c

19 files changed

+209
-78
lines changed

ChangeLog

+54
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
1+
2012-01-07 Richard Murray <murray@malabar.local>
2+
3+
* doc/modules.rst: added new sections for analysis, synthesis,
4+
frequency plots and time response.
5+
6+
* doc/index.rst (Contents): added modules and examples.
7+
8+
* src/xferfcn.py (_convertToTransferFunction): added check for
9+
slycot import error. If not present, use signal.lti to perform the
10+
conversion. Only works for SISO.
11+
12+
* src/statesp.py (_convertToStateSpace): added check for slycot
13+
import error, to allow basic functionality without the presence of
14+
slycot (contributed by Ryan Krauss).
15+
16+
* tests/slycot_convert_test.py (TestSlycot.testTF): moved slycot
17+
import into test function, so that test script still works even if
18+
time response is not present.
19+
20+
2011-08-09 Richard Murray <murray@malabar.local>
21+
22+
* src/timeresp.py: fixed doc reference to time-series-convention
23+
24+
2011-08-08 Richard Murray <murray@malabar.local>
25+
26+
* doc/index.rst, doc/modules.rst: Moved MATLAB section into
27+
python-control modules file
28+
29+
2011-08-07 Richard Murray <murray@malabar.local>
30+
31+
* doc/conf.py: added autosummary extension
32+
33+
* doc/timeresp.rst: New file containing listing of functions for
34+
time responses (step, initial, etc)
35+
36+
* doc/freqplot.rst: New file listing functions for frequency
37+
plots (bode, nyquist, etc)
38+
39+
* doc/modules.rst: New file that contains a listing of the major
40+
modules in the toolbox
41+
42+
* doc/index.rst (Contents): Rearranged contents to put modules
43+
documentation in a separate section. Also added examples section
44+
(not quite ready yet).
45+
46+
2011-08-07 Richard Murray <murray@malabar.local>
47+
48+
* examples/rss-balred.py: reordered outputs from call to matlab.step
49+
(missed this the first time around)
50+
51+
* doc/matlab_strings.rst: Matlab -> MATLAB (proper spelling)
52+
53+
* setup.py, doc/conf.py: updated version to 0.5b
54+
155
2011-08-07 Richard Murray <murray@malabar.local>
256

357
* doc/conf.py: Updated version numbers to 0.5a, regenerated

doc/analysis.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Control System Analysis
2+
***********************

doc/bdalg_strings.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Block Diagram Algebra Routines
2-
******************************
1+
Block Diagram Algebra
2+
*********************
3+
4+
.. toctree::
35

4-
The Block Diagram Algebra Module
5-
================================
66
.. automodule:: bdalg
77
:members:

doc/class_strings.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Python-Control Classes
22
**********************
33

4-
The State Space Module
5-
======================
4+
State Space Class
5+
=================
66
.. automodule:: statesp
77
:members:
88

9-
The Transfer Function Module
10-
============================
9+
Transfer Function Class
10+
=======================
1111
.. automodule:: xferfcn
12-
:members:
12+
:members:

doc/conf.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
# ``sphinx.ext.viewcode`` : Include highlighted source code in the
3535
# documentation
3636
extensions = ['sphinx.ext.autodoc', 'numpydoc', 'sphinx.ext.pngmath',
37-
'sphinx.ext.intersphinx', 'sphinx.ext.todo']
37+
'sphinx.ext.intersphinx', 'sphinx.ext.todo',
38+
'sphinx.ext.autosummary']
3839

3940
# Add any paths that contain templates here, relative to this directory.
4041
templates_path = ['_templates']
@@ -49,17 +50,17 @@
4950
master_doc = 'index'
5051

5152
# General information about the project.
52-
project = u'Python Control'
53+
project = u'Python Control Systems Library'
5354
copyright = u'2011, Richard M. Murray et al.'
5455

5556
# The version info for the project you're documenting, acts as replacement for
5657
# |version| and |release|, also used in various other places throughout the
5758
# built documents.
5859
#
5960
# The short X.Y version.
60-
version = '0.5a'
61+
version = '0.5b'
6162
# The full version, including alpha/beta/rc tags.
62-
release = '0.5a'
63+
release = '0.5b'
6364

6465
# The language for content autogenerated by Sphinx. Refer to documentation
6566
# for a list of supported languages.
@@ -99,7 +100,7 @@
99100
#should be linked to in this documentation.
100101
intersphinx_mapping = \
101102
{'scipy':('http://docs.scipy.org/doc/scipy/reference/', None),
102-
'numpy':('http://docs.scipy.org/doc/numpy/reference/', None)}
103+
'numpy':('http://docs.scipy.org/doc/numpy', None)}
103104

104105
#If this is True, todo and todolist produce output, else they produce nothing.
105106
#The default is False.

doc/examples.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Examples
2+
********

doc/freqplot.rst

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Frequency Domain Plotting
2+
*************************
3+
4+
.. toctree::
5+
6+
Plotting routines
7+
=================
8+
.. autofunction:: freqplot.bode_plot
9+
.. autofunction:: freqplot.nyquist_plot
10+
.. autofunction:: freqplot.gangof4_plot
11+
.. autofunction:: nichols.nichols_plot
12+
13+
Utility functions
14+
=================
15+
.. autofunction:: freqplot.default_frequency_range

doc/index.rst

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
Welcome to Python-Control's documentation!
7-
==========================================
6+
Python Control User's Manual
7+
============================
8+
9+
Welcome to the Python Control Systems Library (python-control) User's
10+
Manual. This manual describes the python-control package, including
11+
all of the functions defined in the package and examples showing how
12+
to use the package.
813

914
Contents:
1015

1116
.. toctree::
17+
:maxdepth: 2
1218

1319
intro
1420
class_strings
15-
modsimp_strings
16-
matlab_strings
17-
bdalg_strings
21+
modules
22+
examples
1823

1924
Indices and tables
2025
==================

doc/intro.rst

+17-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
Introduction
33
============
44

5-
Welcome to the Python-Control project.
5+
Welcome to the Python Control Systems Toolbox (python-control) User's
6+
Manual. This manual contains information on using the python-control
7+
package, including documentation for all functions in the package and
8+
examples illustrating their use.
9+
10+
Overview of the Toolbox
11+
-----------------------
612

713
The python-control package is a set of python classes and functions
814
that implement common operations for the analysis and design of
@@ -39,15 +45,22 @@ some thing to keep in mind:
3945
Getting Started
4046
---------------
4147
1. Download latest release from http://sf.net/projects/python-control/files.
48+
4249
2. Untar the source code in a temporary directory and run 'python setup.py
4350
install' to build and install the code
44-
3. To see if things are working correctly, run ipython -pylab and run the
45-
script 'examples/secord-matlab.py'. This should generate a set response,
46-
Bode plot and Nyquist plot for a simple second order system.
51+
52+
3. To see if things are working correctly, run ipython -pylab and run
53+
the script 'examples/secord-matlab.py'. This should generate a
54+
step response, Bode plot and Nyquist plot for a simple second order
55+
system.
56+
4757
4. To see the commands that are available, run the following commands in
4858
ipython::
59+
4960
>>> import control
5061
>>> ?control.matlab
62+
5163
5. If you want to have a MATLAB-like environment for running the control
5264
toolbox, use::
65+
5366
>>> from control.matlab import *

doc/matlab_strings.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
Matlab-like Routines
2-
********************
1+
MATLAB Compatibility Module
2+
***************************
33

4-
The Matlab Module
5-
=================
64
.. automodule:: matlab
75
:members:
86

doc/modsimp_strings.rst

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
Model Simplification Tools
22
**************************
33

4-
The modelsimp Module
5-
====================
64
.. automodule:: modelsimp
75
:members:

doc/modules.rst

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Python-Control Modules
2+
**********************
3+
4+
.. toctree::
5+
6+
bdalg_strings
7+
analysis
8+
freqplot
9+
timeresp
10+
synthesis
11+
modsimp_strings
12+
matlab_strings

doc/synthesis.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Control System Synthesis
2+
************************

doc/timeresp.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Time Domain Simulation
2+
**********************
3+
4+
.. automodule:: timeresp
5+
:members:
6+
7+
.. autofunction:: phaseplot.phase_plot
8+
.. autofunction:: phaseplot.box_grid

examples/rss-balred.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
# Comparison of the step responses of the full and reduced systems
2828
plt.figure(1)
29-
t, y = mt.step(fsys)
30-
tr, yr = mt.step(rsys)
29+
y, t = mt.step(fsys)
30+
yr, tr = mt.step(rsys)
3131
plt.plot(t.T, y.T)
3232
plt.hold(True)
3333
plt.plot(tr.T, yr.T)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from setuptools import setup
55

66
setup(name = 'control',
7-
version = '0.5a',
7+
version = '0.5b',
88
description = 'Python Control Systems Library',
99
author = 'Richard Murray',
1010
author_email = 'murray@cds.caltech.edu',

src/statesp.py

+33-24
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
from numpy import all, angle, any, array, asarray, concatenate, cos, delete, \
7777
dot, empty, exp, eye, matrix, ones, pi, poly, poly1d, roots, shape, sin, \
78-
zeros
78+
zeros, squeeze
7979
from numpy.random import rand, randn
8080
from numpy.linalg import inv, det, solve
8181
from numpy.linalg.linalg import LinAlgError
@@ -459,28 +459,37 @@ def _convertToStateSpace(sys, **kw):
459459
# Already a state space system; just return it
460460
return sys
461461
elif isinstance(sys, xferfcn.TransferFunction):
462-
from slycot import td04ad
463-
if len(kw):
464-
raise TypeError("If sys is a TransferFunction, _convertToStateSpace \
465-
cannot take keywords.")
462+
try:
463+
from slycot import td04ad
464+
if len(kw):
465+
raise TypeError("If sys is a TransferFunction, _convertToStateSpace \
466+
cannot take keywords.")
467+
468+
# Change the numerator and denominator arrays so that the transfer
469+
# function matrix has a common denominator.
470+
num, den = sys._common_den()
471+
# Make a list of the orders of the denominator polynomials.
472+
index = [len(den) - 1 for i in range(sys.outputs)]
473+
# Repeat the common denominator along the rows.
474+
den = array([den for i in range(sys.outputs)])
475+
# TODO: transfer function to state space conversion is still buggy!
476+
#print num
477+
#print shape(num)
478+
ssout = td04ad('R',sys.inputs, sys.outputs, index, den, num,tol=0.0)
479+
480+
states = ssout[0]
481+
return StateSpace(ssout[1][:states, :states],
482+
ssout[2][:states, :sys.inputs],
483+
ssout[3][:sys.outputs, :states],
484+
ssout[4])
485+
except ImportError:
486+
lti_sys = lti(squeeze(sys.num), squeeze(sys.den))#<-- do we want to squeeze first
487+
# and check dimenations? I think
488+
# this will fail if num and den aren't 1-D
489+
# after the squeeze
490+
return StateSpace(lti_sys.A, lti_sys.B, lti_sys.C, lti_sys.D)
491+
466492

467-
# Change the numerator and denominator arrays so that the transfer
468-
# function matrix has a common denominator.
469-
num, den = sys._common_den()
470-
# Make a list of the orders of the denominator polynomials.
471-
index = [len(den) - 1 for i in range(sys.outputs)]
472-
# Repeat the common denominator along the rows.
473-
den = array([den for i in range(sys.outputs)])
474-
# TODO: transfer function to state space conversion is still buggy!
475-
#print num
476-
#print shape(num)
477-
ssout = td04ad('R',sys.inputs, sys.outputs, index, den, num,tol=0.0)
478-
479-
states = ssout[0]
480-
return StateSpace(ssout[1][:states, :states],
481-
ssout[2][:states, :sys.inputs],
482-
ssout[3][:sys.outputs, :states],
483-
ssout[4])
484493
elif isinstance(sys, (int, long, float, complex)):
485494
if "inputs" in kw:
486495
inputs = kw["inputs"]
@@ -627,8 +636,8 @@ def _mimo2siso(sys, input, output, warn_conversion):
627636
628637
If ``sys`` is already a SISO system, it will be returned unaltered.
629638
630-
Parameters:
631-
639+
Parameters
640+
----------
632641
sys: StateSpace
633642
Linear (MIMO) system that should be converted.
634643
input: int

0 commit comments

Comments
 (0)