COMPASS  5.0.0
End-to-end AO simulation tool using GPU acceleration
widget_roket.Bokeh_roket Class Reference
Collaboration diagram for widget_roket.Bokeh_roket:

Public Member Functions

def __init__ (self)
 
def update_files (self)
 Update the select_files options following the current datapath. More...
 
def load_file (self)
 Load the selected file and update the display. More...
 
def update_breakdown (self)
 Update the values of the error breakdown tables. More...
 
def update_covcor (self)
 Update tables of covariances and correlations. More...
 
def update_params (self)
 Update the simulation parameters table. More...
 
def update (self)
 Main callback function that update the bokeh display. More...
 

Public Attributes

 dataroot
 
 datapath
 
 files
 
 f
 
 Btt
 
 P
 
 cov
 
 cor
 
 url
 
 old
 
 pretext
 
 button_load
 
 select_datapath
 
 select_files
 
 radioButton_basis
 
 colors
 
 contributors
 
 source_breakdown
 
 source_cov
 
 source_cor
 
 source_params
 
 table_breakdown
 
 table_cov
 
 table_cor
 
 table_params
 
 source_variances
 
 p
 
 control_box
 
 tab
 

Detailed Description

Definition at line 20 of file widget_roket.py.

Constructor & Destructor Documentation

◆ __init__()

def widget_roket.Bokeh_roket.__init__ (   self)

Definition at line 22 of file widget_roket.py.

22  def __init__(self):
23 
24  self.dataroot = os.getenv("DATA_GUARDIAN")
25  self.datapath = self.dataroot
26  self.files = [f.split('/')[-1] for f in glob(self.datapath + "roket_*.h5")]
27  if self.files == []:
28  self.files = ["No hdf5 files"]
29  self.f = None
30  self.Btt = None
31  self.P = None
32  self.cov = None
33  self.cor = None
34  self.url = "http://hippo6.obspm.fr/~fferreira/roket_display"
35  self.old = None
36 
37  # Widgets Elements
38  self.pretext = PreText(text=""" """, width=500, height=75)
39  self.button_load = Button(label="Load", button_type="success")
40  self.select_datapath = Select(
41  title="Datapath", value=self.dataroot,
42  options=[self.dataroot] + glob(self.dataroot + "*/"))
43  self.select_files = Select(title="File", value=self.files[0], options=self.files)
44  self.radioButton_basis = RadioButtonGroup(labels=["Actuators", "Btt"], active=1)
45 
46  self.colors = {
47  "filtered modes": "green",
48  "bandwidth": "orange",
49  "noise": "red",
50  "tomography": "purple",
51  "non linearity": "cyan",
52  "aliasing": "blue"
53  }
54  self.contributors = [c for c in self.colors.keys()]
55  self.source_breakdown = ColumnDataSource(
56  data=dict(n=[], a=[], b=[], t=[], nl=[], f=[], fm=[]))
57  self.source_cov = ColumnDataSource(
58  data=dict(Type=[], Noise=[], Trunc=[], Aliasing=[], FilteredModes=[],
59  Bandwidth=[], Tomography=[]))
60  self.source_cor = ColumnDataSource(
61  data=dict(Type=[], Noise=[], Trunc=[], Aliasing=[], FilteredModes=[],
62  Bandwidth=[], Tomography=[]))
63  self.source_params = ColumnDataSource(data=dict(Parameter=[], Value=[]))
64  columns = [
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")
72  ]
73 
74  self.table_breakdown = DataTable(source=self.source_breakdown, columns=columns,
75  width=400, height=75)
76  #self.update_breakdown()
77 
78  columns2 = [
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"),
86  ]
87  self.table_cov = DataTable(source=self.source_cov, columns=columns2, width=400,
88  height=200)
89  columns2[0] = TableColumn(field="Type", title="Cor.")
90  self.table_cor = DataTable(source=self.source_cor, columns=columns2, width=400,
91  height=250)
92  #self.update_covcor()
93 
94  tmp = [
95  TableColumn(field="Parameter", title="Parameter"),
96  TableColumn(field="Value", title="Value")
97  ]
98  self.table_params = DataTable(source=self.source_params, columns=tmp, width=600,
99  height=500)
100  #self.update_params()
101  self.source_variances = {}
102  for c in self.contributors:
103  self.source_variances[c] = ColumnDataSource(data=dict(x=[], y=[]))
104  self.p = figure(plot_height=600, plot_width=800, y_axis_type="log",
105  y_range=[1e-9, 1], title="Contibutors variance")
106  for c in self.contributors:
107  self.p.line(x="x", y="y", legend=c, color=self.colors[c],
108  muted_color=self.colors[c], muted_alpha=0.1,
109  source=self.source_variances[c])
110 
111  self.p.legend.click_policy = "mute"
112 
113  # Callback functions
114  self.select_datapath.on_change(
115  "value", lambda attr, old, new: self.update_files())
116  self.button_load.on_click(self.load_file)
117  self.radioButton_basis.on_change("active", lambda attr, old, new: self.update())
118 
119  # Layouts
120  self.control_box = widgetbox(self.select_datapath, self.select_files,
121  self.button_load, self.radioButton_basis)
122  self.tab = Panel(
123  child=layout([[
124  self.control_box, self.p,
125  widgetbox(self.pretext, self.table_breakdown, self.table_cov,
126  self.table_cor)
127  ], [self.table_params]]), title="ROKET")
128 

