def breakup(ref, minval, maxima):
    """
    This function segments the entire 2-D array into areas belonging to each identified
    maximum according to a watershed algorithm.
    """
    ref_t = np.zeros(ref.shape)
    ref_t[:] = minval
    ref_t[ref > minval] = ref[ref > minval]
    markers = ndi.label(maxima)[0]
    areas = skis.watershed(-ref_t, markers=markers)
    lines = skis.watershed(-ref_t, markers=markers, watershed_line=True)

    return areas, lines
This function segments the entire 2-D array into areas belonging to each identified
maximum according to a watershed algorithm.
pysteps/feature/tstorm.py