Normalized difference vegetation index.
        :return: NDVI
964188
def ndvi(self):
        
        red, nir = self.reflectance(3), self.reflectance(4)
        ndvi = self._divide_zero((nir - red), (nir + red), nan)

        return ndvi
676676
def lognormal(mu, sigma, random_state):
    '''
    
    '''
    return np.exp(normal(mu, sigma, random_state))
124398
def normalise_correlation_coefficient(image_tile_dict, transformed_array, template, normed_tolerance=1):
    
    template_mean = np.mean(template)
    template_minus_mean = template - template_mean
    template_norm = np.linalg.norm(template_minus_mean)
    image_norms = {(x,y):np.linalg.norm(image_tile_dict[(x,y)]- np.mean(image_tile_dict[(x,y)]))*template_norm for (x,y) in image_tile_dict.keys()}
    match_points = image_tile_dict.keys()
    # for correlation, then need to transofrm back to get correct value for division
    h, w = template.shape
    image_matches_normalised = {match_points[i]:transformed_array[match_points[i][0], match_points[i][1]]/image_norms[match_points[i]] for i in range(len(match_points))}
    normalised_matches = {key:value for key, value in image_matches_normalised.items() if np.round(value, decimals=3) >= normed_tolerance}
    return normalised_matches.keys()
1322840
def normalize(self):
        
        median_diff = np.median(np.diff(self.x))
        bin_edges = [self.x[0] - median_diff/2.0]
        bin_edges.extend(median_diff/2.0 + self.x)
        self.y_raw = self.y_raw/(self.y_raw.sum()*np.diff(bin_edges))
        self.smooth()
522717
def get_normalized_bdew_profile(self):
        
        self.df['temperature'] = self.temperature.values
        self.df['temperature_geo'] = self.weighted_temperature(
            how='geometric_series')

        sf = self.get_sf_values()

        [a, b, c, d] = self.get_sigmoid_parameters()

        f = self.get_weekday_parameters()
        h = (a / (1 + (b / (self.df['temperature_geo'] - 40)) ** c) + d)
        kw = 1.0 / (sum(h * f) / 24)
        heat_profile_normalized = (kw * h * f * sf)

        return heat_profile_normalized
896948
def bandwidth(self):
    """"""
    return np.abs(np.diff(self.pairs(), axis=1)).max()
138937
def normalize(v):
    ''''''
    if 0 == np.linalg.norm(v):
        return v
    return v / np.linalg.norm(v)
808732
def normnorm(self):
        

        n = self.norm()
        return V2(-self.y / n, self.x / n)
116787
def rtruncated_normal(mu, tau, a=-np.inf, b=np.inf, size=None):
    

    sigma = 1. / np.sqrt(tau)
    na = utils.normcdf((a - mu) / sigma)
    nb = utils.normcdf((b - mu) / sigma)

    # Use the inverse CDF generation method.
    U = np.random.mtrand.uniform(size=size)
    q = U * nb + (1 - U) * na
    R = utils.invcdf(q)

    # Unnormalize
    return R * sigma + mu
360266
def bicolor_spectral(self):
    '''
    '''
    lap = self.laplacian().astype(float)
    vals, vecs = eigs(lap, k=1, which='LM')
    vec = vecs[:,0].real
    return vec > 0 if vec[0] > 0 else vec < 0
131026
def get_gadf(self):
        
        adam = (np.abs(self.y - np.median(self.y))).sum()
        gadf = 1 - self.adcm / adam
        return gadf
429298
def _normalize_histogram2d(self, counts, type):
        
        counts = (255 * (counts - np.nanmin(counts)) /
                  (np.nanmax(counts) - np.nanmin(counts)))

        if type == 'reverse_bw':
            counts = 255 - counts

        return counts.astype(np.uint8)
959463
def kdtree(self):
        

        kdtree = KDTree(self.vertices.view(np.ndarray))
        return kdtree
1161233
def normalise_correlation(image_tile_dict, transformed_array, template, normed_tolerance=1):
    
    template_norm = np.linalg.norm(template)
    image_norms = {(x,y):np.linalg.norm(image_tile_dict[(x,y)])*template_norm for (x,y) in image_tile_dict.keys()}
    match_points = image_tile_dict.keys()
    # for correlation, then need to transofrm back to get correct value for division
    h, w = template.shape
    #points_from_transformed_array = [(match[0] + h - 1, match[1] + w - 1) for match in match_points]
    image_matches_normalised = {match_points[i]:transformed_array[match_points[i][0], match_points[i][1]]/image_norms[match_points[i]] for i in range(len(match_points))}
    result = {key:value for key, value in image_matches_normalised.items() if np.round(value, decimals=3) >= normed_tolerance}
    return result.keys()
230247
def get_irradiance_value_for_hoy(self, hoy):
        """"""
        count = int(hoy * self.timestep)
        return self.direct_normal_irradiance[count], \
            self.diffuse_horizontal_irradiance[count]
497121
def _spectral_norm(self):
        
        w = self.params.get('weight').data(self.ctx)
        w_mat = nd.reshape(w, [w.shape[0], -1])

        _u = self.u.data(self.ctx)
        _v = None

        for _ in range(POWER_ITERATION):
            _v = nd.L2Normalization(nd.dot(_u, w_mat))
            _u = nd.L2Normalization(nd.dot(_v, w_mat.T))

        sigma = nd.sum(nd.dot(_u, w_mat) * _v)
        if sigma == 0.:
            sigma = EPSILON

        with autograd.pause():
            self.u.set_data(_u)

        return w / sigma
765308
def plot_knee_normalized(self, ):
        
        import matplotlib.pyplot as plt

        plt.figure(figsize=(8, 8))
        plt.plot(self.xsn, self.ysn)
        plt.plot(self.xd, self.yd, 'r')
        plt.xticks(np.arange(min(self.xsn), max(self.xsn) + 0.1, 0.1))
        plt.yticks(np.arange(min(self.xd), max(self.ysn) + 0.1, 0.1))

        plt.vlines(self.norm_knee, plt.ylim()[0], plt.ylim()[1])