def _max_p2t(data, delta):
turning_points = []  <EOL>for i in range(<NUM_LIT:1>, len(data) - <NUM_LIT:1>):<EOL><INDENT>if (data[i] < data[i - <NUM_LIT:1>] and data[i] < data[i + <NUM_LIT:1>]) or(data[i] > data[i - <NUM_LIT:1>] and data[i] > data[i + <NUM_LIT:1>]):<EOL><INDENT>turning_points.append((data[i], i))<EOL><DEDENT><DEDENT>if len(turning_points) >= <NUM_LIT:1>:<EOL><INDENT>amplitudes = np.empty([len(turning_points) - <NUM_LIT:1>],)<EOL>half_periods = np.empty([len(turning_points) - <NUM_LIT:1>],)<EOL><DEDENT>else:<EOL><INDENT>print('<STR_LIT>' + str(len(turning_points)) +<EOL>'<STR_LIT>' + str(len(data)))<EOL>return <NUM_LIT:0.0>, <NUM_LIT:0.0>, <NUM_LIT:0.0><EOL><DEDENT>for i in range(<NUM_LIT:1>, len(turning_points)):<EOL><INDENT>half_periods[i - <NUM_LIT:1>] = (delta * (turning_points[i][<NUM_LIT:1>] -<EOL>turning_points[i - <NUM_LIT:1>][<NUM_LIT:1>]))<EOL>amplitudes[i - <NUM_LIT:1>] = np.abs(turning_points[i][<NUM_LIT:0>] -<EOL>turning_points[i - <NUM_LIT:1>][<NUM_LIT:0>])<EOL><DEDENT>amplitude = np.max(amplitudes)<EOL>period = <NUM_LIT:2> * half_periods[np.argmax(amplitudes)]<EOL>return amplitude, period, delta * turning_points[np.argmax(amplitudes)][<NUM_LIT:1>]<EOL>
Finds the maximum peak-to-trough amplitude and period.
Originally designed to be used to calculate magnitudes (by \
taking half of the peak-to-trough amplitude as the peak amplitude).

:type data: numpy.ndarray
:param data: waveform trace to find the peak-to-trough in.
:type delta: float
:param delta: Sampling interval in seconds

:returns: tuple of (amplitude, period, time) with amplitude in the same \
    scale as given in the input data, and period in seconds, and time in \
    seconds from the start of the data window.
:rtype: tuple