Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Imviz with only Glue + bqplot #417

Closed
wants to merge 1 commit into from

Conversation

pllim
Copy link
Contributor

@pllim pllim commented Jan 29, 2021

You would think this would Just Work ™️ but it doesn't. I will need an expert to advise, or someone else is free to take over the PR.

Traceback:

      3 imviz = Imviz()
----> 4 imviz.load_data('jbt7a3k7q_flc.fits')
      5 imviz.app

.../jdaviz/core/helpers.py in load_data(self, data, parser_reference, **kwargs)
     35 
     36     def load_data(self, data, parser_reference=None, **kwargs):
---> 37         self.app.load_data(data, parser_reference=parser_reference, **kwargs)

.../jdaviz/app.py in load_data(self, file_obj, parser_reference, **kwargs)
    295             # If the parser returns something other than known, assume it's
    296             #  a message we want to make the user aware of.
--> 297             msg = parser(self, file_obj, **kwargs)
    298 
    299             if msg is not None:

.../jdaviz/configs/imviz/plugins/parsers.py in imviz_data_parser(app, file_obj, data_type, data_label)
     19     if isinstance(file_obj, str) and os.path.exists(file_obj):
     20         file_name = os.path.basename(file_obj)
---> 21         _parse_data(app, file_obj)
     22     else:
     23         msg = f'Cannot load {file_obj}'

.../jdaviz/configs/imviz/plugins/parsers.py in _parse_data(app, file_obj)
     30     for data in data_list:
     31         app.add_data(data, data.label)
---> 32         app.add_data_to_viewer("imviz-image-viewer", data.label)

.../jdaviz/app.py in add_data_to_viewer(self, viewer_reference, data_path, clear_other_data, ext)
    636         if data_id is not None:
    637             data_ids.append(data_id)
