本文整理匯總了Python中numpy.polymul方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.polymul方法的具體用法?Python numpy.polymul怎麽用?Python numpy.polymul使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.polymul方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _polysqr
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import polymul [as 別名]
def _polysqr(pol):
"""return a polynomial squared"""
return np.polymul(pol, pol)
# Took the framework for the old function by
# Sawyer B. Fuller <minster@caltech.edu>, removed a lot of the innards
# and replaced with analytical polynomial functions for LTI systems.
#
# idea for the frequency data solution copied/adapted from
# https://github.com/alchemyst/Skogestad-Python/blob/master/BODE.py
# Rene van Paassen <rene.vanpaassen@gmail.com>
#
# RvP, July 8, 2014, corrected to exclude phase=0 crossing for the gain
# margin polynomial
# RvP, July 8, 2015, augmented to calculate all phase/gain crossings with
# frd data. Correct to return smallest phase
# margin, smallest gain margin and their frequencies
# RvP, Jun 10, 2017, modified the inclusion of roots found for phase
# crossing to include all >= 0, made subsequent calc
# insensitive to div by 0
# also changed the selection of which crossings to
# return on basis of "A note on the Gain and Phase
# Margin Concepts" Journal of Control and Systems
# Engineering, Yazdan Bavafi-Toosi, Dec 2015, vol 3
# issue 1, pp 51-59, closer to Matlab behavior, but
# not completely identical in edge cases, which don't
# cross but touch gain=1
示例2: phase_crossover_frequencies
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import polymul [as 別名]
def phase_crossover_frequencies(sys):
"""Compute frequencies and gains at intersections with real axis
in Nyquist plot.
Call as:
omega, gain = phase_crossover_frequencies()
Returns
-------
omega: 1d array of (non-negative) frequencies where Nyquist plot
intersects the real axis
gain: 1d array of corresponding gains
Examples
--------
>>> tf = TransferFunction([1], [1, 2, 3, 4])
>>> PhaseCrossoverFrequenies(tf)
(array([ 1.73205081, 0. ]), array([-0.5 , 0.25]))
"""
# Convert to a transfer function
tf = xferfcn._convert_to_transfer_function(sys)
# if not siso, fall back to (0,0) element
#! TODO: should add a check and warning here
num = tf.num[0][0]
den = tf.den[0][0]
# Compute frequencies that we cross over the real axis
numj = (1.j)**np.arange(len(num)-1,-1,-1)*num
denj = (-1.j)**np.arange(len(den)-1,-1,-1)*den
allfreq = np.roots(np.imag(np.polymul(numj,denj)))
realfreq = np.real(allfreq[np.isreal(allfreq)])
realposfreq = realfreq[realfreq >= 0.]
# using real() to avoid rounding errors and results like 1+0j
# it would be nice to have a vectorized version of self.evalfr here
gain = np.real(np.asarray([tf._evalfr(f)[0][0] for f in realposfreq]))
return realposfreq, gain
示例3: test_mem_polymul
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import polymul [as 別名]
def test_mem_polymul(self):
# Ticket #448
np.polymul([], [1.])
示例4: sos2tf
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import polymul [as 別名]
def sos2tf(sos):
"""
Return a single transfer function from a series of second-order sections
Parameters
----------
sos : array_like
Array of second-order filter coefficients, must have shape
``(n_sections, 6)``. See `sosfilt` for the SOS filter format
specification.
Returns
-------
b : ndarray
Numerator polynomial coefficients.
a : ndarray
Denominator polynomial coefficients.
Notes
-----
.. versionadded:: 0.16.0
"""
sos = np.asarray(sos)
b = [1.]
a = [1.]
n_sections = sos.shape[0]
for section in range(n_sections):
b = np.polymul(b, sos[section, :3])
a = np.polymul(a, sos[section, 3:])
return b, a
示例5: test_mem_polymul
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import polymul [as 別名]
def test_mem_polymul(self, level=rlevel):
# Ticket #448
np.polymul([], [1.])
示例6: test_mem_polymul
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import polymul [as 別名]
def test_mem_polymul(self, level=rlevel):
"""Ticket #448"""
np.polymul([], [1.])
示例7: A_weighting
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import polymul [as 別名]
def A_weighting(fs):
"""Design of an A-weighting filter.
b, a = A_weighting(fs) designs a digital A-weighting filter for
sampling frequency `fs`. Usage: y = scipy.signal.lfilter(b, a, x).
Warning: `fs` should normally be higher than 20 kHz. For example,
fs = 48000 yields a class 1-compliant filter.
References:
[1] IEC/CD 1672: Electroacoustics-Sound Level Meters, Nov. 1996.
"""
# Definition of analog A-weighting filter according to IEC/CD 1672.
f1 = 20.598997
f2 = 107.65265
f3 = 737.86223
f4 = 12194.217
A1000 = 1.9997
NUMs = [(2*numpy.pi * f4)**2 * (10**(A1000/20)), 0, 0, 0, 0]
DENs = numpy.polymul([1, 4*numpy.pi * f4, (2*numpy.pi * f4)**2],
[1, 4*numpy.pi * f1, (2*numpy.pi * f1)**2])
DENs = numpy.polymul(numpy.polymul(DENs, [1, 2*numpy.pi * f3]),
[1, 2*numpy.pi * f2])
# Use the bilinear transformation to get the digital filter.
# (Octave, MATLAB, and PyLab disagree about Fs vs 1/Fs)
return bilinear(NUMs, DENs, fs)