def calculate_amplitudes(signal, crossings):
    # FIXME: slow (can we remain entirely in numpy here?)
    #return np.asarray([chunk.mean() if chunk.any() else 0 for chunk in np.split(np.abs(signal), crossings)[:-1]])
    # amazingly it is faster to call np.add.reduce()/len() than to use the numpy mean() method.
    return np.asarray([np.add.reduce(chunk)/len(chunk) if chunk.any() else 0 for chunk in np.split(np.abs(signal), crossings)[:-1]])