Пример #1
0
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
counts, bin_edges = np.histogram(masked_regrid, bins=levels,
                                 range=(levels.min(), levels.max()))
bin_width = bin_edges[1] - bin_edges[0]
bin_centers = bin_edges + bin_width / 2
hist_sources = [ColumnDataSource(data={'x': [bin_centers[i]],
                                       'top': [counts[i]],
                                       'color': [color_pal[i]]})
                for i in range(len(counts))]

# bokeh plotting
rgba_vals = sm.to_rgba(masked_regrid, bytes=True, alpha=ALPHA)

width = 600
height = int(width / 2 * dy / dx)
sfmt = '%Y-%m-%d %HZ'
title = 'MRMS Precipitation {} through {}'.format(
    (valid_date - dt.timedelta(hours=24)).strftime(sfmt),