update model_reduction to allow input/output selection + unstable warning (vs exception) by murrayrm · Pull Request #1074 · python-control/python-control
This PR updates the model_reduction function to add some additional functionality. From the docstring:
This function produces a reduced-order model of a system by eliminating specified inputs, outputs, and/or states from the original system. The specific states, inputs, or outputs that are eliminated can be specified by either listing the states, inputs, or outputs to be eliminated or those to be kept.
Specific updates:
- Changed the
ELIMpositional parameter toelim_states(positional or keyword). - Added
keep_statesto allow specifying the list of states to keep instead of those to eliminate. - Added
elim_inputs,elim_outputs,keep_inputs,keep_outputsto allow selection of inputs and outputs. - Specifications of states, inputs, and outputs can be done by a list of integers (original implementation) as well as slices or lists of signal names (new).
- In the case of eliminating states, inputs, or outputs from an unstable system, a warning is issued (versus an exception) and this warning can be suppressed using
warn_unstable=False. - Removed the copyright info from the top of
modelsimp.pysince we know just use theLICENSEfile. - Add unit tests and documentation updates.
- Cleaned up import order (isort -m2) and removed extraneous spaces.
This PR was motivated by an example from FBS2e (see steering.py), where I wanted to extract the dynamics of a subsystem (and the original system had an eigenvalue at the origin). It is possible to accomplish the same result by using the old implementation (assuming the exception is changed to a warning) and then indexing the system directly to handle the inputs and outputs, but it seemed natural to include in a single function call.