def get_ceil_plot(time_int=None, t_min=None, t_max=None): if time_int == None: time_int = cs.time_int plot_height = cs.plot_height plot_width = cs.plot_width border_left = cs.border_left if t_min == None or t_max == None: t_max, t_min = get_first_time_interval() t_span = t_max - t_min data = sql_con.get_data_bs(time_int=time_int, t_min=t_min, t_max=t_max) # print data ll = len(data) toolset = [CrosshairTool(), WheelZoomTool(), PreviewSaveTool(), PanTool()] plot = figure(x_range=DataRange1d(start=(t_min - t_span * .1) * 1000, end=(t_max + t_span * .1) * 1000), y_range=[0, 250 * 15], plot_height=plot_height, plot_width=plot_width, x_axis_type="datetime", min_border_left=border_left, toolbar_location="right", tools=toolset) plot.yaxis.axis_label = "meters above ground" dd = [] tt = [] y = [] dw = [] dh = [] for i in range(ll): dd.append(data.iloc[i:i + 1, 1:].T.values) tt.append(int(data.iloc[i, 0]) * 1000 - time_int * 1000 / 2) y.append(0) dw.append(time_int * 1000) dh.append(250 * 15) plot.image(image=dd, x=tt, y=y, dw=dw, dh=dh, palette="Spectral11", dilate=True) plot.title = cs.plot_title_ceil + ' averaged to {} seconds'.format( time_int) return plot
def get_ceil_plot(time_int=None,t_min=None,t_max=None): if time_int == None: time_int = cs.time_int plot_height = cs.plot_height plot_width = cs.plot_width border_left = cs.border_left if t_min == None or t_max == None: t_max, t_min = get_first_time_interval() t_span = t_max-t_min data = sql_con.get_data_bs(time_int=time_int, t_min=t_min, t_max=t_max) # print data ll = len(data) toolset = [CrosshairTool(),WheelZoomTool(),PreviewSaveTool(),PanTool()] plot = figure(x_range=DataRange1d(start=(t_min-t_span*.1)*1000, end=(t_max+t_span*.1)*1000 ), y_range=[0, 250 * 15], plot_height=plot_height, plot_width=plot_width, x_axis_type="datetime", min_border_left=border_left, toolbar_location="right", tools=toolset ) plot.yaxis.axis_label = "meters above ground" dd = [] tt = [] y = [] dw = [] dh = [] for i in range(ll): dd.append(data.iloc[i:i + 1, 1:].T.values) tt.append(int(data.iloc[i, 0]) * 1000 - time_int * 1000 / 2) y.append(0) dw.append(time_int * 1000) dh.append(250 * 15) plot.image(image=dd, x=tt, y=y, dw=dw, dh=dh, palette="Spectral11", dilate=True) plot.title = cs.plot_title_ceil + ' averaged to {} seconds'.format(time_int) return plot
from __future__ import print_function from bokeh.browserlib import view from bokeh.document import Document from bokeh.embed import file_html from bokeh.resources import INLINE from ceil_bokeh import sql_con, plots border_left = 150 time_int = 3600 data_weather = sql_con.get_data_ws(time_int=time_int) plot_weather = plots.get_weather_plot(data_weather, border_left=border_left) data_ceil = sql_con.get_data_bs(time_int=time_int) plot_ceil = plots.get_ceil_plot(data_ceil, time_int=time_int, border_left=border_left) # link x_range both plots plot_weather.x_range = plot_ceil.x_range doc = Document() doc.add(plot_weather) doc.add(plot_ceil) if __name__ == "__main__": filename = "twin_axis.html" with open(filename, "w") as f: f.write(file_html(doc, INLINE, "Twin Axis Plot")) print("Wrote %s" % filename)
from __future__ import print_function from bokeh.browserlib import view from bokeh.document import Document from bokeh.embed import file_html from bokeh.resources import INLINE from ceil_bokeh import sql_con, plots border_left = 150 time_int = 3600 data_weather = sql_con.get_data_ws(time_int=time_int) plot_weather = plots.get_weather_plot(data_weather, border_left=border_left) data_ceil = sql_con.get_data_bs(time_int=time_int) plot_ceil = plots.get_ceil_plot(data_ceil, time_int=time_int, border_left=border_left) # link x_range both plots plot_weather.x_range = plot_ceil.x_range doc = Document() doc.add(plot_weather) doc.add(plot_ceil) if __name__ == "__main__": filename = "twin_axis.html" with open(filename, "w") as f: