當前位置: 首頁>>代碼示例>>Python>>正文


Python signal.find_peaks_cwt方法代碼示例

本文整理匯總了Python中scipy.signal.find_peaks_cwt方法的典型用法代碼示例。如果您正苦於以下問題:Python signal.find_peaks_cwt方法的具體用法?Python signal.find_peaks_cwt怎麽用?Python signal.find_peaks_cwt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scipy.signal的用法示例。


在下文中一共展示了signal.find_peaks_cwt方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: detect_lines

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import find_peaks_cwt [as 別名]
def detect_lines(x, y, kernal_size=3, centroid_kernal=default_kernal, 
                 center=False):
    """Detect lines goes through a 1-D spectra and detect peaks

    Parameters
    ----------
    x: ~numpy.ndarray
        Array describing the x-position 

    y: ~numpy.ndarray
        Array describing the counts in each x-position

    kernal_size: int
        Size for the detection kernal

    centroid_kernal: 
        Kernal to be used for centroiding

    center: boolean
        If True, centroid for detected peaks will be calculated

    Returns
    -------
    xp: ~numpy.ndarray
        Array of x-positions of peaks in the spectrum
    """
    # find all peaks
    xp = signal.find_peaks_cwt(y, np.array([kernal_size]))
    xp = np.array(xp)

    # set the output values
    if center:
        xdiff = int(0.5 * len(centroid_kernal) + 1)
        x_arr = np.arange(len(x))
        xp = xp * 1.0
        for i in range(len(xp)):
            xp[i] = mcentroid(x, y, kern=centroid_kernal, xdiff=xdiff, xc=x[xp[i]])

    return xp 
開發者ID:crawfordsm,項目名稱:specidentify,代碼行數:41,代碼來源:spectools.py

示例2: get_frequencies_from_correlation

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import find_peaks_cwt [as 別名]
def get_frequencies_from_correlation(correlation_vector,test_frequencies_range):

    frequencies = []
    for branch in range(correlation_vector.shape[1]):
        peakind = signal.find_peaks_cwt(correlation_vector[:,branch].real, np.arange(1,200) )

     #   plt.plot(test_frequencies_range,correlation_vector[:,branch].real)
     #   plt.plot([test_frequencies_range[i] for i in peakind],[correlation_vector[i,branch].real for i in peakind],'ro')
     #   plt.show()

        heights = [correlation_vector[i,branch] for i in peakind]
        max_height_index = heights.index(max(heights))
        frequencies.append(test_frequencies_range[peakind[max_height_index]])

    return np.array(frequencies) 
開發者ID:abelcarreras,項目名稱:DynaPhoPy,代碼行數:17,代碼來源:peaksearch.py

示例3: get_peaks

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import find_peaks_cwt [as 別名]
def get_peaks(x, n):
    return find_peaks_cwt(x, widths=np.arange(1, n + 1), wavelet=ricker) 
開發者ID:kavvkon,項目名稱:enlopy,代碼行數:4,代碼來源:stats.py

示例4: test_single_continuous_property

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import find_peaks_cwt [as 別名]
def test_single_continuous_property(self):
        # Tested on a water molecule
        system = ase.build.molecule("H2O")

        # Descriptor setup
        std = 0.1
        elements = ["H", "O"]
        peaks = [0.3, 2.0]
        values = dict(zip(elements, peaks))
        elemdist = ElementalDistribution(
            properties={
                "first_property": {
                    "type": "continuous",
                    "min": 0,
                    "max": 2.5,
                    "std": std,
                    "n": 50,
                    "values": values
                }
            }
        )

        # Features
        y = elemdist.create(system)
        y = y.todense().A1
        x = elemdist.get_axis("first_property")

        # Test that the peak positions match
        from scipy.signal import find_peaks_cwt
        peak_indices = find_peaks_cwt(y, [std])
        peak_loc = x[peak_indices]

        # Test that the peak locations match within some tolerance
        self.assertTrue(np.allclose(peaks, peak_loc, rtol=0, atol=0.05))

        # Plot for visual inspection
        # mpl.plot(x, y)
        # mpl.show() 
開發者ID:SINGROUP,項目名稱:dscribe,代碼行數:40,代碼來源:elementaldistribution.py

示例5: fragment_length_qc

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import find_peaks_cwt [as 別名]
def fragment_length_qc(data, prefix):
    results = []

    NFR_UPPER_LIMIT = 150
    MONO_NUC_LOWER_LIMIT = 150
    MONO_NUC_UPPER_LIMIT = 300

    # % of NFR vs res
    nfr_reads = data[data[:, 0] < NFR_UPPER_LIMIT][:, 1]
    percent_nfr = nfr_reads.sum() / data[:, 1].sum()
    results.append(
        QCGreaterThanEqualCheck('Fraction of reads in NFR', 0.4)(percent_nfr))

    # % of NFR vs mononucleosome
    mono_nuc_reads = data[
        (data[:, 0] > MONO_NUC_LOWER_LIMIT) &
        (data[:, 0] <= MONO_NUC_UPPER_LIMIT)][:, 1]

    percent_nfr_vs_mono_nuc = (
        nfr_reads.sum() /
        mono_nuc_reads.sum())
    results.append(
        QCGreaterThanEqualCheck('NFR / mono-nuc reads', 2.5)(
            percent_nfr_vs_mono_nuc))

    # peak locations
    pos_start_val = data[0, 0]  # this may be greater than 0
    peaks = find_peaks_cwt(data[:, 1], np.array([25]))
    nuc_range_metrics = [
        ('Presence of NFR peak', 20 - pos_start_val, 90 - pos_start_val),
        ('Presence of Mono-Nuc peak',
         120 - pos_start_val, 250 - pos_start_val),
        ('Presence of Di-Nuc peak',
         300 - pos_start_val, 500 - pos_start_val)]
    for range_metric in nuc_range_metrics:
        results.append(QCHasElementInRange(*range_metric)(peaks))

    out = prefix + '.nucleosomal.qc'
    with open(out, 'w') as fp:
        for elem in results:
            fp.write(
                '\t'.join(
                    [elem.metric, str(elem.qc_pass), elem.message]) + '\n')

    return out 
開發者ID:ENCODE-DCC,項目名稱:atac-seq-pipeline,代碼行數:47,代碼來源:encode_task_fraglen_stat_pe.py


注:本文中的scipy.signal.find_peaks_cwt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。