- Notifications
You must be signed in to change notification settings - Fork441
handle non proper tf in _common_den()#370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletionscontrol/tests/xferfcn_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
28 changes: 26 additions & 2 deletionscontrol/xferfcn.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -679,7 +679,7 @@ def freqresp(self, omega): | ||
def pole(self): | ||
"""Compute the poles of a transfer function.""" | ||
_, den, denorder = self._common_den(allow_nonproper=True) | ||
rts = [] | ||
for d, o in zip(den, denorder): | ||
rts.extend(roots(d[:o + 1])) | ||
@@ -797,7 +797,7 @@ def returnScipySignalLTI(self): | ||
return out | ||
def _common_den(self, imag_tol=None, allow_nonproper=False): | ||
""" | ||
Compute MIMO common denominators; return them and adjusted numerators. | ||
@@ -813,6 +813,9 @@ def _common_den(self, imag_tol=None): | ||
Threshold for the imaginary part of a root to use in detecting | ||
complex poles | ||
allow_nonproper : boolean | ||
Do not enforce proper transfer functions | ||
Returns | ||
------- | ||
num: array | ||
@@ -822,6 +825,8 @@ def _common_den(self, imag_tol=None): | ||
gives the numerator coefficient array for the ith output and jth | ||
input; padded for use in td04ad ('C' option); matches the | ||
denorder order; highest coefficient starts on the left. | ||
If allow_nonproper=True and the order of a numerator exceeds the | ||
order of the common denominator, num will be returned as None | ||
den: array | ||
sys.inputs by kd | ||
@@ -906,6 +911,8 @@ def _common_den(self, imag_tol=None): | ||
dtype=float) | ||
denorder = zeros((self.inputs,), dtype=int) | ||
havenonproper = False | ||
for j in range(self.inputs): | ||
if not len(poles[j]): | ||
# no poles matching this input; only one or more gains | ||
@@ -930,11 +937,28 @@ def _common_den(self, imag_tol=None): | ||
nwzeros.append(poles[j][ip]) | ||
numpoly = poleset[i][j][2] * np.atleast_1d(poly(nwzeros)) | ||
# td04ad expects a proper transfer function. If the | ||
# numerater has a higher order than the denominator, the | ||
# padding will fail | ||
if len(numpoly) > maxindex + 1: | ||
if allow_nonproper: | ||
havenonproper = True | ||
bnavigator marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
break | ||
raise ValueError( | ||
self.__str__() + | ||
"is not a proper transfer function. " | ||
"The degree of the numerators must not exceed " | ||
"the degree of the denominators.") | ||
# numerator polynomial should be padded on left and right | ||
# ending at maxindex to line up with what td04ad expects. | ||
num[i, j, maxindex+1-len(numpoly):maxindex+1] = numpoly | ||
# print(num[i, j]) | ||
if havenonproper: | ||
num = None | ||
return num, den, denorder | ||
def sample(self, Ts, method='zoh', alpha=None): | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.