helpers.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:metaseek 作者: ahoarfrost 项目源码 文件源码
def getMapBins(map_counts, num_bins): #e.g. latlon_map[0]
    #find upper limit of percentile for 0 count (for all data is something like 30th)
    bottom = sp.percentileofscore(map_counts.flatten(), 0.0, kind='weak')
    #define 10 percentile bins, evenly divide rest of bins above 0 count into nine chunks
    step = (100-bottom)/(num_bins-1)
    percentiles = [0]
    for ix in xrange(0,num_bins-1):
        percentiles.append(bottom+(ix*step))
    #find counts that bound each bin
    countRanges = []
    for bin in percentiles:
        countRanges.append(round(np.percentile(map_counts,bin),0))
    countRanges.append(round(np.amax(map_counts),0))
    #define fill colors for each of the bins
    fillColors = []
    for ix in xrange(0,num_bins):
        #the 255*0.8 is the max opacity
        fillColors.append([66, 91, 161, (255*0.8)*(ix/float(num_bins-1))])
    return percentiles, countRanges, fillColors

# Create the actual data to power our map overlay
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号