(im_ms, cloud_mask, im_bool)
return features
Calculates features on the image that are used for the supervised classification. 
    The features include spectral normalized-difference indices and standard 
    deviation of the image for all the bands and indices.

    KV WRL 2018

    Arguments:
    -----------
    im_ms: np.array
        RGB + downsampled NIR and SWIR
    cloud_mask: np.array
        2D cloud mask with True where cloud pixels are
    im_bool: np.array
        2D array of boolean indicating where on the image to calculate the features

    Returns:    
    -----------
    features: np.array
        matrix containing each feature (columns) calculated for all
        the pixels (rows) indicated in im_bool
Calculates features on the image that are used for the supervised classification. 
    The features include spectral normalized-difference indices and standard 
    deviation of the image for all the bands and indices.
Calculates features on the image that are used for the supervised classification . The features include spectral normalized - difference indices and standard deviation of the image for all the bands and indices .
def calculate_features(im_ms, cloud_mask, im_bool):
    """
    Calculates features on the image that are used for the supervised classification. 
    The features include spectral normalized-difference indices and standard 
    deviation of the image for all the bands and indices.

    KV WRL 2018

    Arguments:
    -----------
    im_ms: np.array
        RGB + downsampled NIR and SWIR
    cloud_mask: np.array
        2D cloud mask with True where cloud pixels are
    im_bool: np.array
        2D array of boolean indicating where on the image to calculate the features

    Returns:    
    -----------
    features: np.array
        matrix containing each feature (columns) calculated for all
        the pixels (rows) indicated in im_bool
        
    """

    # add all the multispectral bands
    features = np.expand_dims(im_ms[im_bool,0],axis=1)
    for k in range(1,im_ms.shape[2]):
        feature = np.expand_dims(im_ms[im_bool,k],axis=1)
        features = np.append(features, feature, axis=-1)
    # NIR-G
    im_NIRG = SDS_tools.nd_index(im_ms[:,:,3], im_ms[:,:,1], cloud_mask)
    features = np.append(features, np.expand_dims(im_NIRG[im_bool],axis=1), axis=-1)
    # SWIR-G
    im_SWIRG = SDS_tools.nd_index(im_ms[:,:,4], im_ms[:,:,1], cloud_mask)
    features = np.append(features, np.expand_dims(im_SWIRG[im_bool],axis=1), axis=-1)
    # NIR-R
    im_NIRR = SDS_tools.nd_index(im_ms[:,:,3], im_ms[:,:,2], cloud_mask)
    features = np.append(features, np.expand_dims(im_NIRR[im_bool],axis=1), axis=-1)
    # SWIR-NIR
    im_SWIRNIR = SDS_tools.nd_index(im_ms[:,:,4], im_ms[:,:,3], cloud_mask)
    features = np.append(features, np.expand_dims(im_SWIRNIR[im_bool],axis=1), axis=-1)
    # B-R
    im_BR = SDS_tools.nd_index(im_ms[:,:,0], im_ms[:,:,2], cloud_mask)
    features = np.append(features, np.expand_dims(im_BR[im_bool],axis=1), axis=-1)
    # calculate standard deviation of individual bands
    for k in range(im_ms.shape[2]):
        im_std =  SDS_tools.image_std(im_ms[:,:,k], 1)
        features = np.append(features, np.expand_dims(im_std[im_bool],axis=1), axis=-1)
    # calculate standard deviation of the spectral indices
    im_std = SDS_tools.image_std(im_NIRG, 1)
    features = np.append(features, np.expand_dims(im_std[im_bool],axis=1), axis=-1)
    im_std = SDS_tools.image_std(im_SWIRG, 1)
    features = np.append(features, np.expand_dims(im_std[im_bool],axis=1), axis=-1)
    im_std = SDS_tools.image_std(im_NIRR, 1)
    features = np.append(features, np.expand_dims(im_std[im_bool],axis=1), axis=-1)
    im_std = SDS_tools.image_std(im_SWIRNIR, 1)
    features = np.append(features, np.expand_dims(im_std[im_bool],axis=1), axis=-1)
    im_std = SDS_tools.image_std(im_BR, 1)
    features = np.append(features, np.expand_dims(im_std[im_bool],axis=1), axis=-1)

    return features
def calculate_features ( im_ms , cloud_mask , im_bool ) : # add all the multispectral bands features = np . expand_dims ( im_ms [ im_bool , 0 ] , axis = 1 ) for k in range ( 1 , im_ms . shape [ 2 ] ) : feature = np . expand_dims ( im_ms [ im_bool , k ] , axis = 1 ) features = np . append ( features , feature , axis = - 1 ) # NIR-G im_NIRG = SDS_tools . nd_index ( im_ms [ : , : , 3 ] , im_ms [ : , : , 1 ] , cloud_mask ) features = np . append ( features , np . expand_dims ( im_NIRG [ im_bool ] , axis = 1 ) , axis = - 1 ) # SWIR-G im_SWIRG = SDS_tools . nd_index ( im_ms [ : , : , 4 ] , im_ms [ : , : , 1 ] , cloud_mask ) features = np . append ( features , np . expand_dims ( im_SWIRG [ im_bool ] , axis = 1 ) , axis = - 1 ) # NIR-R im_NIRR = SDS_tools . nd_index ( im_ms [ : , : , 3 ] , im_ms [ : , : , 2 ] , cloud_mask ) features = np . append ( features , np . expand_dims ( im_NIRR [ im_bool ] , axis = 1 ) , axis = - 1 ) # SWIR-NIR im_SWIRNIR = SDS_tools . nd_index ( im_ms [ : , : , 4 ] , im_ms [ : , : , 3 ] , cloud_mask ) features = np . append ( features , np . expand_dims ( im_SWIRNIR [ im_bool ] , axis = 1 ) , axis = - 1 ) # B-R im_BR = SDS_tools . nd_index ( im_ms [ : , : , 0 ] , im_ms [ : , : , 2 ] , cloud_mask ) features = np . append ( features , np . expand_dims ( im_BR [ im_bool ] , axis = 1 ) , axis = - 1 ) # calculate standard deviation of individual bands for k in range ( im_ms . shape [ 2 ] ) : im_std = SDS_tools . image_std ( im_ms [ : , : , k ] , 1 ) features = np . append ( features , np . expand_dims ( im_std [ im_bool ] , axis = 1 ) , axis = - 1 ) # calculate standard deviation of the spectral indices im_std = SDS_tools . image_std ( im_NIRG , 1 ) features = np . append ( features , np . expand_dims ( im_std [ im_bool ] , axis = 1 ) , axis = - 1 ) im_std = SDS_tools . image_std ( im_SWIRG , 1 ) features = np . append ( features , np . expand_dims ( im_std [ im_bool ] , axis = 1 ) , axis = - 1 ) im_std = SDS_tools . image_std ( im_NIRR , 1 ) features = np . append ( features , np . expand_dims ( im_std [ im_bool ] , axis = 1 ) , axis = - 1 ) im_std = SDS_tools . image_std ( im_SWIRNIR , 1 ) features = np . append ( features , np . expand_dims ( im_std [ im_bool ] , axis = 1 ) , axis = - 1 ) im_std = SDS_tools . image_std ( im_BR , 1 ) features = np . append ( features , np . expand_dims ( im_std [ im_bool ] , axis = 1 ) , axis = - 1 ) return features