Member Function Documentation

◆ load_file()

def widget_roket.Bokeh_roket.load_file (   self)

Load the selected file and update the display.

Definition at line 145 of file widget_roket.py.

145  """
146  self.button_load.button_type = "danger"
147  self.f = h5py.File(self.datapath + str(self.select_files.value), mode='r+')
148  self.Btt = self.f["Btt"][:]
149  self.P = self.f["P"][:] #/np.sqrt(self.IF.shape[0])
150  self.cov = self.f["cov"][:]
151  self.cor = self.f["cor"][:]
152 
153  self.update()
154  self.update_breakdown()
155  self.update_covcor()
156  self.update_params()
157  self.button_load.button_type = "success"
158 
159  print("DB loaded")
160 
Here is the call graph for this function:

◆ update()

def widget_roket.Bokeh_roket.update (   self)

Main callback function that update the bokeh display.

Definition at line 219 of file widget_roket.py.

219  """
220  tmp = self.button_load.button_type
221  self.button_load.button_type = "danger"
222  self.pretext.text = """ Updating plot... Please wait"""
223 
224  basis_active = self.radioButton_basis.active
225  xi = []
226  yi = []
227  coloris = []
228 
229  for c in self.contributors:
230  self.source_variances[c].data = dict(x=[], y=[], color=[], legend=[])
231  data = self.f[c][:]
232  self.p.xaxis.axis_label = "Actuators"
233  if (basis_active):
234  data = self.P.dot(data)
235  self.p.xaxis.axis_label = "Modes"
236  self.source_variances[c].data = dict(
237  x=np.arange(len(data)).tolist(), y=np.var(data, axis=1).tolist())
238 
239  self.pretext.text = """ """
240  self.button_load.button_type = tmp
Here is the caller graph for this function:

◆ update_breakdown()

def widget_roket.Bokeh_roket.update_breakdown (   self)

Update the values of the error breakdown tables.

Definition at line 164 of file widget_roket.py.

164  """
165  self.pretext.text = """ Updating error breakdown... Please wait"""
166 
167  breakdown = drax.get_breakdown(self.datapath + str(self.select_files.value))
168  self.source_breakdown.data = dict(
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"]))])
176  self.pretext.text = """ """
177 
Here is the caller graph for this function:

◆ update_covcor()

def widget_roket.Bokeh_roket.update_covcor (   self)

Update tables of covariances and correlations.

Definition at line 181 of file widget_roket.py.

181  """
182  self.pretext.text = """ Updating cov cor tables... Please wait"""
183 
184  self.source_cov.data = dict(
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]])
192  self.source_cor.data = dict(
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]])
200 
201  self.pretext.text = """ """
202 
Here is the caller graph for this function:

◆ update_files()

def widget_roket.Bokeh_roket.update_files (   self)

Update the select_files options following the current datapath.

Definition at line 132 of file widget_roket.py.

