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

Public Member Functions

def __init__ (self)
 
def update (self)
 Update the attributes based on the new selected filename. More...
 
def update_files (self)
 Update the select_files options following the current datapath. More...
 
def update_psf (self)
 Update the PSF display. More...
 
def update_covmats (self)
 Update the covmats. More...
 
def update_cuts (self)
 Update the PSF cuts. More...
 
def comp_covmats (self)
 Compute the covmats using GROOT model and display it. More...
 
def comp_psf (self)
 Compute the PSF from the covmats. More...
 

Public Attributes

 dataroot
 
 datapath
 
 files
 
 f
 
 Btt
 
 P
 
 nactus
 
 nmodes
 
 nslopes
 
 url
 
 old
 
 psf_compass
 
 psf_roket
 
 psf_groot
 
 covmat_groot
 
 covmat_roket
 
 pretext
 
 SRcompass
 
 SRroket
 
 SRgroot
 
 button_covmat
 
 button_psf
 
 toggle_fit
 
 select_datapath
 
 select_files
 
 contributors
 
 checkboxButtonGroup_contributors
 
 radioButton_basis
 
 xdr
 
 ydr
 
 xdr2
 
 ydr2
 
 image_roket
 
 image_groot
 
 im_covmat_roket
 
 im_covmat_groot
 
 plot_psf_cuts
 
 source_psf_roket
 
 source_psf_groot
 
 source_psf_compass
 
 source_covmat_roket
 
 source_covmat_groot
 
 control_box
 
 tab
 

Detailed Description

Definition at line 18 of file widget_groot.py.

Constructor & Destructor Documentation

◆ __init__()

def widget_groot.Bokeh_groot.__init__ (   self)

Definition at line 20 of file widget_groot.py.

20  def __init__(self):
21 
22  self.dataroot = os.getenv("DATA_GUARDIAN")
23  self.datapath = self.dataroot
24  self.files = [f.split('/')[-1] for f in glob(self.datapath + "roket_*.h5")]
25  if self.files == []:
26  self.files = ["No hdf5 files"]
27  self.f = None
28  self.Btt = None
29  self.P = None
30  self.nactus = None
31  self.nmodes = None
32  self.nslopes = None
33 
34  self.url = "http://" + os.uname()[1] + ".obspm.fr/~" + os.getlogin(
35  ) + "/roket_display"
36  self.old = None
37  self.psf_compass = None
38  self.psf_roket = None
39  self.psf_groot = None
40  self.covmat_groot = None
41  self.covmat_roket = None
42 
43  # Widgets Elements
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:")
48 
49  self.button_covmat = Button(label="Covmat", button_type="success")
50  self.button_psf = Button(label="PSF !", button_type="success")
51  self.toggle_fit = Toggle(label="Fitting", button_type="primary")
52 
53  self.select_datapath = Select(
54  title="Datapath", value=self.dataroot,
55  options=[self.dataroot] + glob(self.dataroot + "*/"))
56  self.select_files = Select(title="File", value=self.files[0], options=self.files)
57 
58  self.contributors = ["noise", "bandwidth & tomography", "aliasing"]
59  self.checkboxButtonGroup_contributors = CheckboxButtonGroup(
60  labels=self.contributors, active=[])
61  self.radioButton_basis = RadioButtonGroup(labels=["Actus", "Btt", "Slopes"],
62  active=0)
63 
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)
68  self.image_roket = figure(x_range=self.xdr, y_range=self.ydr,
69  x_axis_location="above", title="PSF ROKET")
70  self.image_groot = figure(x_range=self.image_roket.x_range,
71  y_range=self.image_roket.y_range,
72  x_axis_location="above", title="PSF GROOT")
73  self.im_covmat_roket = figure(x_range=self.xdr2, y_range=self.ydr2,
74  x_axis_location="above", title="Covmat ROKET")
75  self.im_covmat_groot = figure(x_range=self.im_covmat_roket.x_range,
76  y_range=self.im_covmat_roket.y_range,
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")
80  self.source_psf_roket = ColumnDataSource(data=dict(x=[], y=[]))
81  self.source_psf_groot = ColumnDataSource(data=dict(x=[], y=[]))
82  self.source_psf_compass = ColumnDataSource(data=dict(x=[], y=[]))
83  self.source_covmat_roket = ColumnDataSource(data=dict(x=[], y=[]))
84  self.source_covmat_groot = ColumnDataSource(data=dict(x=[], y=[]))
85 
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)
88  self.im_covmat_roket.image_url(url=[], x=0, y=0, w=1024, h=1024)
89  self.im_covmat_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",
91  muted_alpha=0.1, source=self.source_psf_roket)
92  self.plot_psf_cuts.line(x="x", y="y", legend="COMPASS", color="red",
93  muted_alpha=0.1, source=self.source_psf_compass)
94  self.plot_psf_cuts.line(x="x", y="y", legend="GROOT", color="green",
95  muted_alpha=0.1, source=self.source_psf_groot)
96  self.plot_psf_cuts.legend.click_policy = "mute"
97 
98  # Callback functions
99  self.select_datapath.on_change(
100  "value", lambda attr, old, new: self.update_files())
101  self.select_files.on_change("value", lambda attr, old, new: self.update())
102  self.button_psf.on_click(self.comp_psf)
103  self.button_covmat.on_click(self.comp_covmats)
104  self.update()
105 
106  #layouts
107  self.control_box = widgetbox(self.select_datapath, self.select_files,
108  self.checkboxButtonGroup_contributors,
109  self.radioButton_basis, self.button_covmat,
110  self.button_psf, self.toggle_fit, self.SRcompass,
111  self.SRroket, self.SRgroot, self.pretext)
112  self.tab = Panel(
113  child=layout([[
114  self.control_box, self.im_covmat_roket, self.im_covmat_groot
115  ], [self.image_roket, self.image_groot], [self.plot_psf_cuts]]),
116  title="GROOT")
117 

