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

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 by ensquaring them. More...
 
def update_cuts (self)
 Update the PSF cuts. More...
 
def comp_psf (self)
 Compute the PSF using the Vii functions and display it. More...
 
def roll_psf (self)
 Roll the COMPASS PSF (for retro-compatibility with old ROKET files) More...
 

Public Attributes

 dataroot
 
 datapath
 
 files
 
 f
 
 Btt
 
 P
 
 url
 
 old
 
 psf_compass
 
 psf_Vii
 
 pretext
 
 SRcompass
 
 SRVii
 
 button_psf
 
 button_roll
 
 select_datapath
 
 select_files
 
 xdr
 
 ydr
 
 image_compass
 
 image_Vii
 
 plot_psf_cuts
 
 source_psf_compass
 
 source_psf_Vii
 
 control_box
 
 tab
 

Detailed Description

Definition at line 18 of file widget_gamora.py.

Constructor & Destructor Documentation

◆ __init__()

def widget_gamora.Bokeh_gamora.__init__ (   self)

Definition at line 20 of file widget_gamora.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 
28  self.f = None
29  self.Btt = None
30  self.P = None
31 
32  self.url = "http://" + os.uname()[1] + ".obspm.fr/~" + os.getlogin(
33  ) + "/roket_display"
34  self.old = None
35  self.psf_compass = None
36  self.psf_Vii = None
37 
38  # Widgets Elements
39  self.pretext = PreText(text=""" """, width=500, height=75)
40  self.SRcompass = TextInput(value=" ", title="SR compass:")
41  self.SRVii = TextInput(value=" ", title="SR Vii:")
42 
43  self.button_psf = Button(label="PSF !", button_type="success")
44  self.button_roll = Button(label="Roll", button_type="primary")
45 
46  self.select_datapath = Select(
47  title="Datapath", value=self.dataroot,
48  options=[self.dataroot] + glob(self.dataroot + "*/"))
49  self.select_files = Select(title="File", value=self.files[0], options=self.files)
50 
51  self.xdr = Range1d(start=0, end=1024)
52  self.ydr = Range1d(start=1024, end=0)
53  self.image_compass = figure(x_range=self.xdr, y_range=self.ydr,
54  x_axis_location="above", title="PSF COMPASS")
55  self.image_Vii = figure(x_range=self.image_compass.x_range,
56  y_range=self.image_compass.y_range,
57  x_axis_location="above", title="PSF ROKET")
58  self.plot_psf_cuts = figure(plot_height=600, plot_width=800, y_range=[1e-9, 1],
59  x_range=self.image_compass.x_range,
60  y_axis_type="log")
61  self.source_psf_compass = ColumnDataSource(data=dict(x=[], y=[]))
62  self.source_psf_Vii = ColumnDataSource(data=dict(x=[], y=[]))
63 
64  self.image_compass.image_url(url=[], x=0, y=0, w=1024, h=1024)
65  self.image_Vii.image_url(url=[], x=0, y=0, w=1024, h=1024)
66  self.plot_psf_cuts.line(x="x", y="y", legend="COMPASS", color="red",
67  muted_alpha=0.1, source=self.source_psf_compass)
68  self.plot_psf_cuts.line(x="x", y="y", legend="Vii", color="blue",
69  muted_alpha=0.1, source=self.source_psf_Vii)
70  self.plot_psf_cuts.legend.click_policy = "mute"
71 
72  # Callback functions
73  self.select_datapath.on_change(
74  "value", lambda attr, old, new: self.update_files())
75  self.select_files.on_change("value", lambda attr, old, new: self.update())
76  self.button_psf.on_click(self.comp_psf)
77  self.button_roll.on_click(self.roll_psf)
78 
79  self.update()
80 
81  #layouts
82  self.control_box = widgetbox(self.select_datapath, self.select_files,
83  self.button_psf, self.button_roll, self.SRcompass,
84  self.SRVii, self.pretext)
85  self.tab = Panel(
86  child=layout([[self.control_box, self.image_compass, self.image_Vii],
87  [self.plot_psf_cuts]]), title="GAMORA")
88 

