def applyCutlerLinearLogScale(grayImage, roi):
    
    TOP_SECTION_PERCENTILE = 99
    TOP_SECTION_START      = 221
    topRange = 256 - TOP_SECTION_START
    
    # Compute a histogram of the entire area
    # - Do this at a lower resolution to reduce computation time
    
    PERCENTILE_SCALE = 50 # Resolution in meters to compute the percentile at
    percentiles = grayImage.reduceRegion(ee.Reducer.percentile([0, TOP_SECTION_PERCENTILE, 100], ['min', 'split', 'max']),
                                         roi, PERCENTILE_SCALE).getInfo()
    
    # Extracting the results is annoying because EE prepends the channel name
    minVal   = next(val for key, val in percentiles.items() if 'min'   in key)
    splitVal = next(val for key, val in percentiles.items() if 'split' in key)
    maxVal   = next(val for key, val in percentiles.items() if 'max'   in key)
    
    lowRange    = splitVal - minVal
    
    logMin   = math.log10(splitVal)
    logMax   = math.log10(maxVal)
    logRange = logMax - logMin
    
    #addToMap(grayImage.select(['vh']), {}, 'vh',   False)
    # Intensities from 0  to  98th percent are mapped to   0 - 220 on a linear scale
    # Intensities from 99 to 100th percent are mapped to 221 - 255 on a log scale
    lowMask       = grayImage.lt(splitVal )
    highMask      = grayImage.gte(splitVal)
    #addToMap(lowMask,  {'min': 0, 'max': 1,  'opacity': 1.0, 'palette': GRAY_PALETTE}, 'low range',   False)
    #addToMap(highMask, {'min': 0, 'max': 1,  'opacity': 1.0, 'palette': GRAY_PALETTE}, 'high range',   False)
    linearPortion = grayImage.subtract(minVal).divide(lowRange).multiply(TOP_SECTION_START-1).multiply(lowMask )#.uint8()
    logPortion    = grayImage.log10().subtract(logMin).divide(logRange).multiply(topRange).add(TOP_SECTION_START).multiply(highMask)
    #addToMap(linearPortion, {'min': 0, 'max': 255,  'opacity': 1.0, 'palette': GRAY_PALETTE}, 'linear',   False)
    #addToMap(logPortion,    {'min': 0, 'max': 255,  'opacity': 1.0, 'palette': GRAY_PALETTE}, 'log',   False)
    scaledImage   = linearPortion.add(logPortion)
    
    return scaledImage
Decorator - mark a function or method for skipping its doctest.
dataset/ETHPy150Open nasa/CrisisMappingToolkit/cmt/radar/martinis.py/applyCutlerLinearLogScale--crossover with--dataset/ETHPy150Open ipython/ipython-py3k/IPython/testing/skipdoctest.py/skip_doctest