Member Function Documentation

◆ comp_covmats()

def widget_groot.Bokeh_groot.comp_covmats (   self)

Compute the covmats using GROOT model and display it.

Definition at line 221 of file widget_groot.py.

221  """
222  self.pretext.text = """ Computing covmats... Please wait"""
223  self.button_covmat.button_type = "danger"
224  contrib = [
225  self.contributors[c]
226  for c in self.checkboxButtonGroup_contributors.active
227  ]
228  if contrib == []:
229  contrib = self.contributors
230  if "bandwidth & tomography" in contrib:
231  contrib.remove("bandwidth & tomography")
232  contrib.append("bandwidth")
233  contrib.append("tomography")
234  modal = self.radioButton_basis.active
235  if modal == 1:
236  self.covmat_groot = np.zeros((self.nmodes, self.nmodes))
237  elif modal == 2:
238  self.covmat_groot = np.zeros((self.nslopes, self.nslopes))
239  else:
240  self.covmat_groot = np.zeros((self.nactus, self.nactus))
241 
242  if modal != 2:
243  if "noise" in contrib:
244  self.covmat_groot += groot.compute_Cn_cpu(
245  self.datapath + str(self.select_files.value), modal=modal)
246  if "aliasing" in contrib:
247  self.covmat_groot += groot.compute_Ca_cpu(
248  self.datapath + str(self.select_files.value), modal=modal)
249  if "tomography" in contrib or "bandwidth" in contrib:
250  self.covmat_groot += groot.compute_Cerr(
251  self.datapath + str(self.select_files.value), modal=modal)
252 
253  err = drax.get_err_contributors(self.datapath + str(self.select_files.value),
254  contrib)
255  self.covmat_roket = err.dot(err.T) / err.shape[1]
256  if modal:
257  self.covmat_roket = self.P.dot(self.covmat_roket).dot(self.P.T)
258  else:
259  if "aliasing" in contrib:
260  self.covmat_groot, self.covmat_roket = groot.compute_Calias(
261  self.datapath + str(self.select_files.value))
262 
263  self.update_covmats()
264 
265  self.pretext.text = """ """
266  self.button_covmat.button_type = "success"
267 
Here is the call graph for this function:

◆ comp_psf()

def widget_groot.Bokeh_groot.comp_psf (   self)

Compute the PSF from the covmats.

Definition at line 271 of file widget_groot.py.

271  """
272  self.pretext.text = """ Computing PSFs... Please wait"""
273  self.button_psf.button_type = "danger"
274 
275  fit = self.toggle_fit.active
276  if self.covmat_groot.shape[0] != self.nmodes:
277  self.covmat_groot = self.P.dot(self.covmat_groot).dot(self.P.T)
278  self.covmat_roket = self.P.dot(self.covmat_roket).dot(self.P.T)
279 
280  otftel, otf2, self.psf_groot, _ = gamora.psf_rec_Vii(
281  self.datapath + str(self.select_files.value),
282  cov=self.covmat_groot.astype(np.float32), fitting=False)
283  if fit:
284  otffit, _ = groot.compute_OTF_fitting(
285  self.datapath + str(self.select_files.value), otftel)
286  self.psf_groot = gamora.add_fitting_to_psf(
287  self.datapath + str(self.select_files.value), otf2 * otftel, otffit)
288 
289  _, _, self.psf_roket, _ = gamora.psf_rec_Vii(
290  self.datapath + str(self.select_files.value),
291  cov=self.covmat_roket.astype(np.float32), fitting=fit)
292 
293  self.update_psf()
294  self.pretext.text = """ """
295  self.button_psf.button_type = "success"
Here is the call graph for this function:

