Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
reworked feature selection for discrete systems
  • Loading branch information
martinup committed Sep 7, 2015
commit 3b6de2fd987212531378d35ebd73e76842b07eab
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ build.log
doc/_build
doc/generated

examples/.ipynb_checkpoints/bode-plot-checkpoint.ipynb
examples/.ipynb_checkpoints/
.settings/org.eclipse.core.resources.prefs
.pydevproject
.project
.project
Untitled*.ipynb
27 changes: 16 additions & 11 deletions control/freqplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,21 +442,26 @@ def default_frequency_range(syslist, Hz=None, number_of_samples=None, feature_pe
try:
# Add new features to the list
if sys.isctime():
features_ = np.abs(sys.pole())
features_ = np.concatenate((features_, np.abs(sys.zero())))
features_ = np.concatenate((np.abs(sys.pole()),
np.abs(sys.zero())))
# Get rid of poles and zeros at the origin
features_ = features_[features_ != 0.0];
features = np.concatenate((features, features_))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to remove all poles and zeros on (or very near) the imaginary axis? It wouldn't make sense to remove such zeros for a Nyquist plot, I guess.

elif sys.isdtime(strict=True):
fn = np.pi * 1. / sys.dt
#TODO: What distance to the Nyquist frequency is appropriate?
freq_interesting.append(fn*0.9)
p = sys.pole()
p = p[p != -1.]
features = np.concatenate((features, np.abs(np.log(p) / sys.dt)))
z = sys.zero()
z = z[(z.imag != 0.0)] # Get rid of poles and zeros at the origin and real <= 0 & imag==0
features = np.concatenate((features, np.abs(np.log(z) / sys.dt)))
# TODO: What distance to the Nyquist frequency is appropriate?
freq_interesting.append(fn * 0.9)

features_ = np.concatenate((sys.pole(),
sys.zero()))
# Get rid of poles and zeros
# * at the origin and real <= 0 & imag==0: log!
# * at 1.: would result in omega=0. (logaritmic plot!)
features_ = features_[(features_.imag != 0.0) | (features_.real > 0.)]
features_ = features_[np.bitwise_not((features_.imag == 0.0) & (np.abs(features_.real - 1.0) < 1.e-10))]
# TODO: improve
features__ = np.abs(np.log(features_) / (1.j * sys.dt))
features = np.concatenate((features, features__))
else:
# TODO
raise NotImplementedError('type of system in not implemented now')
Expand All @@ -466,7 +471,7 @@ def default_frequency_range(syslist, Hz=None, number_of_samples=None, feature_pe

# Make sure there is at least one point in the range
if (features.shape[0] == 0):
features = [1];
features = np.array([1]);

if Hz:
features /= 2.*np.pi
Expand Down
55 changes: 32 additions & 23 deletions examples/bode-plot.ipynb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
"signature": "sha256:2416b0175371454a997b2a6cd448368a26e5913058bba72d188ec84dd29a7784"
"signature": "sha256:bb8169741807e084dda69a0ed35f00bb23568ea1695b9268b1208f4b57b73508"
},
"nbformat": 3,
"nbformat_minor": 0,
Expand Down Expand Up @@ -1137,7 +1137,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x11db1d50>"
"<IPython.core.display.Javascript at 0x13181e70>"
]
},
{
Expand All @@ -1147,7 +1147,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x11dd74d0>"
"<IPython.core.display.HTML at 0x131ae630>"
]
}
],
Expand Down Expand Up @@ -1934,7 +1934,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x11db1e10>"
"<IPython.core.display.Javascript at 0x13090ab0>"
]
},
{
Expand All @@ -1944,7 +1944,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x11f3db10>"
"<IPython.core.display.HTML at 0x132e2c70>"
]
}
],
Expand Down Expand Up @@ -2735,7 +2735,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x11db1ed0>"
"<IPython.core.display.Javascript at 0x131ae050>"
]
},
{
Expand All @@ -2745,7 +2745,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x120449d0>"
"<IPython.core.display.HTML at 0x133e9b10>"
]
}
],
Expand Down Expand Up @@ -3532,7 +3532,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x11db1c30>"
"<IPython.core.display.Javascript at 0x131ae730>"
]
},
{
Expand All @@ -3542,7 +3542,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x1214ced0>"
"<IPython.core.display.HTML at 0x13561fb0>"
]
}
],
Expand Down Expand Up @@ -4308,7 +4308,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x11cdae30>"
"<IPython.core.display.Javascript at 0x131ae070>"
]
},
{
Expand All @@ -4318,7 +4318,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x1227ee30>"
"<IPython.core.display.HTML at 0x13679f70>"
]
}
],
Expand Down Expand Up @@ -5073,7 +5073,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x11cdad70>"
"<IPython.core.display.Javascript at 0x13090e10>"
]
},
{
Expand All @@ -5083,7 +5083,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x12368d10>"
"<IPython.core.display.HTML at 0x1373be50>"
]
}
],
Expand Down Expand Up @@ -5840,7 +5840,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x12044730>"
"<IPython.core.display.Javascript at 0x13561cf0>"
]
},
{
Expand All @@ -5850,7 +5850,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x124cc4d0>"
"<IPython.core.display.HTML at 0x138d0610>"
]
}
],
Expand Down Expand Up @@ -6616,7 +6616,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x122e8490>"
"<IPython.core.display.Javascript at 0x131ae110>"
]
},
{
Expand All @@ -6626,7 +6626,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x121a0f70>"
"<IPython.core.display.HTML at 0x135c3c70>"
]
}
],
Expand Down Expand Up @@ -7381,7 +7381,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x11cdacd0>"
"<IPython.core.display.Javascript at 0x13679b90>"
]
},
{
Expand All @@ -7391,7 +7391,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x14787b90>"
"<IPython.core.display.HTML at 0x147c0cd0>"
]
}
],
Expand Down Expand Up @@ -8149,7 +8149,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x1246cf90>"
"<IPython.core.display.Javascript at 0x13870e30>"
]
},
{
Expand All @@ -8159,7 +8159,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x148e9df0>"
"<IPython.core.display.HTML at 0x148c4f30>"
]
}
],
Expand Down Expand Up @@ -8907,7 +8907,7 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.Javascript at 0x1246c0b0>"
"<IPython.core.display.Javascript at 0x138709d0>"
]
},
{
Expand All @@ -8917,12 +8917,21 @@
"metadata": {},
"output_type": "display_data",
"text": [
"<IPython.core.display.HTML at 0x14b2e3f0>"
"<IPython.core.display.HTML at 0x14b49510>"
]
}
],
"prompt_number": 32
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 32
},
{
"cell_type": "code",
"collapsed": false,
Expand Down