Пример #1
0
    def __init__(self, **kwargs):
        super(WeatherPlot, self).__init__(**kwargs)

        # def __init__(self,
        #              data,
        #              column_names=cs.column_names_weewx,
        #              column_time=cs.time_column_name_weewx,
        #              plot_height=300,
        #              plot_width=800,
        #              border_left=150,
        #              **kwargs):
        #     if "tool_events" not in kwargs:
        #         kwargs["tool_events"] = ToolEvents()
        #     super(WeatherPlot,self).__init__(x_range=DataRange1d(),
        #                                      y_range=DataRange1d(),
        #                                      plot_width=800,
        #                                      plot_height=500,
        #                                      min_border_left=150,
        #                                      **kwargs)

        time_int = 3600
        t_max = int(time.time())
        t_min = t_max - 3600 * 24
        data = sql_con.get_data_ws(time_int=time_int, t_max=t_max, t_min=t_min)
        self._data = data
        column_names = cs.column_names_weewx
        column_time = cs.time_column_name_weewx
        data_seconds = data
        data_seconds.iloc[:, 0] = data_seconds.iloc[:, 0] * 1000
        add_glyphs_to_plot(column_names, column_time, data_seconds, self)
        self.add_layout(DatetimeAxis(), "below")
        self.add_tools(PanTool(), WheelZoomTool(), ResizeTool(), CrosshairTool())
Пример #2
0
    def __init__(self,**kwargs):
        super(WeatherPlot,self).__init__(**kwargs)

    # def __init__(self,
    #              data,
    #              column_names=cs.column_names_weewx,
    #              column_time=cs.time_column_name_weewx,
    #              plot_height=300,
    #              plot_width=800,
    #              border_left=150,
    #              **kwargs):
    #     if "tool_events" not in kwargs:
    #         kwargs["tool_events"] = ToolEvents()
    #     super(WeatherPlot,self).__init__(x_range=DataRange1d(),
    #                                      y_range=DataRange1d(),
    #                                      plot_width=800,
    #                                      plot_height=500,
    #                                      min_border_left=150,
    #                                      **kwargs)

        time_int = 3600
        t_max = int(time.time())
        t_min = t_max - 3600 * 24
        data = sql_con.get_data_ws(time_int=time_int,
                                           t_max=t_max,
                                           t_min=t_min)
        self._data = data
        column_names=cs.column_names_weewx
        column_time=cs.time_column_name_weewx
        data_seconds = data
        data_seconds.iloc[:, 0] = data_seconds.iloc[:, 0] * 1000
        add_glyphs_to_plot(column_names, column_time, data_seconds, self)
        self.add_layout(DatetimeAxis(), 'below')
        self.add_tools(PanTool(), WheelZoomTool(), ResizeTool(), CrosshairTool())
Пример #3
0
def get_weather_plot(time_int=None, t_min=None, t_max=None):
    plot_height = cs.plot_height
    plot_width = cs.plot_width
    border_left = cs.border_left
    column_names = cs.column_names_weewx
    column_time = cs.time_column_name_weewx
    if t_max == None or t_min == None:
        t_max, t_min = get_first_time_interval()
    t_span = t_max - t_min
    if time_int == None:
        time_int = cs.time_int
    data_seconds = sql_con.get_data_ws(time_int=time_int,
                                       t_min=t_min,
                                       t_max=t_max)
    data_seconds.iloc[:, 0] = data_seconds.iloc[:, 0] * 1000

    plot = Plot(
        x_range=DataRange1d(start=(t_min - t_span * .1) * 1000,
                            end=(t_max + t_span * .1) * 1000),
        y_range=DataRange1d(),
        plot_width=plot_width,
        plot_height=plot_height,
        # x_axis_type="datetime",
        min_border_left=border_left,
        toolbar_location="right")

    add_glyphs_to_plot(column_names, column_time, data_seconds, plot,
                       'source_weather')

    plot.add_layout(DatetimeAxis(name="date_time_axis"), 'below')

    plot.add_tools(
        PanTool(),
        WheelZoomTool(),
        # ResizeTool(),
        CrosshairTool(),
        PreviewSaveTool())
    Grid(plot=plot,
         dimension=0,
         ticker=plot.select('date_time_axis')[0].ticker)

    Grid(plot=plot,
         dimension=1,
         ticker=plot.select(type=LinearAxis, name=column_names[0])[0].ticker)

    set_legends(plot)

    plot.title = cs.plot_title_weewx + ' averaged to {} seconds'.format(
        time_int)

    return plot
Пример #4
0
def get_weather_plot(time_int=None,t_min=None,t_max=None):
    plot_height = cs.plot_height
    plot_width = cs.plot_width
    border_left = cs.border_left
    column_names = cs.column_names_weewx
    column_time = cs.time_column_name_weewx
    if t_max == None or t_min == None:
        t_max, t_min = get_first_time_interval()
    t_span = t_max - t_min
    if time_int == None:
        time_int = cs.time_int
    data_seconds = sql_con.get_data_ws(time_int=time_int, t_min=t_min, t_max=t_max)
    data_seconds.iloc[:, 0] = data_seconds.iloc[:, 0] * 1000

    plot = Plot(x_range=DataRange1d(start=(t_min-t_span*.1)*1000,
                                    end=(t_max+t_span*.1)*1000),
                y_range=DataRange1d(),
                plot_width=plot_width,
                plot_height=plot_height,
                # x_axis_type="datetime",
                min_border_left=border_left,
                toolbar_location="right")

    add_glyphs_to_plot(column_names, column_time, data_seconds, plot,'source_weather')

    plot.add_layout(DatetimeAxis(name="date_time_axis"), 'below')

    plot.add_tools(PanTool(),
                   WheelZoomTool(),
                   # ResizeTool(),
                   CrosshairTool(),
                   PreviewSaveTool()
                   )
    Grid(plot=plot,dimension=0,ticker=plot.select('date_time_axis')[0].ticker)

    Grid(plot=plot,
         dimension=1,
         ticker=plot.select(type=LinearAxis,name=column_names[0])[0].ticker
         )

    set_legends(plot)

    plot.title = cs.plot_title_weewx + ' averaged to {} seconds'.format(time_int)


    return plot
Пример #5
0
from __future__ import print_function

from ceil_bokeh import sql_con, plots

from bokeh.browserlib import view
from bokeh.document import Document
from bokeh.embed import file_html
from bokeh.resources import INLINE

data_weather = sql_con.get_data_ws(time_int=3600)

plot_weather = plots.get_weather_plot(data_weather)

# data_ceil = sql_con.get_data_bs()

# plot_ceil = plots.get_bs_plot(data_ceil)

# 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)
    view(filename)
Пример #6
0
from __future__ import print_function

from ceil_bokeh import sql_con, plots

from bokeh.browserlib import view
from bokeh.document import Document
from bokeh.embed import file_html
from bokeh.resources import INLINE


data_weather = sql_con.get_data_ws(time_int=3600)

plot_weather = plots.get_weather_plot(data_weather)

# data_ceil = sql_con.get_data_bs()

# plot_ceil = plots.get_bs_plot(data_ceil)

# 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)
    view(filename)