Python scipy.signal 模块,argrelmax() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用scipy.signal.argrelmax()

项目:untwist    作者:IoSR-Surrey    | 项目源码 | 文件源码
def process(self, X):
        onset_func = zscore(self.func(X))
        onset_func = signal.filtfilt(self.moving_avg_filter, 1, onset_func)
        onset_func = onset_func - signal.medfilt(
            onset_func[:,np.newaxis], self.median_kernel
        )[:,0]
        peaks = signal.argrelmax(onset_func)
        onsets = peaks[0][np.where(onset_func[peaks[0]] >
            self.threshold)]
        return onsets
项目:piradar    作者:scivision    | 项目源码 | 文件源码
def get_peaks(rx):
  peaks = signal.argrelmax(rx, order=10000)[0]

  peak_diffs = np.diff(peaks)

  if np.isfinite(peak_diffs):
      print('avg peak distance:', peak_diffs.mean())
      print('max peak distance:', peak_diffs.max())
      print('min peak distance:', peak_diffs.min())

      L = peak_diffs.min()
  else:
      L= None

  return peaks, L
项目:neural-segmentation    作者:melsner    | 项目源码 | 文件源码
def pSegs2Segs(pSegs, acoustic=False, threshold=0.1, implementation='delta'):
    if acoustic:
        if implementation == 'delta':
            return relMaxWithDelta(pSegs, threshold)
        else:
            padding = [(0, 0) for d in range(len(pSegs.shape))]
            padding[1] = (1, 1)
            pSegs_padded = np.pad(pSegs, padding, 'constant', constant_values=0.)
            pSegs_padded[pSegs_padded < threshold] = 0
            segs = np.zeros_like(pSegs_padded)
            segs[argrelmax(pSegs_padded, 1)] = 1
            return segs[:, 1:-1, :]
    else:
        return pSegs > 0.5
项目:SpaceX    作者:shahar603    | 项目源码 | 文件源码
def get_landing_burn(data):
    max_q_landing_index = data['q'].index(max(data['q']))
    post_q_data = data_between(data, start=max_q_landing_index)
    minpoint = signal.argrelmax(np.array(post_q_data['acceleration']))[0][0]
    return minpoint + max_q_landing_index, np.argmax(np.array(data['velocity']) < 5)
项目:astrobase    作者:waqasbhatti    | 项目源码 | 文件源码
def _get_acf_peakheights(lags, acf, npeaks=20, searchinterval=1):
    '''This calculates the relative peak heights for first npeaks in ACF.

    Usually, the first peak or the second peak (if its peak height > first peak)
    corresponds to the correct lag. When we know the correct lag, the period is
    then:

    bestperiod = time[lags == bestlag] - time[0]

    '''

    maxinds = argrelmax(acf, order=searchinterval)[0]
    maxacfs = acf[maxinds]
    maxlags = lags[maxinds]
    mininds = argrelmin(acf, order=searchinterval)[0]
    minacfs = acf[mininds]
    minlags = lags[mininds]

    relpeakheights = np.zeros(npeaks)
    relpeaklags = np.zeros(npeaks,dtype=np.int64)
    peakindices = np.zeros(npeaks,dtype=np.int64)

    for peakind, mxi in enumerate(maxinds[:npeaks]):

        # check if there are no mins to the left
        # throw away this peak because it's probably spurious
        # (FIXME: is this OK?)
        if np.all(mxi < mininds):
            continue

        leftminind = mininds[mininds < mxi][-1] # the last index to the left
        rightminind = mininds[mininds > mxi][0] # the first index to the right
        relpeakheights[peakind] = (
            acf[mxi] - (acf[leftminind] + acf[rightminind])/2.0
        )
        relpeaklags[peakind] = lags[mxi]
        peakindices[peakind] = peakind

    # figure out the bestperiod if possible
    if relpeakheights[0] > relpeakheights[1]:
        bestlag = relpeaklags[0]
        bestpeakheight = relpeakheights[0]
        bestpeakindex = peakindices[0]
    else:
        bestlag = relpeaklags[1]
        bestpeakheight = relpeakheights[1]
        bestpeakindex = peakindices[1]

    return {'maxinds':maxinds,
            'maxacfs':maxacfs,
            'maxlags':maxlags,
            'mininds':mininds,
            'minacfs':minacfs,
            'minlags':minlags,
            'relpeakheights':relpeakheights,
            'relpeaklags':relpeaklags,
            'peakindices':peakindices,
            'bestlag':bestlag,
            'bestpeakheight':bestpeakheight,
            'bestpeakindex':bestpeakindex}