◆ update()

def widget_groot.Bokeh_groot.update (   self)

Update the attributes based on the new selected filename.

Definition at line 121 of file widget_groot.py.

121  """
122  if os.path.exists(self.datapath + str(self.select_files.value)):
123  self.f = h5py.File(self.datapath + str(self.select_files.value), mode='r+')
124  self.psf_compass = self.f["psf"][:]
125  self.SRcompass.value = "%.2f" % (self.psf_compass.max())
126  self.psf_groot = None
127  self.psf_roket = None
128  self.covmat_groot = None
129  self.covmat_roket = None
130  self.Btt = self.f["Btt"][:]
131  self.P = self.f["P"][:]
132  self.nactus = self.P.shape[1]
133  self.nmodes = self.P.shape[0]
134  self.nslopes = self.f["R"][:].shape[1]
135 
Here is the caller graph for this function:

◆ update_covmats()

def widget_groot.Bokeh_groot.update_covmats (   self)

Update the covmats.

Definition at line 180 of file widget_groot.py.

180  """
181  if self.covmat_roket is not None:
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"
185  mpl.image.imsave(self.old, self.covmat_roket)
186  self.im_covmat_roket.image_url(
187  url=dict(value=self.url + time + ".png"), x=0, y=0,
188  w=self.covmat_roket.shape[0], h=self.covmat_roket.shape[0])
189  self.im_covmat_roket.x_range.update(start=0, end=self.covmat_roket.shape[0])
190  self.im_covmat_roket.y_range.update(start=self.covmat_roket.shape[0], end=0)
191 
192  if self.covmat_groot is not None:
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"
196  mpl.image.imsave(self.old, self.covmat_groot)
197  self.im_covmat_groot.image_url(
198  url=dict(value=self.url + time + ".png"), x=0, y=0,
199  w=self.covmat_groot.shape[0], h=self.covmat_groot.shape[0])
200 
Here is the caller graph for this function:

◆ update_cuts()

def widget_groot.Bokeh_groot.update_cuts (   self)

