<reponame>zhouming-hfut/sprocket<gh_stars>100-1000
# -*- coding: utf-8 -*-

from __future__ import division, print_function, absolute_import

import numpy as np


def extfrm(data, npow, power_threshold=-20):
    """Extract frame over the power threshold

    Parameters
    ----------
    data: array, shape (`T`, `dim`)
        Array of input data
    npow : array, shape (`T`)
        Vector of normalized power sequence.
    power_threshold : float, optional
        Value of power threshold [dB]
        Default set to -20

    Returns
    -------
    data: array, shape (`T_ext`, `dim`)
        Remaining data after extracting frame
        `T_ext` <= `T`

    """

    T = data.shape[0]
    if T != len(npow):
        raise("Length of two vectors is different.")

    valid_index = np.where(npow > power_threshold)
    extdata = data[valid_index]
    assert extdata.shape[0] <= T

    return extdata

# -*- coding: utf-8 -*-

from __future__ import division, print_function, absolute_import

import numpy as np


def extfrm(data, npow, power_threshold=-20):
    """Extract frame over the power threshold

    Parameters
    ----------
    data: array, shape (`T`, `dim`)
        Array of input data
    npow : array, shape (`T`)
        Vector of normalized power sequence.
    power_threshold : float, optional
        Value of power threshold [dB]
        Default set to -20

    Returns
    -------
    data: array, shape (`T_ext`, `dim`)
        Remaining data after extracting frame
        `T_ext` <= `T`

    """

    T = data.shape[0]
    if T != len(npow):
        raise("Length of two vectors is different.")

    valid_index = np.where(npow > power_threshold)
    extdata = data[valid_index]
    assert extdata.shape[0] <= T

    return extdata
# -*- coding: utf-8 -*- Extract frame over the power threshold      Parameters     ----------     data: array, shape (`T`, `dim`)         Array of input data     npow : array, shape (`T`)         Vector of normalized power sequence.     power_threshold : float, optional         Value of power threshold [dB]         Default set to -20      Returns     -------     data: array, shape (`T_ext`, `dim`)         Remaining data after extracting frame         `T_ext` <= `T`