Python numpy.polymul() Examples

The following are 22 code examples of numpy.polymul(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module numpy , or try the search function .
Example #1
Source File: test_regression.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_mem_polymul(self):
        # Ticket #448
        np.polymul([], [1.]) 
Example #2
Source File: test_regression.py    From keras-lambda with MIT License 5 votes vote down vote up
def test_mem_polymul(self, level=rlevel):
        # Ticket #448
        np.polymul([], [1.]) 
Example #3
Source File: test_regression.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_mem_polymul(self):
        # Ticket #448
        np.polymul([], [1.]) 
Example #4
Source File: test_regression.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def test_mem_polymul(self):
        # Ticket #448
        np.polymul([], [1.]) 
Example #5
Source File: spl_lib.py    From spl-meter-with-RPi with MIT License 5 votes vote down vote up
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) 
Example #6
Source File: test_regression.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_mem_polymul(self):
        # Ticket #448
        np.polymul([], [1.]) 
Example #7
Source File: test_regression.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_mem_polymul(self, level=rlevel):
        # Ticket #448
        np.polymul([], [1.]) 
Example #8
Source File: filter_design.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
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 
Example #9
Source File: test_regression.py    From ImageFusion with MIT License 5 votes vote down vote up
def test_mem_polymul(self, level=rlevel):
        # Ticket #448
        np.polymul([], [1.]) 
Example #10
Source File: test_regression.py    From mxnet-lambda with Apache License 2.0 5 votes vote down vote up
def test_mem_polymul(self, level=rlevel):
        # Ticket #448
        np.polymul([], [1.]) 
Example #11
Source File: test_regression.py    From pySINDy with MIT License 5 votes vote down vote up
def test_mem_polymul(self):
        # Ticket #448
        np.polymul([], [1.]) 
Example #12
Source File: margins.py    From python-control with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 
Example #13
Source File: filter_design.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
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 
Example #14
Source File: test_regression.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def test_mem_polymul(self):
        # Ticket #448
        np.polymul([], [1.]) 
Example #15
Source File: test_regression.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
def test_mem_polymul(self):
        # Ticket #448
        np.polymul([], [1.]) 
Example #16
Source File: test_regression.py    From Computable with MIT License 5 votes vote down vote up
def test_mem_polymul(self, level=rlevel):
        """Ticket #448"""
        np.polymul([], [1.]) 
Example #17
Source File: test_regression.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_mem_polymul(self):
        # Ticket #448
        np.polymul([], [1.]) 
Example #18
Source File: test_regression.py    From auto-alt-text-lambda-api with MIT License 5 votes vote down vote up
def test_mem_polymul(self, level=rlevel):
        # Ticket #448
        np.polymul([], [1.]) 
Example #19
Source File: test_regression.py    From lambda-packs with MIT License 5 votes vote down vote up
def test_mem_polymul(self, level=rlevel):
        # Ticket #448
        np.polymul([], [1.]) 
Example #20
Source File: filter_design.py    From lambda-packs with MIT License 5 votes vote down vote up
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 
Example #21
Source File: test_regression.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_mem_polymul(self):
        # Ticket #448
        np.polymul([], [1.]) 
Example #22
Source File: margins.py    From python-control with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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