Update the PSF cuts.

Definition at line 204 of file widget_groot.py.

204  """
205  if self.psf_roket is not None:
206  x = np.arange(self.psf_roket.shape[0])
207  self.source_psf_roket.data = dict(
208  x=x, y=self.psf_roket[:, self.psf_roket.shape[0] // 2])
209  if self.psf_groot is not None:
210  x = np.arange(self.psf_groot.shape[0])
211  self.source_psf_groot.data = dict(
212  x=x, y=self.psf_groot[:, self.psf_groot.shape[0] // 2])
213  if self.psf_compass is not None:
214  x = np.arange(self.psf_compass.shape[0])
215  self.source_psf_compass.data = dict(
216  x=x, y=self.psf_compass[:, self.psf_compass.shape[0] // 2])
217 
Here is the caller graph for this function:

◆ update_files()

def widget_groot.Bokeh_groot.update_files (   self)

Update the select_files options following the current datapath.

Definition at line 139 of file widget_groot.py.

139  """
140  self.datapath = str(self.select_datapath.value)
141  self.files = self.files = [
142  f.split('/')[-1] for f in glob(self.datapath + "roket_*.h5")
143  ]
144  if self.files == []:
145  self.files = ["No hdf5 files"]
146  self.select_files.options = self.files
147  self.select_files.value = self.files[0]
148 

◆ update_psf()

def widget_groot.Bokeh_groot.update_psf (   self)

Update the PSF display.

Definition at line 152 of file widget_groot.py.