Member Function Documentation

◆ comp_psf()

def widget_gamora.Bokeh_gamora.comp_psf (   self)

Compute the PSF using the Vii functions and display it.

Definition at line 159 of file widget_gamora.py.

159  """
160  self.pretext.text = """ Computing PSF using Vii... Please wait"""
161  self.button_psf.button_type = "danger"
162  _, _, self.psf_Vii, _ = gamora.psf_rec_Vii(self.datapath +
163  str(self.select_files.value))
164  self.psf_compass = self.f["psf"][:]
165  self.update_psf()
166  self.pretext.text = """ """
167  self.button_psf.button_type = "success"
168 
Here is the call graph for this function:

◆ roll_psf()

def widget_gamora.Bokeh_gamora.roll_psf (   self)

Roll the COMPASS PSF (for retro-compatibility with old ROKET files)

Definition at line 172 of file widget_gamora.py.

172  """
173  self.psf_compass = np.fft.fftshift(self.psf_compass)
174  self.update_psf()
Here is the call graph for this function:

◆ update()

def widget_gamora.Bokeh_gamora.update (   self)

Update the attributes based on the new selected filename.

Definition at line 92 of file widget_gamora.py.

92  """
93  if os.path.exists(self.datapath + str(self.select_files.value)):
94  self.f = h5py.File(self.datapath + str(self.select_files.value), mode='r+')
95  self.psf_compass = self.f["psf"][:]
96  self.psf_Vii = None
97  self.Btt = self.f["Btt"][:]
98  self.P = self.f["P"][:]
99 
Here is the caller graph for this function:

◆ update_cuts()

def widget_gamora.Bokeh_gamora.update_cuts (   self)

Update the PSF cuts.

Definition at line 148 of file widget_gamora.py.

148  """
149  x = np.arange(self.psf_compass.shape[0])
150  self.source_psf_compass.data = dict(
151  x=x, y=self.psf_compass[:, self.psf_compass.shape[0] // 2])
152  if self.psf_Vii is not None:
153  self.source_psf_Vii.data = dict(
154  x=x, y=self.psf_Vii[:, self.psf_Vii.shape[0] // 2])
155 
Here is the caller graph for this function:

◆ update_files()

def widget_gamora.Bokeh_gamora.update_files (   self)

Update the select_files options following the current datapath.

Definition at line 103 of file widget_gamora.py.

103  """
104  self.datapath = str(self.select_datapath.value)
105  self.files = self.files = [
106  f.split('/')[-1] for f in glob(self.datapath + "roket_*.h5")
107  ]
108  if self.files == []:
109  self.files = ["No hdf5 files"]
110 
111  self.select_files.options = self.files
112  self.select_files.value = self.files[0]
113 

◆ update_psf()

def widget_gamora.Bokeh_gamora.update_psf (   self)

Update the PSF by ensquaring them.

Definition at line 117 of file widget_gamora.py.

117  """
118 
119  psfc = self.psf_compass
120  time = str(datetime.datetime.now().strftime('%Y-%m-%d_%H_%M_%f'))
121  self.old = "/home/" + os.getlogin() + "/public_html/roket_display" + time + ".png"
122  mpl.image.imsave(self.old, np.log10(np.abs(psfc)))
123  self.image_compass.image_url(
124  url=dict(value=self.url + time + ".png"), x=0, y=0, w=psfc.shape[0],
125  h=psfc.shape[0])
126  self.image_compass.x_range.update(start=0, end=psfc.shape[0])
127  self.image_compass.y_range.update(start=psfc.shape[0], end=0)
128 
129  self.SRcompass.value = "%.2f" % (self.psf_compass.max())
130 
131  if self.psf_Vii is not None:
132 
133  psfv = self.psf_Vii
134  time = str(datetime.datetime.now().strftime('%Y-%m-%d_%H_%M_%f'))
135  self.old = "/home/" + os.getlogin(
136  ) + "/public_html/roket_display" + time + ".png"
137  mpl.image.imsave(self.old, np.log10(np.abs(psfv)))
138  self.image_Vii.image_url(
139  url=dict(value=self.url + time + ".png"), x=0, y=0, w=psfc.shape[0],
140  h=psfc.shape[0])
141  self.SRVii.value = "%.2f" % (self.psf_Vii.max())
142 
143  self.update_cuts()
144 
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Btt

widget_gamora.Bokeh_gamora.Btt

Definition at line 29 of file widget_gamora.py.

◆ button_psf

widget_gamora.Bokeh_gamora.button_psf

Definition at line 43 of file widget_gamora.py.

◆ button_roll

widget_gamora.Bokeh_gamora.button_roll

Definition at line 44 of file widget_gamora.py.

◆ control_box

widget_gamora.Bokeh_gamora.control_box

Definition at line 82 of file widget_gamora.py.

◆ datapath

widget_gamora.Bokeh_gamora.datapath

Definition at line 23 of file widget_gamora.py.

◆ dataroot

widget_gamora.Bokeh_gamora.dataroot

Definition at line 22 of file widget_gamora.py.

◆ f

widget_gamora.Bokeh_gamora.f

Definition at line 28 of file widget_gamora.py.

◆ files

widget_gamora.Bokeh_gamora.files

Definition at line 24 of file widget_gamora.py.

◆ image_compass

widget_gamora.Bokeh_gamora.image_compass

Definition at line 53 of file widget_gamora.py.

◆ image_Vii

widget_gamora.Bokeh_gamora.image_Vii

Definition at line 55 of file widget_gamora.py.

◆ old

widget_gamora.Bokeh_gamora.old

Definition at line 34 of file widget_gamora.py.

◆ P

widget_gamora.Bokeh_gamora.P

Definition at line 30 of file widget_gamora.py.

◆ plot_psf_cuts

widget_gamora.Bokeh_gamora.plot_psf_cuts

Definition at line 58 of file widget_gamora.py.

◆ pretext

widget_gamora.Bokeh_gamora.pretext

Definition at line 39 of file widget_gamora.py.

◆ psf_compass

widget_gamora.Bokeh_gamora.psf_compass

Definition at line 35 of file widget_gamora.py.

◆ psf_Vii

widget_gamora.Bokeh_gamora.psf_Vii

Definition at line 36 of file widget_gamora.py.

◆ select_datapath

widget_gamora.Bokeh_gamora.select_datapath

Definition at line 46 of file widget_gamora.py.

◆ select_files

widget_gamora.Bokeh_gamora.select_files

Definition at line 49 of file widget_gamora.py.

◆ source_psf_compass

widget_gamora.Bokeh_gamora.source_psf_compass

Definition at line 61 of file widget_gamora.py.

◆ source_psf_Vii

widget_gamora.Bokeh_gamora.source_psf_Vii

Definition at line 62 of file widget_gamora.py.

◆ SRcompass

widget_gamora.Bokeh_gamora.SRcompass

Definition at line 40 of file widget_gamora.py.

◆ SRVii

widget_gamora.Bokeh_gamora.SRVii

Definition at line 41 of file widget_gamora.py.

◆ tab

widget_gamora.Bokeh_gamora.tab

Definition at line 85 of file widget_gamora.py.

◆ url

widget_gamora.Bokeh_gamora.url

Definition at line 32 of file widget_gamora.py.

◆ xdr

widget_gamora.Bokeh_gamora.xdr

Definition at line 51 of file widget_gamora.py.

◆ ydr

widget_gamora.Bokeh_gamora.ydr

Definition at line 52 of file widget_gamora.py.


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