(im1, im2, cloud_mask)
return im_nd
Computes normalised difference index on 2 images (2D), given a cloud mask (2D).

    KV WRL 2018

    Arguments:
    -----------
    im1: np.array
        first image (2D) with which to calculate the ND index
    im2: np.array
        second image (2D) with which to calculate the ND index
    cloud_mask: np.array
        2D cloud mask with True where cloud pixels are

    Returns:    
    -----------
    im_nd: np.array
        Image (2D) containing the ND index
Computes normalised difference index on 2 images (2D), given a cloud mask (2D).
Computes normalised difference index on 2 images ( 2D ) given a cloud mask ( 2D ) .
def nd_index(im1, im2, cloud_mask):
    """
    Computes normalised difference index on 2 images (2D), given a cloud mask (2D).

    KV WRL 2018

    Arguments:
    -----------
    im1: np.array
        first image (2D) with which to calculate the ND index
    im2: np.array
        second image (2D) with which to calculate the ND index
    cloud_mask: np.array
        2D cloud mask with True where cloud pixels are

    Returns:    
    -----------
    im_nd: np.array
        Image (2D) containing the ND index
        
    """

    # reshape the cloud mask
    vec_mask = cloud_mask.reshape(im1.shape[0] * im1.shape[1])
    # initialise with NaNs
    vec_nd = np.ones(len(vec_mask)) * np.nan
    # reshape the two images
    vec1 = im1.reshape(im1.shape[0] * im1.shape[1])
    vec2 = im2.reshape(im2.shape[0] * im2.shape[1])
    # compute the normalised difference index
    temp = np.divide(vec1[~vec_mask] - vec2[~vec_mask],
                     vec1[~vec_mask] + vec2[~vec_mask])
    vec_nd[~vec_mask] = temp
    # reshape into image
    im_nd = vec_nd.reshape(im1.shape[0], im1.shape[1])

    return im_nd
def nd_index ( im1 , im2 , cloud_mask ) : # reshape the cloud mask vec_mask = cloud_mask . reshape ( im1 . shape [ 0 ] * im1 . shape [ 1 ] ) # initialise with NaNs vec_nd = np . ones ( len ( vec_mask ) ) * np . nan # reshape the two images vec1 = im1 . reshape ( im1 . shape [ 0 ] * im1 . shape [ 1 ] ) vec2 = im2 . reshape ( im2 . shape [ 0 ] * im2 . shape [ 1 ] ) # compute the normalised difference index temp = np . divide ( vec1 [ ~ vec_mask ] - vec2 [ ~ vec_mask ] , vec1 [ ~ vec_mask ] + vec2 [ ~ vec_mask ] ) vec_nd [ ~ vec_mask ] = temp # reshape into image im_nd = vec_nd . reshape ( im1 . shape [ 0 ] , im1 . shape [ 1 ] ) return im_nd