152  """
153  if self.psf_roket is not None:
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)))
158  self.image_roket.image_url(
159  url=dict(value=self.url + time + ".png"), x=0, y=0,
160  w=self.psf_roket.shape[0], h=self.psf_roket.shape[0])
161  self.image_roket.x_range.update(start=0, end=self.psf_roket.shape[0])
162  self.image_roket.y_range.update(start=self.psf_roket.shape[0], end=0)
163  self.SRroket.value = "%.2f" % (self.psf_roket.max())
164 
165  if self.psf_groot is not None:
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)))
170  self.image_groot.image_url(
171  url=dict(value=self.url + time + ".png"), x=0, y=0,
172  w=self.psf_groot.shape[0], h=self.psf_groot.shape[0])
173  self.SRgroot.value = "%.2f" % (self.psf_groot.max())
174 
175  self.update_cuts()
176 
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Btt

widget_groot.Bokeh_groot.Btt

Definition at line 28 of file widget_groot.py.

◆ button_covmat

widget_groot.Bokeh_groot.button_covmat

Definition at line 49 of file widget_groot.py.

◆ button_psf

widget_groot.Bokeh_groot.button_psf

Definition at line 50 of file widget_groot.py.

◆ checkboxButtonGroup_contributors

widget_groot.Bokeh_groot.checkboxButtonGroup_contributors

Definition at line 59 of file widget_groot.py.

◆ contributors

widget_groot.Bokeh_groot.contributors

Definition at line 58 of file widget_groot.py.

◆ control_box

widget_groot.Bokeh_groot.control_box

Definition at line 107 of file widget_groot.py.

◆ covmat_groot

widget_groot.Bokeh_groot.covmat_groot

Definition at line 40 of file widget_groot.py.

◆ covmat_roket

widget_groot.Bokeh_groot.covmat_roket

Definition at line 41 of file widget_groot.py.

◆ datapath

widget_groot.Bokeh_groot.datapath

Definition at line 23 of file widget_groot.py.

◆ dataroot

widget_groot.Bokeh_groot.dataroot

Definition at line 22 of file widget_groot.py.

◆ f

widget_groot.Bokeh_groot.f

Definition at line 27 of file widget_groot.py.

◆ files

widget_groot.Bokeh_groot.files

Definition at line 24 of file widget_groot.py.

◆ im_covmat_groot

widget_groot.Bokeh_groot.im_covmat_groot

Definition at line 75 of file widget_groot.py.

◆ im_covmat_roket

widget_groot.Bokeh_groot.im_covmat_roket

Definition at line 73 of file widget_groot.py.

◆ image_groot

widget_groot.Bokeh_groot.image_groot

Definition at line 70 of file widget_groot.py.

◆ image_roket

widget_groot.Bokeh_groot.image_roket

Definition at line 68 of file widget_groot.py.

◆ nactus

widget_groot.Bokeh_groot.nactus

Definition at line 30 of file widget_groot.py.

◆ nmodes

widget_groot.Bokeh_groot.nmodes

Definition at line 31 of file widget_groot.py.

◆ nslopes

widget_groot.Bokeh_groot.nslopes

Definition at line 32 of file widget_groot.py.

◆ old

widget_groot.Bokeh_groot.old

Definition at line 36 of file widget_groot.py.

◆ P

widget_groot.Bokeh_groot.P

Definition at line 29 of file widget_groot.py.

◆ plot_psf_cuts

widget_groot.Bokeh_groot.plot_psf_cuts

Definition at line 78 of file widget_groot.py.

◆ pretext

widget_groot.Bokeh_groot.pretext

Definition at line 44 of file widget_groot.py.

◆ psf_compass

widget_groot.Bokeh_groot.psf_compass

Definition at line 37 of file widget_groot.py.

◆ psf_groot

widget_groot.Bokeh_groot.psf_groot

Definition at line 39 of file widget_groot.py.

◆ psf_roket

widget_groot.Bokeh_groot.psf_roket

Definition at line 38 of file widget_groot.py.

◆ radioButton_basis

widget_groot.Bokeh_groot.radioButton_basis

Definition at line 61 of file widget_groot.py.

◆ select_datapath

widget_groot.Bokeh_groot.select_datapath

Definition at line 53 of file widget_groot.py.

◆ select_files

widget_groot.Bokeh_groot.select_files

Definition at line 56 of file widget_groot.py.

◆ source_covmat_groot

widget_groot.Bokeh_groot.source_covmat_groot

Definition at line 84 of file widget_groot.py.

◆ source_covmat_roket

widget_groot.Bokeh_groot.source_covmat_roket

Definition at line 83 of file widget_groot.py.

◆ source_psf_compass

widget_groot.Bokeh_groot.source_psf_compass

Definition at line 82 of file widget_groot.py.

◆ source_psf_groot

widget_groot.Bokeh_groot.source_psf_groot

Definition at line 81 of file widget_groot.py.

◆ source_psf_roket

widget_groot.Bokeh_groot.source_psf_roket

Definition at line 80 of file widget_groot.py.

◆ SRcompass

widget_groot.Bokeh_groot.SRcompass

Definition at line 45 of file widget_groot.py.

◆ SRgroot

widget_groot.Bokeh_groot.SRgroot

Definition at line 47 of file widget_groot.py.

◆ SRroket

widget_groot.Bokeh_groot.SRroket

Definition at line 46 of file widget_groot.py.

◆ tab

widget_groot.Bokeh_groot.tab

Definition at line 112 of file widget_groot.py.

◆ toggle_fit

widget_groot.Bokeh_groot.toggle_fit

Definition at line 51 of file widget_groot.py.

◆ url

widget_groot.Bokeh_groot.url

Definition at line 34 of file widget_groot.py.

◆ xdr

widget_groot.Bokeh_groot.xdr

Definition at line 64 of file widget_groot.py.

◆ xdr2

widget_groot.Bokeh_groot.xdr2

Definition at line 66 of file widget_groot.py.

◆ ydr

widget_groot.Bokeh_groot.ydr

Definition at line 65 of file widget_groot.py.

◆ ydr2

widget_groot.Bokeh_groot.ydr2

Definition at line 67 of file widget_groot.py.


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