Пример #1
0

# setup the coloring
levels = MaxNLocator(nbins=10 * MAX_VAL + 1).tick_values(0, MAX_VAL)
cmap = get_cmap('viridis')
cmap.set_bad(color='k')
cmap.set_under(color='k')
cmap.set_over(color='w')
norm = Normalize(vmin=0, vmax=MAX_VAL, clip=False)
sm = ScalarMappable(norm=norm, cmap=cmap)
color_pal = [
    RGB(*val).to_hex()
    for val in sm.to_rgba(levels, bytes=True, norm=True)[:-1]
]
color_mapper = LinearColorMapper(color_pal,
                                 low=sm.get_clim()[0],
                                 high=sm.get_clim()[1])
l = levels.copy()[::3]
l[0] = GREY_THRESHOLD
ticker = FixedTicker(ticks=l)
cb = ColorBar(color_mapper=color_mapper,
              location=(0, 0),
              scale_alpha=ALPHA,
              ticker=ticker)

# make the bokeh figures without the data yet
width = 1024
height = int(0.73 * width)
sfmt = '%Y-%m-%d %HZ'
tools = 'pan, box_zoom, reset, save'
map_fig = figure(plot_width=width,
Пример #2
0
            continue
        date = datetime.strftime('%Y-%m-%d')
        if date not in out:
            out[date] = []
        out[date].append(datetime.strftime('%HZ'))
    return out


# setup the coloring
levels = MaxNLocator(nbins=21).tick_values(0, MAX_VAL)
cmap = plt.get_cmap('viridis')
norm = BoundaryNorm(levels, ncolors=cmap.N, clip=True)
sm = ScalarMappable(norm=norm, cmap=cmap)
color_pal = [RGB(*val).to_hex() for val in
             sm.to_rgba(levels, bytes=True, norm=True)[:-1]]
color_mapper = LinearColorMapper(color_pal, low=sm.get_clim()[0],
                                 high=sm.get_clim()[1])
ticker = FixedTicker(ticks=levels[::3])
cb = ColorBar(color_mapper=color_mapper, location=(0, 0),
              scale_alpha=ALPHA, ticker=ticker)

masked_regrid, X, Y, valid_date = load_data()

xn = X[0]
yn = Y[:, 0]
dw = xn[-1] - xn[0]
dh = yn[-1] - yn[0]
dx = xn[1] - xn[0]
dy = yn[1] - yn[0]

# make histograms