spacetelescope / jdat_notebooks

JWST Data Analysis Tools Notebooks
https://spacetelescope.github.io/jdat_notebooks/
98 stars 80 forks source link

ifu_optimal.ipynb - Visualize Science Data with Cubeviz - ZeroDivisionError: division by zero #189

Closed JosephKarpinski closed 6 months ago

JosephKarpinski commented 7 months ago

Python 3.11.6 using Visual Studio Code Version: 1.84.2

cubeviz = Cubeviz() cubeviz.app


ZeroDivisionError Traceback (most recent call last) File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/bqplot_image_gl/viewlistener.py:30, in ViewListener._on_custom_msg(self, widget, content, buffers) 28 id = content['id'] 29 data = content['data'] ---> 30 self.view_data = {**self.view_data, id: data} 31 elif content.get('event', '') == 'remove_view_data': 32 id = content['id']

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:718, in TraitType.set(self, obj, value) 716 raise TraitError('The "%s" trait is read-only.' % self.name) 717 else: --> 718 self.set(obj, value)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:707, in TraitType.set(self, obj, value) 703 silent = False 704 if silent is not True: 705 # we explicitly compare silent to True just in case the equality 706 # comparison above returns something other than True/False --> 707 obj._notify_trait(self.name, old_value, new_value)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:1515, in HasTraits._notify_trait(self, name, old_value, new_value) 1514 def _notify_trait(self, name: str, old_value: t.Any, new_value: t.Any) -> None: -> 1515 self.notify_change( 1516 Bunch( 1517 name=name, 1518 old=old_value, 1519 new=new_value, 1520 owner=self, 1521 type="change", 1522 ) 1523 )

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:701, in Widget.notify_change(self, change) 698 if name in self.keys and self._should_send_property(name, getattr(self, name)): 699 # Send new state to front-end 700 self.send_state(key=name) --> 701 super().notify_change(change)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:1527, in HasTraits.notify_change(self, change) 1525 def notify_change(self, change: Bunch) -> None: 1526 """Notify observers of a change event""" -> 1527 return self._notify_observers(change)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:1570, in HasTraits._notify_observers(self, event) 1567 elif isinstance(c, EventHandler) and c.name is not None: 1568 c = getattr(self, c.name) -> 1570 c(event)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/glue_jupyter/bqplot/image/viewer.py:81, in BqplotImageView._on_view_change(self, *args) 79 else: 80 self.shape = None ---> 81 self._sync_figure_aspect()

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/glue_jupyter/bqplot/image/viewer.py:90, in BqplotImageView._sync_figure_aspect(self, *args, **kwargs) 88 else: 89 height, width = self._composite_image.shape ---> 90 axes_ratio = height / width 91 else: 92 axes_ratio = None

ZeroDivisionError: division by zero

ZeroDivisionError Traceback (most recent call last) File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/bqplot_image_gl/viewlistener.py:30, in ViewListener._on_custom_msg(self, widget, content, buffers) 28 id = content['id'] 29 data = content['data'] ---> 30 self.view_data = {**self.view_data, id: data} 31 elif content.get('event', '') == 'remove_view_data': 32 id = content['id']

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:718, in TraitType.set(self, obj, value) 716 raise TraitError('The "%s" trait is read-only.' % self.name) 717 else: --> 718 self.set(obj, value)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:707, in TraitType.set(self, obj, value) 703 silent = False 704 if silent is not True: 705 # we explicitly compare silent to True just in case the equality 706 # comparison above returns something other than True/False --> 707 obj._notify_trait(self.name, old_value, new_value)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:1515, in HasTraits._notify_trait(self, name, old_value, new_value) 1514 def _notify_trait(self, name: str, old_value: t.Any, new_value: t.Any) -> None: -> 1515 self.notify_change( 1516 Bunch( 1517 name=name, 1518 old=old_value, 1519 new=new_value, 1520 owner=self, 1521 type="change", 1522 ) 1523 )

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/ipywidgets/widgets/widget.py:701, in Widget.notify_change(self, change) 698 if name in self.keys and self._should_send_property(name, getattr(self, name)): 699 # Send new state to front-end 700 self.send_state(key=name) --> 701 super().notify_change(change)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:1527, in HasTraits.notify_change(self, change) 1525 def notify_change(self, change: Bunch) -> None: 1526 """Notify observers of a change event""" -> 1527 return self._notify_observers(change)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/traitlets/traitlets.py:1570, in HasTraits._notify_observers(self, event) 1567 elif isinstance(c, EventHandler) and c.name is not None: 1568 c = getattr(self, c.name) -> 1570 c(event)

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/glue_jupyter/bqplot/image/viewer.py:81, in BqplotImageView._on_view_change(self, *args) 79 else: 80 self.shape = None ---> 81 self._sync_figure_aspect()

File ~/opt/anaconda3/envs/env311Jdat/lib/python3.11/site-packages/glue_jupyter/bqplot/image/viewer.py:90, in BqplotImageView._sync_figure_aspect(self, *args, **kwargs) 88 else: 89 height, width = self._composite_image.shape ---> 90 axes_ratio = height / width 91 else: 92 axes_ratio = None

ZeroDivisionError: division by zero

camipacifici commented 6 months ago

Hi! This notebook has just been updated. Can you try the new version and let us know if you still encounter the error please? Thank you!

JosephKarpinski commented 6 months ago

Downloaded GitHub updated notebooks https://github.com/spacetelescope/jdat_notebooks/tree/main

Same error using jdaviz 3.7.1

pip install upgrade jdaviz 3.8.0

Same error

Screenshot 2023-12-13 at 10 56 28 AM Screenshot 2023-12-13 at 10 56 54 AM Screenshot 2023-12-13 at 10 57 56 AM Screenshot 2023-12-13 at 10 58 32 AM
camipacifici commented 6 months ago

Thank you for trying with the updated notebook and the newest version of jdaviz. Unfortunately, we do not test in VScode and we do not really support it. Is there any chance you could use Jupyter Notebook or Lab outside of VScode?

JosephKarpinski commented 6 months ago

You're right. It works under Jupyter Notebook but not VSCODE. I should have tried that. Please close.

Thank you!

Best Regards,

Joseph Karpinski

Screenshot 2023-12-13 at 2 12 50 PM
camipacifici commented 6 months ago

Glad it's solved! Feel free to open new issues if you have any other problem.