7 from bokeh.plotting
import figure
8 from bokeh.models
import ColumnDataSource
9 from bokeh.models.widgets
import Panel, DataTable, TableColumn, Tabs, Button, RadioButtonGroup, Select, DataTable, DateFormatter, TableColumn, PreText
10 from bokeh.layouts
import layout, widgetbox
11 from bokeh.io
import curdoc, output_file, show
13 from guardians
import drax
18 Class that defines a bokeh layout and callback functions for ROKET
19 Usage: see bokeh_roket.py which is the executable
26 self.
files = [f.split(
'/')[-1]
for f
in glob(self.
datapath +
"roket_*.h5")]
28 self.
files = [
"No hdf5 files"]
34 self.
url =
"http://hippo6.obspm.fr/~fferreira/roket_display"
38 self.
pretext = PreText(text=
""" """, width=500, height=75)
39 self.
button_load = Button(label=
"Load", button_type=
"success")
41 title=
"Datapath", value=self.
dataroot,
47 "filtered modes":
"green",
48 "bandwidth":
"orange",
50 "tomography":
"purple",
51 "non linearity":
"cyan",
56 data=dict(n=[], a=[], b=[], t=[], nl=[], f=[], fm=[]))
58 data=dict(Type=[], Noise=[], Trunc=[], Aliasing=[], FilteredModes=[],
59 Bandwidth=[], Tomography=[]))
61 data=dict(Type=[], Noise=[], Trunc=[], Aliasing=[], FilteredModes=[],
62 Bandwidth=[], Tomography=[]))
63 self.
source_params = ColumnDataSource(data=dict(Parameter=[], Value=[]))
65 TableColumn(field=
"n", title=
"noise"),
66 TableColumn(field=
"a", title=
"aliasing"),
67 TableColumn(field=
"b", title=
"bandwidth"),
68 TableColumn(field=
"t", title=
"tomography"),
69 TableColumn(field=
"nl", title=
"non lin."),
70 TableColumn(field=
"f", title=
"fitting"),
71 TableColumn(field=
"fm", title=
"filt. modes")
79 TableColumn(field=
"Type", title=
"Cov."),
80 TableColumn(field=
"Noise", title=
"Noise"),
81 TableColumn(field=
"Trunc", title=
"Non lin."),
82 TableColumn(field=
"Aliasing", title=
"Alias."),
83 TableColumn(field=
"FilteredModes", title=
"Filt."),
84 TableColumn(field=
"Bandwidth", title=
"Band."),
85 TableColumn(field=
"Tomography", title=
"Tomo"),
89 columns2[0] = TableColumn(field=
"Type", title=
"Cor.")
95 TableColumn(field=
"Parameter", title=
"Parameter"),
96 TableColumn(field=
"Value", title=
"Value")
104 self.
p = figure(plot_height=600, plot_width=800, y_axis_type=
"log",
105 y_range=[1e-9, 1], title=
"Contibutors variance")
107 self.
p.line(x=
"x", y=
"y", legend=c, color=self.
colors[c],
108 muted_color=self.
colors[c], muted_alpha=0.1,
111 self.
p.legend.click_policy =
"mute"
131 Update the select_files options following the current datapath
135 f.split(
'/')[-1]
for f
in glob(self.
datapath +
"roket_*.h5")
138 self.
files = [
"No hdf5 files"]
144 Load the selected file and update the display
148 self.
Btt = self.
f[
"Btt"][:]
149 self.
P = self.
f[
"P"][:]
150 self.
cov = self.
f[
"cov"][:]
151 self.
cor = self.
f[
"cor"][:]
163 Update the values of the error breakdown tables
165 self.
pretext.text =
""" Updating error breakdown... Please wait"""
169 n=[int(np.round(breakdown[
"noise"]))
170 ], a=[int(np.round(breakdown[
"aliasing"]))
171 ], b=[int(np.round(breakdown[
"bandwidth"]))
172 ], t=[int(np.round(breakdown[
"tomography"]))
173 ], nl=[int(np.round(breakdown[
"non linearity"]))
174 ], f=[int(np.round(breakdown[
"fitting"]))],
175 fm=[int(np.round(breakdown[
"filtered modes"]))])
180 Update tables of covariances and correlations
182 self.
pretext.text =
""" Updating cov cor tables... Please wait"""
185 Type=[
"Noise",
"Trunc",
"Alias.",
"Filt.",
"Band.",
186 "Tomo"], Noise=[
"%.2E" % v
for v
in self.
cov[:, 0]
187 ], Trunc=[
"%.2E" % v
for v
in self.
cov[:, 1]],
188 Aliasing=[
"%.2E" % v
for v
in self.
cov[:, 2]
189 ], FilteredModes=[
"%.2E" % v
for v
in self.
cov[:, 3]],
190 Bandwidth=[
"%.2E" % v
for v
in self.
cov[:, 4]
191 ], Tomography=[
"%.2E" % v
for v
in self.
cov[:, 5]])
193 Type=[
"Noise",
"Trunc",
"Alias.",
"Filt.",
"Band.",
194 "Tomo"], Noise=[
"%.2f" % v
for v
in self.
cor[:, 0]
195 ], Trunc=[
"%.2f" % v
for v
in self.
cor[:, 1]],
196 Aliasing=[
"%.2f" % v
for v
in self.
cor[:, 2]
197 ], FilteredModes=[
"%.2f" % v
for v
in self.
cor[:, 3]],
198 Bandwidth=[
"%.2f" % v
for v
in self.
cor[:, 4]
199 ], Tomography=[
"%.2f" % v
for v
in self.
cor[:, 5]])
205 Update the simulation parameters table
207 self.
pretext.text =
""" Updating parameters table... Please wait"""
208 params = list(self.
f.attrs.keys())
212 values.append(str(self.
f.attrs[k]))
213 self.
source_params.data = dict(Parameter=params, Value=values)
218 Main callback function that update the bokeh display
222 self.
pretext.text =
""" Updating plot... Please wait"""
232 self.
p.xaxis.axis_label =
"Actuators"
234 data = self.
P.dot(data)
235 self.
p.xaxis.axis_label =
"Modes"
237 x=np.arange(len(data)).tolist(), y=np.var(data, axis=1).tolist())