132  """
133  self.datapath = str(self.select_datapath.value)
134  self.files = self.files = [
135  f.split('/')[-1] for f in glob(self.datapath + "roket_*.h5")
136  ]
137  if self.files == []:
138  self.files = ["No hdf5 files"]
139  self.select_files.options = self.files
140  self.select_files.value = self.files[0]
141 

◆ update_params()

def widget_roket.Bokeh_roket.update_params (   self)

Update the simulation parameters table.

Definition at line 206 of file widget_roket.py.

206  """
207  self.pretext.text = """ Updating parameters table... Please wait"""
208  params = list(self.f.attrs.keys())
209  params.sort()
210  values = []
211  for k in params:
212  values.append(str(self.f.attrs[k]))
213  self.source_params.data = dict(Parameter=params, Value=values)
214  self.pretext.text = """ """
215 
Here is the caller graph for this function:

Member Data Documentation

◆ Btt

widget_roket.Bokeh_roket.Btt

Definition at line 30 of file widget_roket.py.

◆ button_load

widget_roket.Bokeh_roket.button_load

Definition at line 39 of file widget_roket.py.

◆ colors

widget_roket.Bokeh_roket.colors

Definition at line 46 of file widget_roket.py.

◆ contributors

widget_roket.Bokeh_roket.contributors

Definition at line 54 of file widget_roket.py.

◆ control_box

widget_roket.Bokeh_roket.control_box

Definition at line 120 of file widget_roket.py.

◆ cor

widget_roket.Bokeh_roket.cor

Definition at line 33 of file widget_roket.py.

◆ cov

widget_roket.Bokeh_roket.cov

Definition at line 32 of file widget_roket.py.

◆ datapath

widget_roket.Bokeh_roket.datapath

Definition at line 25 of file widget_roket.py.

◆ dataroot

widget_roket.Bokeh_roket.dataroot

Definition at line 24 of file widget_roket.py.

◆ f

widget_roket.Bokeh_roket.f

Definition at line 29 of file widget_roket.py.

◆ files

widget_roket.Bokeh_roket.files

Definition at line 26 of file widget_roket.py.

◆ old

widget_roket.Bokeh_roket.old

Definition at line 35 of file widget_roket.py.

◆ P

widget_roket.Bokeh_roket.P

Definition at line 31 of file widget_roket.py.

◆ p

widget_roket.Bokeh_roket.p

Definition at line 104 of file widget_roket.py.

◆ pretext

widget_roket.Bokeh_roket.pretext

Definition at line 38 of file widget_roket.py.

◆ radioButton_basis

widget_roket.Bokeh_roket.radioButton_basis

Definition at line 44 of file widget_roket.py.

◆ select_datapath

widget_roket.Bokeh_roket.select_datapath

Definition at line 40 of file widget_roket.py.

◆ select_files

widget_roket.Bokeh_roket.select_files

Definition at line 43 of file widget_roket.py.

◆ source_breakdown

widget_roket.Bokeh_roket.source_breakdown

Definition at line 55 of file widget_roket.py.

◆ source_cor

widget_roket.Bokeh_roket.source_cor

Definition at line 60 of file widget_roket.py.

◆ source_cov

widget_roket.Bokeh_roket.source_cov

Definition at line 57 of file widget_roket.py.

◆ source_params

widget_roket.Bokeh_roket.source_params

Definition at line 63 of file widget_roket.py.

◆ source_variances

widget_roket.Bokeh_roket.source_variances

Definition at line 101 of file widget_roket.py.

◆ tab

widget_roket.Bokeh_roket.tab

Definition at line 122 of file widget_roket.py.

◆ table_breakdown

widget_roket.Bokeh_roket.table_breakdown

Definition at line 74 of file widget_roket.py.

◆ table_cor

widget_roket.Bokeh_roket.table_cor

Definition at line 90 of file widget_roket.py.

◆ table_cov

widget_roket.Bokeh_roket.table_cov

Definition at line 87 of file widget_roket.py.

◆ table_params

widget_roket.Bokeh_roket.table_params

Definition at line 98 of file widget_roket.py.

◆ url

widget_roket.Bokeh_roket.url

Definition at line 34 of file widget_roket.py.


The documentation for this class was generated from the following file: