54 self.datapath =
"/home/fferreira/Data/correlation/"
56 self.files = glob.glob(self.datapath +
"roket_*.h5")
60 self.f_list.append(f.split(
'/')[-1])
62 self.f = h5py.File(self.files[0], mode=
'r+')
64 self.Lambda_tar = self.f.attrs[
"target.Lambda"][0]
65 self.Btt = self.f[
"Btt"][:]
67 self.IF = csr_matrix((self.f[
"IF.data"][:], self.f[
"IF.indices"][:],
68 self.f[
"IF.indptr"][:]))
71 self.P = self.f[
"P"][:]
73 self.indx_pup = self.f[
"indx_pup"][:]
74 self.pup = np.zeros((self.f[
"dm_dim"].value, self.f[
"dm_dim"].value))
76 self.niter = self.f[
"noise"][:].shape[1]
77 self.nactus = self.f[
"noise"][:].shape[0]
78 self.nmodes = self.P.shape[0]
79 self.swap = np.arange(self.nmodes) - 2
80 self.swap[0:2] = [self.nmodes - 2, self.nmodes - 1]
82 self.plot_type = [
"Commands",
"Variance"]
84 "noise",
"aliasing",
"tomography",
"filtered modes",
"bandwidth",
88 self.cov = self.f[
"cov"][:]
89 self.cor = self.f[
"cor"][:]
90 self.psf_compass = np.fft.fftshift(self.f[
"psf"][:])
91 self.psf_fitting = np.fft.fftshift(self.f[
"psfortho"][:])
96 self.basis = [
"Actuators",
"Btt"]
97 self.url =
"http://hippo6.obspm.fr/~fferreira/roket_display"
107 self.dialog = Dialog(closable=
False, visible=
False, title=
"Dialog Box",
111 self.comsTags = Paragraph(text=
"Commands type", height=25)
112 self.coms = CheckboxButtonGroup(labels=self.coms_list, active=[0])
113 self.DB_select = Select(title=
"Database", value=self.f_list[0],
115 self.DB_button = Button(label=
"Load DB", type=
"success")
116 self.plot_select = Select(title=
"Plot type", value=self.plot_type[1],
117 options=self.plot_type)
118 self.basis_select1 = Select(title=
"Basis", value=self.basis[0],
120 self.iter_select = Slider(title=
"Iteration number", start=1, end=self.niter,
122 self.plusTag = Paragraph(text=
"Add :", height=25)
123 self.plus_select = CheckboxButtonGroup(
124 labels=self.coms_list + [
"fitting",
"CORRECT"],
125 active=[0, 1, 2, 3, 4, 5, 6])
126 self.moinsTag = Paragraph(text=
"Substract :", height=25)
127 self.moins_select = CheckboxButtonGroup(labels=self.coms_list + [
"fitting"],
129 self.diff_button = Button(label=
"Sum !", type=
"success")
131 self.A = Select(title=
"Commands A", value=self.coms_list[0],
132 options=self.coms_list)
133 self.B = Select(title=
"Commands B", value=self.coms_list[0],
134 options=self.coms_list)
135 self.basis_select2 = Select(title=
"Basis", value=self.basis[0],
137 self.power = Slider(title=
"Abs(covmat)**X", start=0.1, end=1., step=0.1,
139 self.cmin = Slider(title=
"vmin", start=1, end=10, step=1)
140 self.cmax = Slider(title=
"vmax", start=1, end=10, step=1)
141 self.rescale = Button(label=
"Rescale !", type=
"primary")
142 self.draw = Button(label=
"Draw !", type=
"success")
143 self.diag = Button(label=
"Plot diag !", type=
"primary")
144 self.cut = Button(label=
"Cut !", type=
"primary")
145 self.axiscut = Slider(title=
"X/Y cut", start=0, end=1, step=1)
146 self.XY = RadioButtonGroup(labels=[
"X",
"Y"], active=0)
147 self.DataTableItems = [
148 "Type",
"Noise",
"Truncature",
"Aliasing",
"FilteredModes",
"Bandwidth",
151 self.ParamTableItems = list(self.f.attrs.keys())
153 self.table_cov_source = ColumnDataSource(
154 data=dict(Type=[], Noise=[], Truncature=[], Aliasing=[],
155 FilteredModes=[], Bandwidth=[], Tomography=[]))
156 self.table_cor_source = ColumnDataSource(
157 data=dict(Type=[], Noise=[], Truncature=[], Aliasing=[],
158 FilteredModes=[], Bandwidth=[], Tomography=[]))
160 self.table_param_source = ColumnDataSource(data=dict(Parameter=[], Value=[]))
162 self.cov_table, self.cor_table, self.param_table = self.createDataTables()
163 self.pcov_source = ColumnDataSource(
164 data=dict(image=[], x=[], y=[], dw=[], dh=[]))
165 self.pcor_source = ColumnDataSource(
166 data=dict(image=[], x=[], y=[], dw=[], dh=[]))
167 self.xdr4 = Range1d(start=0, end=6)
168 self.ydr4 = Range1d(start=0, end=6)
169 self.pcov = figure(x_range=self.xdr4, y_range=self.ydr4, x_axis_location=
"above")
170 self.pcov.image(
"image",
"x",
"y",
"dw",
"dh", palette=
"Spectral11",
171 source=self.pcov_source)
172 self.pcor = figure(x_range=self.xdr4, y_range=self.ydr4, x_axis_location=
"above")
173 self.pcor.image(
"image",
"x",
"y",
"dw",
"dh", palette=
"Spectral11",
174 source=self.pcor_source)
176 self.updateDataTables()
178 self.basis_select3 = Select(title=
"Basis", value=self.basis[0],
180 self.modes_select = Slider(title=
"Mode #", value=0, start=0, end=self.nmodes,
183 self.draw_mode = Button(label=
"Draw !", type=
"success")
184 self.inc_mode = Button(label=
"+", type=
"primary")
185 self.desinc_mode = Button(label=
"-", type=
"primary")
187 self.independence = CheckboxButtonGroup(labels=[
"Independence"], active=[])
188 self.psf_display_select = Select(
189 title=
"PSF display", value=
"COMPASS", options=[
190 "COMPASS",
"ROKET",
"Vii",
"Fitting",
"OTF Telescope",
"OTF res"
192 self.psf_rec_methods_select = Select(title=
"Reconstruction method", value=
"Vii",
193 options=[
"Vii",
"ROKET"])
194 self.gamora_tag = Paragraph(text=
"PSF reconstruction :", height=25)
195 self.psf_display_tag = Paragraph(text=
"PSF display :", height=25)
196 self.error_select = CheckboxButtonGroup(labels=self.coms_list + [
"fitting"],
197 active=[0, 1, 2, 3, 4, 5, 6])
198 self.gamora_comp = Button(label=
"Reconstruct !", type=
"primary")
199 self.psf_display = Button(label=
"Display", type=
"primary")
201 "filtered modes":
"green",
202 "bandwidth":
"orange",
204 "tomography":
"purple",
205 "non linearity":
"cyan",
209 self.source1 = ColumnDataSource(data=dict(x=[], y=[], color=[], typec=[]))
210 self.source2 = ColumnDataSource(data=dict(x=[], y=[], color=[]))
211 self.source3 = ColumnDataSource(data=dict(x=[], y=[], color=[]))
212 self.sourcepsf = ColumnDataSource(data=dict(x=[], y=[], color=[]))
214 self.hover = HoverTool(tooltips=[(
"x",
"@x"), (
"y",
"@y"), (
"type",
"@typec")])
215 self.hoverlog = HoverTool(tooltips=[(
"x",
"@x"), (
"y",
"@y"), (
"type",
217 TOOLS =
"resize,save,pan,box_zoom,tap, box_select, wheel_zoom, lasso_select,reset"
219 self.plog = Figure(plot_height=600, plot_width=800, y_range=[1e-6, 10],
220 y_axis_type=
"log", tools=[TOOLS, self.hoverlog])
221 self.psum = Figure(plot_height=600, plot_width=800)
222 for c
in self.colors:
223 self.plog.line(legend=c, line_color=self.colors[c])
225 self.plog.multi_line(
"x",
"y", color=
"color", source=self.source1)
226 self.psum.line(legend=
"Image SR", line_color=
"red")
227 self.psum.line(legend=
"Phase SR ", line_color=
"purple")
228 self.psum.line(legend=
"Var(X+Y)", line_color=
"blue")
229 self.psum.line(legend=
"Var(X)+var(Y)", line_color=
"green")
231 self.psum.multi_line(
"x",
"y", color=
"color", source=self.source3)
232 self.psum.yaxis.axis_label =
"Strehl Ratio"
234 self.xdr = Range1d(start=0, end=self.nactus)
235 self.ydr = Range1d(start=self.nactus, end=0)
236 self.p2 = figure(x_range=self.xdr, y_range=self.ydr, x_axis_location=
"above")
237 self.p2.image_url(url=[], x=0, y=0, w=self.nactus, h=self.nactus)
238 self.p3 = Figure(plot_height=600, plot_width=800)
239 self.p3.line(x=
"x", y=
"y", source=self.source2)
241 self.xdr2 = Range1d(start=0, end=self.pup.shape[0])
242 self.ydr2 = Range1d(start=self.pup.shape[1], end=0)
243 self.pmodes = figure(x_range=self.xdr2, y_range=self.ydr2,
244 x_axis_location=
"above")
245 self.pmodes.image_url(url=[], x=0, y=0, w=self.pup.shape[0], h=self.pup.shape[1])
247 self.control_plot = [self.plot_select, self.iter_select, self.basis_select1]
249 self.xdr3 = Range1d(start=0, end=self.psf_compass.shape[0])
250 self.ydr3 = Range1d(start=self.psf_compass.shape[1], end=0)
251 self.ppsf = figure(x_range=self.xdr3, y_range=self.ydr3, x_axis_location=
"above")
252 self.ppsf.image_url(url=[], x=0, y=0, w=self.psf_compass.shape[0],
253 h=self.psf_compass.shape[1])
254 self.pcutpsf = Figure(plot_height=600, plot_width=800, y_range=[1e-9, 1],
256 self.pcutpsf.line(legend=
"COMPASS", line_color=
"blue")
257 self.pcutpsf.line(legend=
"PSF rec", line_color=
"red")
258 self.pcutpsf.multi_line(
"x",
"y", color=
"color", source=self.sourcepsf)
260 self.buttons = [self.coms]
261 for control
in self.control_plot:
262 control.on_change(
'value', self.update)
263 for button
in self.buttons:
264 button.on_change(
'active', self.update)
266 self.draw.on_click(self.update_matrix2)
267 self.draw_mode.on_click(self.update_mode)
268 self.rescale.on_click(self.rescale_matrix)
269 self.diag.on_click(self.get_diag)
270 self.cut.on_click(self.cut_matrix)
271 self.inc_mode.on_click(self.mode_increment)
272 self.desinc_mode.on_click(self.mode_desincrement)
273 self.diff_button.on_click(self.plot_sum)
274 self.DB_button.on_click(self.loadDB)
275 self.gamora_comp.on_click(self.gamora_call)
276 self.psf_display.on_click(self.update_psf)
279 VBox(self.DB_select, self.DB_button, self.comsTags, self.coms,
280 self.plot_select, self.basis_select1, self.iter_select,
281 self.plusTag, self.plus_select, self.moinsTag, self.moins_select,
282 self.diff_button), width=350)
284 VBox(self.DB_select, self.DB_button, self.basis_select2, self.A, self.B,
285 self.power, self.draw, self.cmax, self.cmin, self.rescale,
286 self.axiscut, self.XY, self.cut, self.diag))
289 self.DB_select, self.DB_button, self.basis_select3,
294 HBox(self.desinc_mode, self.inc_mode,
295 height=40))), self.draw_mode)))
298 HBox(self.DB_select, self.DB_button), self.gamora_tag,
299 self.psf_rec_methods_select, self.error_select,
300 self.independence, self.gamora_comp, self.psf_display_tag,
301 self.psf_display_select, self.psf_display), width=350)
303 child=HBox(self.inputs, VBox(self.plog, self.psum)), title=
"Breakdown")
307 HBox(self.inputs2, self.p2, self.p3),
308 HBox(self.cov_table, self.pcov),
309 HBox(self.cor_table, self.pcor))), title=
"Cov/cor")
310 self.tab3 = Panel(child=HBox(self.inputs3, self.pmodes), title=
"Basis")
312 child=HBox(self.inputs4, VBox(self.ppsf, self.pcutpsf)), title=
"PSF")
314 child=HBox(VBox(HBox(self.DB_select, self.DB_button), self.param_table)),
316 self.tabs = Tabs(tabs=[self.tab1, self.tab2, self.tab4, self.tab3, self.tab5])
319 self.update(
None,
None,
None)
321 curdoc().add_root(self.tabs)
322 curdoc().add_root(self.dialog)