cumulative_density_function_per_country.py
def calculate_cdf(raster_path, percentile_list):
    """Calculate the CDF given its percentile list."""
    cdf_array = [0.0] * len(percentile_list)
    nodata = pygeoprocessing.get_raster_info(
        raster_path)['nodata'][0]
    pixel_count = 0
    for _, data_block in pygeoprocessing.iterblocks(
            (raster_path, 1)):
        nodata_mask = ~numpy.isclose(data_block, nodata)
        pixel_count += numpy.count_nonzero(nodata_mask)
        for index, percentile_value in enumerate(percentile_list):
            cdf_array[index] += numpy.sum(data_block[
                nodata_mask & (data_block >= percentile_value)])
    return cdf_array
Calculate the CDF given its percentile list.
Calculate the CDF given its percentile list.
Calculate the CDF given its percentile list .
def calculate_cdf(raster_path, percentile_list):
    cdf_array = [0.0] * len(percentile_list)
    nodata = pygeoprocessing.get_raster_info(
        raster_path)['nodata'][0]
    pixel_count = 0
    for _, data_block in pygeoprocessing.iterblocks(
            (raster_path, 1)):
        nodata_mask = ~numpy.isclose(data_block, nodata)
        pixel_count += numpy.count_nonzero(nodata_mask)
        for index, percentile_value in enumerate(percentile_list):
            cdf_array[index] += numpy.sum(data_block[
                nodata_mask & (data_block >= percentile_value)])
    return cdf_array
def calculate_cdf ( raster_path , percentile_list ) : cdf_array = [ 0.0 ] * len ( percentile_list ) nodata = pygeoprocessing . get_raster_info ( raster_path ) [ 'nodata' ] [ 0 ] pixel_count = 0 for _ , data_block in pygeoprocessing . iterblocks ( ( raster_path , 1 ) ) : nodata_mask = ~ numpy . isclose ( data_block , nodata ) pixel_count += numpy . count_nonzero ( nodata_mask ) for index , percentile_value in enumerate ( percentile_list ) : cdf_array [ index ] += numpy . sum ( data_block [ nodata_mask & ( data_block >= percentile_value ) ] ) return cdf_array
Calculate the CDF given its percentile list.
Calculate the CDF given its percentile list .
"""Calculate the CDF given its percentile list."""
raster_path
percentile_list