--> 638             self._update_selected_data_items(viewer_item['id'], data_ids)
    639         else:
    640             raise ValueError(

.../jdaviz/app.py in _update_selected_data_items(self, viewer_id, selected_items)
    906             [data] = [x for x in self.data_collection if x.label == label]
    907 
--> 908             viewer.add_data(data)
    909 
    910             add_data_message = AddDataMessage(data, viewer,

.../glue_jupyter/view.py in add_data(self, data, color, alpha, **layer_state)
    115         data = validate_data_argument(self._data, data)
    116 
--> 117         result = super().add_data(data)
    118 
    119         if not result:

.../glue/viewers/common/viewer.py in add_data(self, data)
    210             return False
    211 
--> 212         self._layer_artist_container.append(layer)
    213         layer.update()
    214 

.../glue/core/layer_artist.py in append(self, artist)
    269         """Add a LayerArtist to this collection"""
    270         self.artists.append(artist)
--> 271         artist.zorder = max(a.zorder for a in self.artists) + 1
    272         self._notify()
    273 

.../echo/core.py in __set__(self, instance, value)
     74         new = self.__get__(instance)
     75         if old != new:
---> 76             self.notify(instance, old, new)
     77 
     78     def setter(self, func):

.../echo/core.py in notify(self, instance, old, new)
    123             return
    124         for cback in self._callbacks.get(instance, []):
--> 125             cback(new)
    126         for cback in self._2arg_callbacks.get(instance, []):
    127             cback(old, new)

.../echo/core.py in prop2_from_prop1(self, value)
    612         if not self._syncing:
    613             self._syncing = True
--> 614             setattr(self.instance2(), self.prop2, getattr(self.instance1(), self.prop1))
    615             self._syncing = False
    616 

.../echo/core.py in __setattr__(self, attribute, value)
    261         super(HasCallbackProperties, self).__setattr__(attribute, value)
    262         if self.is_callback_property(attribute):
--> 263             self._notify_global(**{attribute: value})
    264 
    265     def add_callback(self, name, callback, echo_old=False, priority=0):

.../glue/utils/matplotlib.py in wrapper(*args, **kwargs)
    168             for backend in DEFER_DRAW_BACKENDS:
    169                 backend.draw_idle = DeferredMethod(backend.draw_idle)
--> 170             result = func(*args, **kwargs)
    171         finally:
    172             for backend in DEFER_DRAW_BACKENDS:

.../glue/viewers/matplotlib/state.py in _notify_global(self, *args, **kwargs)
    291     @defer_draw
    292     def _notify_global(self, *args, **kwargs):
--> 293         super(MatplotlibLayerState, self)._notify_global(*args, **kwargs)

.../echo/core.py in _notify_global(self, **kwargs)
    256         if len(kwargs) > 0:
    257             for callback in self._global_callbacks:
--> 258                 callback(**kwargs)
    259 
    260     def __setattr__(self, attribute, value):

.../echo/containers.py in notify_all(self, *args, **kwargs)
     43     def notify_all(self, *args, **kwargs):
     44         for callback in self.callbacks:
---> 45             callback(*args, **kwargs)
     46 
     47     def __repr__(self):

.../echo/containers.py in __call__(self, *args, **kwargs)
    164 
    165     def __call__(self, *args, **kwargs):
--> 166         self.function(*args, **kwargs)
    167 
    168 

.../echo/containers.py in callback(*args, **kwargs)
    187 
    188         def callback(*args, **kwargs):
--> 189             self.notify(instance, wrapped_list, wrapped_list)
    190 
    191         dcb.function = callback

.../echo/core.py in notify(self, instance, old, new)
    123             return
    124         for cback in self._callbacks.get(instance, []):
--> 125             cback(new)
    126         for cback in self._2arg_callbacks.get(instance, []):
    127             cback(old, new)
.../echo/core.py in _notify_global_listordict(self, *args)
    248                     properties[prop_name] = callback_listordict
    249                     break
--> 250         self._notify_global(**properties)
    251 
    252     def _notify_global(self, **kwargs):

.../glue/utils/matplotlib.py in wrapper(*args, **kwargs)
    163         # method since all should be modified in sync.
    164         if isinstance(DEFER_DRAW_BACKENDS[0].draw_idle, DeferredMethod):
--> 165             return func(*args, **kwargs)
    166 
    167         try:

.../glue/viewers/matplotlib/state.py in _notify_global(self, *args, **kwargs)
    248     @defer_draw
    249     def _notify_global(self, *args, **kwargs):
--> 250         super(MatplotlibDataViewerState, self)._notify_global(*args, **kwargs)
    251 
    252     def _update_priority(self, name):

.../echo/core.py in _notify_global(self, **kwargs)
    256         if len(kwargs) > 0:
    257             for callback in self._global_callbacks:
--> 258                 callback(**kwargs)
    259 
    260     def __setattr__(self, attribute, value):

.../glue_jupyter/bqplot/scatter/layer_artist.py in _update_scatter(self, **changes)
    157     def _update_scatter(self, **changes):
    158         self.update_histogram()
--> 159         self.update()
    160 
    161     def update(self):

.../glue_jupyter/bqplot/scatter/layer_artist.py in update(self)
    172             pass
    173         else:
--> 174             self.scatter.x = (ensure_numerical(self.layer.data[self._viewer_state.x_att])
    175                               .astype(np.float32).ravel())
    176             self.scatter.y = (ensure_numerical(self.layer.data[self._viewer_state.y_att])

.../glue/core/data.py in __getitem__(self, key)
    569                 raise IncompatibleAttribute(_k)
    570 
--> 571         return self.get_data(key, view=view)
    572 
    573     def _ipython_key_completions_(self):

.../glue/core/data.py in get_data(self, cid, view)
   1359             comp = self._externally_derivable_components[cid]
   1360         else:
-> 1361             raise IncompatibleAttribute(cid)
   1362 
   1363         if view is not None:

IncompatibleAttribute: Pixel Axis 1 [x]

@pllim pllim added the imviz label Jan 29, 2021
Base automatically changed from master to main January 29, 2021 19:45
@rosteen
Copy link
Collaborator

rosteen commented Feb 1, 2021

@pllim what was the file that was giving you that error traceback? Running the Imviz concept notebook loads in the data included in the notebook (the astropy Spitzer example) with no problems.

@pllim
Copy link
Contributor Author

pllim commented Feb 1, 2021

jbt7a3k7q_flc.fits is a calibrated file from HST/ACS. You can request it from MAST.

@pllim pllim mentioned this pull request Feb 2, 2021
6 tasks
@pllim
Copy link
Contributor Author

pllim commented Feb 10, 2021

From discussions with @eteq today, it is desirable to implement this API following astrowidgets public API signature as much as possible. The idea is that eventually (if not from the start), Imviz will inherit abstract class from astrowidgets.core.ImageWidget (as a mixin?).

Depends on: astropy/astrowidgets#93

Also see: astropy/astrowidgets#122

p.s. @eteq , please correct me if I misunderstood. cc @astrofrog , @mariobuikhuizen , @maartenbreddels

@pllim
Copy link
Contributor Author

pllim commented Apr 13, 2021

Superseded by #429

@pllim pllim closed this Apr 13, 2021
@pllim pllim deleted the imviz-round-4 branch April 13, 2021 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants