7 import matplotlib
as mpl
9 from bokeh.plotting
import figure
10 from bokeh.models
import ColumnDataSource, Range1d
11 from bokeh.models.widgets
import Panel, Toggle, TextInput, Slider, CheckboxButtonGroup, DataTable, TableColumn, Tabs, Button, RadioButtonGroup, Select, DataTable, DateFormatter, TableColumn, PreText
12 from bokeh.layouts
import layout, widgetbox
13 from bokeh.io
import curdoc, output_file, show
15 from guardians
import gamora, groot, drax
24 self.
files = [f.split(
'/')[-1]
for f
in glob(self.
datapath +
"roket_*.h5")]
26 self.
files = [
"No hdf5 files"]
34 self.
url =
"http://" + os.uname()[1] +
".obspm.fr/~" + os.getlogin(
44 self.
pretext = PreText(text=
""" """, width=500, height=75)
45 self.
SRcompass = TextInput(value=
" ", title=
"SR compass:")
46 self.
SRroket = TextInput(value=
" ", title=
"SR roket:")
47 self.
SRgroot = TextInput(value=
" ", title=
"SR groot:")
50 self.
button_psf = Button(label=
"PSF !", button_type=
"success")
51 self.
toggle_fit = Toggle(label=
"Fitting", button_type=
"primary")
54 title=
"Datapath", value=self.
dataroot,
58 self.
contributors = [
"noise",
"bandwidth & tomography",
"aliasing"]
64 self.
xdr = Range1d(start=0, end=1024)
65 self.
ydr = Range1d(start=1024, end=0)
66 self.
xdr2 = Range1d(start=0, end=1024)
67 self.
ydr2 = Range1d(start=1024, end=0)
69 x_axis_location=
"above", title=
"PSF ROKET")
72 x_axis_location=
"above", title=
"PSF GROOT")
74 x_axis_location=
"above", title=
"Covmat ROKET")
77 x_axis_location=
"above", title=
"Covmat GROOT")
78 self.
plot_psf_cuts = figure(plot_height=600, plot_width=800, y_range=[1e-9, 1],
79 x_range=self.
image_roket.x_range, y_axis_type=
"log")
86 self.
image_roket.image_url(url=[], x=0, y=0, w=1024, h=1024)
87 self.
image_groot.image_url(url=[], x=0, y=0, w=1024, h=1024)
90 self.
plot_psf_cuts.line(x=
"x", y=
"y", legend=
"ROKET", color=
"blue",
92 self.
plot_psf_cuts.line(x=
"x", y=
"y", legend=
"COMPASS", color=
"red",
94 self.
plot_psf_cuts.line(x=
"x", y=
"y", legend=
"GROOT", color=
"green",
120 Update the attributes based on the new selected filename
130 self.
Btt = self.
f[
"Btt"][:]
131 self.
P = self.
f[
"P"][:]
134 self.
nslopes = self.
f[
"R"][:].shape[1]
138 Update the select_files options following the current datapath
142 f.split(
'/')[-1]
for f
in glob(self.
datapath +
"roket_*.h5")
145 self.
files = [
"No hdf5 files"]
151 Update the PSF display
154 time = str(datetime.datetime.now().strftime(
'%Y-%m-%d_%H_%M_%f'))
155 self.
old =
"/home/" + os.getlogin(
156 ) +
"/public_html/roket_display" + time +
".png"
157 mpl.image.imsave(self.
old, np.log10(np.abs(self.
psf_roket)))
159 url=dict(value=self.
url + time +
".png"), x=0, y=0,
166 time = str(datetime.datetime.now().strftime(
'%Y-%m-%d_%H_%M_%f'))
167 self.
old =
"/home/" + os.getlogin(
168 ) +
"/public_html/roket_display" + time +
".png"
169 mpl.image.imsave(self.
old, np.log10(np.abs(self.
psf_groot)))
171 url=dict(value=self.
url + time +
".png"), x=0, y=0,
182 time = str(datetime.datetime.now().strftime(
'%Y-%m-%d_%H_%M_%f'))
183 self.
old =
"/home/" + os.getlogin(
184 ) +
"/public_html/roket_display" + time +
".png"
187 url=dict(value=self.
url + time +
".png"), x=0, y=0,
193 time = str(datetime.datetime.now().strftime(
'%Y-%m-%d_%H_%M_%f'))
194 self.
old =
"/home/" + os.getlogin(
195 ) +
"/public_html/roket_display" + time +
".png"
198 url=dict(value=self.
url + time +
".png"), x=0, y=0,
220 Compute the covmats using GROOT model and display it
222 self.
pretext.text =
""" Computing covmats... Please wait"""
230 if "bandwidth & tomography" in contrib:
231 contrib.remove(
"bandwidth & tomography")
232 contrib.append(
"bandwidth")
233 contrib.append(
"tomography")
243 if "noise" in contrib:
246 if "aliasing" in contrib:
249 if "tomography" in contrib
or "bandwidth" in contrib:
259 if "aliasing" in contrib:
270 Compute the PSF from the covmats
272 self.
pretext.text =
""" Computing PSFs... Please wait"""
280 otftel, otf2, self.
psf_groot, _ = gamora.psf_rec_Vii(
282 cov=self.
covmat_groot.astype(np.float32), fitting=
False)
284 otffit, _ = groot.compute_OTF_fitting(
286 self.
psf_groot = gamora.add_fitting_to_psf(
289 _, _, self.
psf_roket, _ = gamora.psf_rec_Vii(