def top_and_tail(a):
    """
    Remove the NaNs from the top and tail (only) of a well log.

    Args:
        a (ndarray): An array.
    Returns:
        ndarray: The top and tailed array.
    """
    if np.all(np.isnan(a)):
        return np.array([])
    nans = np.where(~np.isnan(a))[0]
    last = None if nans[-1]+1 == a.size else nans[-1]+1
    return a[nans[0]:last]
Remove the NaNs from the top and tail (only) of a well log.

    Args:
        a (ndarray): An array.
    Returns:
        ndarray: The top and tailed array.