Skip to content

Commit c24fa46

Browse files
committed
WCIViewer: added missing with self.output tags
1 parent 82cb5ba commit c24fa46

File tree

1 file changed

+48
-45
lines changed
  • python/themachinethatgoesping/pingprocessing/widgets

1 file changed

+48
-45
lines changed

python/themachinethatgoesping/pingprocessing/widgets/wciviewer.py

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ def __init__(self, pings, horizontal_pixels=1024, name="WCI", figure=None, progr
230230
display(self.layout)
231231

232232
def set_ping_sample_selector(self, ping_sample_selector, apply_pss_to_bottom=False):
233-
self.args_imagebuilder["ping_sample_selector"] = ping_sample_selector
234-
self.args_imagebuilder["apply_pss_to_bottom"] = apply_pss_to_bottom
235-
self.update_data(0)
233+
with self.output:
234+
self.args_imagebuilder["ping_sample_selector"] = ping_sample_selector
235+
self.args_imagebuilder["apply_pss_to_bottom"] = apply_pss_to_bottom
236+
self.update_data(0)
236237

237238
def fix_xy(self, w):
238239
with self.output:
@@ -256,55 +257,57 @@ def unfix_xy(self, w):
256257

257258
# @self.output.capture()
258259
def update_data(self, w=None):
259-
self.output.clear_output()
260-
t0 = time()
260+
with self.output:
261+
self.output.clear_output()
262+
t0 = time()
261263

262-
if self.wci_value is None:
263-
self.args_imagebuilder["wci_value"] = self.w_wci_value.value
264-
else:
265-
self.args_imagebuilder["wci_value"] = self.wci_value
266-
self.args_imagebuilder["wci_render"] = self.w_wci_render.value
267-
self.args_imagebuilder["linear_mean"] = self.w_stack_linear.value
268-
self.args_imagebuilder["horizontal_pixels"] = self.w_horizontal_pixels.value
269-
self.args_imagebuilder["mp_cores"] = self.w_mp_cores.value
270-
self.imagebuilder.update_args(**self.args_imagebuilder)
271-
272-
try:
273-
self.wci, self.extent = self.imagebuilder.build(
274-
index=self.w_index.value, stack=self.w_stack.value, stack_step=self.w_stack_step.value
275-
)
276-
self.callback_data()
277-
278-
# w_text_execution_time.value = str(round(time()-t,3))
279-
280-
except Exception as e:
281-
with self.output:
282-
raise (e)
264+
if self.wci_value is None:
265+
self.args_imagebuilder["wci_value"] = self.w_wci_value.value
266+
else:
267+
self.args_imagebuilder["wci_value"] = self.wci_value
268+
self.args_imagebuilder["wci_render"] = self.w_wci_render.value
269+
self.args_imagebuilder["linear_mean"] = self.w_stack_linear.value
270+
self.args_imagebuilder["horizontal_pixels"] = self.w_horizontal_pixels.value
271+
self.args_imagebuilder["mp_cores"] = self.w_mp_cores.value
272+
self.imagebuilder.update_args(**self.args_imagebuilder)
283273

284-
t1 = time()
285-
self.update_view(w)
286-
t2 = time()
287-
ping = self.imagebuilder.pings[self.w_index.value]
288-
if not isinstance(ping, theping.echosounders.filetemplates.I_Ping):
289-
ping = next(iter(ping.values()))
274+
try:
275+
self.wci, self.extent = self.imagebuilder.build(
276+
index=self.w_index.value, stack=self.w_stack.value, stack_step=self.w_stack_step.value
277+
)
278+
self.callback_data()
279+
280+
# w_text_execution_time.value = str(round(time()-t,3))
281+
282+
except Exception as e:
283+
with self.output:
284+
raise (e)
285+
286+
t1 = time()
287+
self.update_view(w)
288+
t2 = time()
289+
ping = self.imagebuilder.pings[self.w_index.value]
290+
if not isinstance(ping, theping.echosounders.filetemplates.I_Ping):
291+
ping = next(iter(ping.values()))
290292

291-
self.w_date.value = ping.get_datetime().strftime("%Y-%m-%d")
292-
self.w_time.value = ping.get_datetime().strftime("%H:%M:%S")
293+
self.w_date.value = ping.get_datetime().strftime("%Y-%m-%d")
294+
self.w_time.value = ping.get_datetime().strftime("%H:%M:%S")
293295

294-
self.w_proctime.value = f"{round(t1-t0,3)} / {round(t2-t1,3)} / [{round(t2-t0,3)}] s"
295-
r1 = 1/(t1-t0) if t1-t0 > 0 else 0
296-
r2 = 1/(t2-t1) if t2-t1 > 0 else 0
297-
r3 = 1/(t2-t0) if t2-t0 > 0 else 0
296+
self.w_proctime.value = f"{round(t1-t0,3)} / {round(t2-t1,3)} / [{round(t2-t0,3)}] s"
297+
r1 = 1/(t1-t0) if t1-t0 > 0 else 0
298+
r2 = 1/(t2-t1) if t2-t1 > 0 else 0
299+
r3 = 1/(t2-t0) if t2-t0 > 0 else 0
298300

299-
self.w_procrate.value = f"r1: {round(r1,1)} / r2: {round(r2,1)} / r3: [{round(r3,1)}] Hz"
301+
self.w_procrate.value = f"r1: {round(r1,1)} / r2: {round(r2,1)} / r3: [{round(r3,1)}] Hz"
300302

301303
def save_background(self):
302-
empty = np.empty(self.wci.transpose().shape)
303-
empty.fill(np.nan)
304-
self.mapable.set_data(empty)
305-
self.fig.canvas.draw()
306-
self.background = self.fig.canvas.copy_from_bbox(self.fig.bbox)
307-
# self.mapable.set_data(self.wci.transpose())
304+
with self.output:
305+
empty = np.empty(self.wci.transpose().shape)
306+
empty.fill(np.nan)
307+
self.mapable.set_data(empty)
308+
self.fig.canvas.draw()
309+
self.background = self.fig.canvas.copy_from_bbox(self.fig.bbox)
310+
# self.mapable.set_data(self.wci.transpose())
308311

309312
def update_view(self, w=None):
310313
with self.output:

0 commit comments

Comments
 (0)