src/cirrus/builtins/tasks/add-preview/lambda_function.py
def calculate_ccc_values(filename, logger, lo=2.0, hi=96.0, bins=1000):
    """ Determine min and and max values for a Cumulative Count Cut """
    ds = gdal.Open(filename)
    band = ds.GetRasterBand(1)
    # min, max, mean, std
    stats = band.GetStatistics(False, True)
    hist = numpy.array(band.GetHistogram(stats[0], stats[1], buckets=bins, approx_ok=False))
    nchist = (hist/hist.sum()).cumsum() * 100
    lo_inds = numpy.where(nchist <= lo)[0]
    hi_inds = numpy.where(nchist >= hi)[0]
    lo_ind = lo_inds[-1] if len(lo_inds) > 0 else 0
    hi_ind = hi_inds[0] if len(hi_inds) > 0 else len(hist)-1
    ds = None
    q = (stats[1] - stats[0]) / bins
    lo_val = stats[0] + lo_ind * q
    hi_val = stats[0] + hi_ind * q
    return [lo_val, hi_val]
 Determine min and and max values for a Cumulative Count Cut 
Determine min and and max values for a Cumulative Count Cut
Determine min and and max values for a Cumulative Count Cut
def calculate_ccc_values(filename, logger, lo=2.0, hi=96.0, bins=1000):
    ds = gdal.Open(filename)
    band = ds.GetRasterBand(1)
    stats = band.GetStatistics(False, True)
    hist = numpy.array(band.GetHistogram(stats[0], stats[1], buckets=bins, approx_ok=False))
    nchist = (hist/hist.sum()).cumsum() * 100
    lo_inds = numpy.where(nchist <= lo)[0]
    hi_inds = numpy.where(nchist >= hi)[0]
    lo_ind = lo_inds[-1] if len(lo_inds) > 0 else 0
    hi_ind = hi_inds[0] if len(hi_inds) > 0 else len(hist)-1
    ds = None
    q = (stats[1] - stats[0]) / bins
    lo_val = stats[0] + lo_ind * q
    hi_val = stats[0] + hi_ind * q
    return [lo_val, hi_val]
def calculate_ccc_values ( filename , logger , lo = 2.0 , hi = 96.0 , bins = 1000 ) : ds = gdal . Open ( filename ) band = ds . GetRasterBand ( 1 ) stats = band . GetStatistics ( False , True ) hist = numpy . array ( band . GetHistogram ( stats [ 0 ] , stats [ 1 ] , buckets = bins , approx_ok = False ) ) nchist = ( hist / hist . sum ( ) ) . cumsum ( ) * 100 lo_inds = numpy . where ( nchist <= lo ) [ 0 ] hi_inds = numpy . where ( nchist >= hi ) [ 0 ] lo_ind = lo_inds [ - 1 ] if len ( lo_inds ) > 0 else 0 hi_ind = hi_inds [ 0 ] if len ( hi_inds ) > 0 else len ( hist ) - 1 ds = None q = ( stats [ 1 ] - stats [ 0 ] ) / bins lo_val = stats [ 0 ] + lo_ind * q hi_val = stats [ 0 ] + hi_ind * q return [ lo_val , hi_val ]
Determine min and and max values for a Cumulative Count Cut
Determine min and and max values for a Cumulative Count Cut
""" Determine min and and max values for a Cumulative Count Cut """ # min, max, mean, std
filename
logger
lo
hi
bins