Hi,
I have a data folder which is fed with new data every 30 minutes which is then read into a panda dataframe and plotted as 4 subplotted time series. I am struggling to get these to update when new data comes in and then ultimately be on a password protected web page which continues to update and is interactive.
Any help would be so so appreciated. I am currently just going round in circles…
Here is my plotting code:
import time
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from bokeh.io import show, output_notebook, push_notebook, gridplot
from bokeh.plotting import figure, show, output_file
from bokeh.models import HoverTool, Span
from bokeh.charts import TimeSeries
import datetime
output_notebook()
Rubble Buoy
rubble = pd.read_csv(‘X:/rubble_buoy.dat’, usecols=[‘TIMESTAMP’, ‘TSS_shallow_corr_Med’, ‘TSS_deep_corr_Med’,], skiprows=[2,3], na_values=[’-’], index_col=0, parse_dates=True, header=1)
Inshore Buoy
inshore = pd.read_csv(‘X:/inshore_buoy.dat’, usecols=[‘TIMESTAMP’, ‘TSS_shallow_corr_Med’, ‘TSS_deep_corr_Med’,], skiprows=[2,3], na_values=[’-’], index_col=0, parse_dates=True, header=1)
rubble.columns = ['1m ', ‘3m’]
inshore.columns = [‘1m’, ‘2m’]
TOOLS=“hover,crosshair,pan,wheel_zoom,box_zoom,reset,tap,save,box_select,poly_select,lasso_select”
create a new plot
rubble_day = TimeSeries(rubble[-1440:], ylabel=‘mg/l’, xlabel=‘TIME’, width=750, height=500, title=‘Rubble Buoy Last Download %s’ % str(rubble.index[-1]), legend=True, tools=TOOLS)
rubble_day.y_range.start = 0
rubble_day.y_range.end = 80
hline = Span(location=20, dimension=‘width’, line_color=‘red’, line_width=3)
create another one
inshore_day = TimeSeries(inshore[-1440:], ylabel=‘mg/l’, xlabel=‘TIME’, width=750, height=500, title=‘Inshore Buoy Last Download %s’ % str(inshore.index[-1]), legend=True, tools=TOOLS)
inshore_day.y_range.start = 0
inshore_day.y_range.end = 80
rubble_day.renderers.extend([hline])
inshore_day.renderers.extend([hline])
create and another
rubble_hour = TimeSeries(rubble[-60:], ylabel=‘mg/l’, xlabel=‘TIME’, width=500, height=500, title=‘Rubble Buoy’, legend=True, tools=TOOLS)
rubble_hour.y_range.start = 0
rubble_hour.y_range.end = 20
create and another
inshore_hour = TimeSeries(inshore[-60:], ylabel=‘mg/l’, xlabel=‘TIME’, width=500, height=500, title=‘Inshore Buoy’, legend=True, tools=TOOLS)
inshore_hour.y_range.start = 0
inshore_hour.y_range.end = 20
put all the plots in a grid layout
p = gridplot([[rubble_day, rubble_hour], [inshore_day, inshore_hour]])
show the results
#output_file(“layout.html”, title=‘Turbidity Data’)
target = show(p, notebook_handle=True)
update data
rubble = pd.read_csv(‘X:rubble_buoy.dat’, usecols=[‘TIMESTAMP’, ‘TSS_shallow_corr_Med’, ‘TSS_deep_corr_Med’,], skiprows=[2,3], na_values=[’-’], index_col=0, parse_dates=True, header=1)
inshore = pd.read_csv(‘X:inshore_buoy.dat’, usecols=[‘TIMESTAMP’, ‘TSS_shallow_corr_Med’, ‘TSS_deep_corr_Med’,], skiprows=[2,3], na_values=[’-’], index_col=0, parse_dates=True, header=1)
push_notebook(handle=target)