def packet_power(trace, plength, midpoint):
    """Return power of a packet

    This function is pretty boring, it just finds a window around a point in a trace.

    Parameters
    ----------
    trace: 1d numpy.ndarray
        The trace in which to find the window
    plength: float
        The size of the packet (in samples)
    midpoint: int
        The central sample

    Returns
    -------
    powerpacket: 1d numpy.ndarray
        The packet of length plength
    topsnum: int
        The index of the top sample (desirable for calculating overall indices in functions that call this one).
    """
    if len(trace.shape) > 1:
        raise ValueError('Need a single, flat trace')
    topsnum = int(midpoint - plength / 2.0)
    bottom = int(midpoint + plength / 2.0)
    powerpacket = trace[topsnum:bottom]
    return powerpacket, topsnum
