Skip to content

Commit

Permalink
Merge pull request scipy#2791 from andbo/master
Browse files Browse the repository at this point in the history
BUG: signal: Bode plot should return continuous phase
  • Loading branch information
pv committed Aug 27, 2013
2 parents 2b3b9c2 + ca0c159 commit 1dff009
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scipy/signal/ltisys.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ def bode(system, w=None, n=100):
w, y = freqresp(system, w=w, n=n)

mag = 20.0 * numpy.log10(abs(y))
phase = numpy.arctan2(y.imag, y.real) * 180.0 / numpy.pi
phase = numpy.unwrap(numpy.arctan2(y.imag, y.real)) * 180.0 / numpy.pi

return w, mag, phase

Expand Down
6 changes: 6 additions & 0 deletions scipy/signal/tests/test_ltisys.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,12 @@ def test_07(self):
system = lti([1], [1, 0, 100])
w, mag, phase = bode(system, n=2)

def test_08(self):
"""Test that bode() return continuous phase, issues/2331."""
system = lti([], [-10, -30, -40, -60, -70], 1)
w, mag, phase = system.bode(w=np.logspace(-3, 40, 100))
assert_almost_equal(min(phase), -450, decimal=15)

def test_from_state_space(self):
# Ensure that bode works with a system that was created from the
# state space representation matrices A, B, C, D. In this case,
Expand Down

0 comments on commit 1dff009

Please sign in to comment.