← Back
Editing: _peak_finding.cpython-311.pyc
� d�c�� � �� � d Z ddlZddlZddlmZmZ ddlmZ ddl m Z mZmZm Z g d�Zdd �Zdd �Zdd�Zdd�Zd � Zd� Zd� Zdd�Zdd�Zd� Zd� Zd� Z dd�Zd� Z dd�Z d d�ZdS )!z- Functions for identifying peaks in signals. � N)�cwt�ricker)�scoreatpercentile� )�_local_maxima_1d�_select_by_peak_distance�_peak_prominences�_peak_widths)� argrelmin� argrelmax� argrelextrema�peak_prominences�peak_widths� find_peaks�find_peaks_cwt�clipc � � t |� � |k s|dk rt d� � �| j | }t j d|� � }t j | j t �� � }| � |||�� � }t d|dz � � D ]o} | � || z ||�� � } | � || z ||�� � }| ||| � � z }| |||� � z }|� � � r|c S �p|S )a� Calculate the relative extrema of `data`. Relative extrema are calculated by finding locations where ``comparator(data[n], data[n+1:n+order+1])`` is True. Parameters ---------- data : ndarray Array in which to find the relative extrema. comparator : callable Function to use to compare two data points. Should take two arrays as arguments. axis : int, optional Axis over which to select from `data`. Default is 0. order : int, optional How many points on each side to use for the comparison to consider ``comparator(n,n+x)`` to be True. mode : str, optional How the edges of the vector are treated. 'wrap' (wrap around) or 'clip' (treat overflow as the same as the last (or first) element). Default 'clip'. See numpy.take. Returns ------- extrema : ndarray Boolean array of the same shape as `data` that is True at an extrema, False otherwise. See also -------- argrelmax, argrelmin Examples -------- >>> import numpy as np >>> testdata = np.array([1,2,3,2,1]) >>> _boolrelextrema(testdata, np.greater, axis=0) array([False, False, True, False, False], dtype=bool) r zOrder must be an int >= 1r ��dtype)�axis�mode) �int� ValueError�shape�np�arange�ones�bool�take�range�any)�data� comparatorr �orderr �datalen�locs�results�main�shift�plus�minuss �</usr/lib/python3/dist-packages/scipy/signal/_peak_finding.py�_boolrelextremar- s � �T �E� � �e��������4�5�5�5��j���G� �9�Q�� � �D��g�d�j��-�-�-�G��9�9�T��4�9�0�0�D��q�%�!�)�$�$� � ���y�y����D�t�y�<�<��� � �$��,�T�� �=�=���:�:�d�D�)�)�)���:�:�d�E�*�*�*���K�K�M�M�>� ��N�N�N� ��N� c �<