def METHOD_NAME(h5link):
    """
    get counts array with some error checking for corrupted files,
    especially those that give
       'OSError: Can't read data (inflate() failed)'
    because one data point is bad.
    This seems to be a common enough failure mode that this function looks
    for such points and replaces offending points by the average of the
    neighboring points
    """
    # will usually succeed, of course.
    try:
        return h5link[()]
    except OSError:
        pass
    # find bad point
    npts = h5link.shape[0]
    ilo, ihi = 0, npts
    imid = (ihi-ilo)//2
    while (ihi-ilo) > 1:
        try:
            _tmp = h5link[ilo:imid]
            ilo, imid = imid, ihi
        except OSError:
            ihi, imid = imid, (imid+ilo)//2
    # retest to make sure there is one bad point
    for i in range(ilo, ihi):
        try:
            _tmp = h5link[i]
        except OSError:
            ibad = i
            break
    # its not unusual to have two bad points in a row:
    p1bad = m1bad = False
    try:
        _tmp = h5link[i+1]
    except OSError:
        p1bad = True
    try:
        _tmp = h5link[i-1]
    except OSError:
        m1bad = True
    if  m1bad:
        ibad = ibad - 1
        p1bad = True
    counts = np.zeros(h5link.shape, dtype=h5link.dtype)
    counts[:ibad] = h5link[:ibad]
    counts[ibad+2:] = h5link[ibad+2:]
    if p1bad: # two in a row
        print("fixing 2 bad points in h5 file")
        counts[ibad]   = h5link[ibad-1]
        counts[ibad+1] = h5link[ibad+2]
    else:
        print("fixing bad point in h5 file")
        counts[ibad+1] = h5link[ibad+1]
        if ibad == 0:
            counts[ibad] = counts[ibad+1]
        elif ibad == npts - 1:
            counts[ibad] = counts[ibad-1]
        else:
            counts[ibad] = ((counts[ibad-1]+counts[ibad+1])/2.0).astype(h5link.dtype)
    return counts