Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

cannot open more than one figure with wcs #152

Merged
merged 1 commit into from
Jun 4, 2015
Merged

cannot open more than one figure with wcs #152

merged 1 commit into from
Jun 4, 2015

Conversation

astrofrog
Copy link
Owner

Every time I try to open a second figure, I get this:

IPython 2.2.0 -- An enhanced Interactive Python.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
?         -> Introduction and overview of IPython's features.       
%quickref -> Quick reference.                                       
help      -> Python's own help system.                              
object?   -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: Qt4Agg                                      

In [1]: from wcsaxes import datasets, WCS

In [2]: 

In [2]: hdu = datasets.fetch_msx_hdu()
WARNING: VerifyWarning: Invalid 'BLANK' keyword in header.  The 'BLANK' keyword is only applicable to integer data, and will be ignored in this HDU. [astropy.io.fits.hdu.image]                          

In [3]: wcs = WCS(hdu.header)

In [4]: import matplotlib.pyplot as plt

In [5]: fig = plt.figure()

In [6]: ax = fig.add_axes([0.15, 0.1, 0.8, 0.8], projection=wcs)

In [7]: fig2 = plt.figure()

In [8]: ax2 = fig2.add_axes([0.15, 0.1, 0.8, 0.8], projection=wcs)

In [9]: Traceback (most recent call last):
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 282, in mouseMoveEvent                                                                    
    FigureCanvasBase.motion_notify_event(self, x, y)                                                 
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 1917, in motion_notify_event                                                                     
    self.callbacks.process(s, event)                                                                 
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py", line 533, in process                                                                                          
    proxy(*args, **kwargs)                                                                           
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py", line 408, in __call__                                                                                         
    return mtd(*args, **kwargs)                                                                      
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2761, in mouse_move                                                                              
    s = event.inaxes.format_coord(event.xdata, event.ydata)                                          
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/wcsaxes-0.4.dev506-py2.7.egg/wcsaxes/core.py", line 61, in _display_world_coords                                                    
    xw = coords[self._x_index].format_coord(world[self._x_index])                                    
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/wcsaxes-0.4.dev506-py2.7.egg/wcsaxes/coordinate_helpers.py", line 183, in format_coord                                              
    spacing = self._fl_spacing                                                                       
AttributeError: 'CoordinateHelper' object has no attribute '_fl_spacing'                             

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues              
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.                                                   

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True                              

Traceback (most recent call last):
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 282, in mouseMoveEvent                                                                    
    FigureCanvasBase.motion_notify_event(self, x, y)                                                 
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 1917, in motion_notify_event                                                                     
    self.callbacks.process(s, event)                                                                 
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py", line 533, in process                                                                                          
    proxy(*args, **kwargs)                                                                           
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/cbook.py", line 408, in __call__                                                                                         
    return mtd(*args, **kwargs)                                                                      
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2761, in mouse_move                                                                              
    s = event.inaxes.format_coord(event.xdata, event.ydata)                                          
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/wcsaxes-0.4.dev506-py2.7.egg/wcsaxes/core.py", line 61, in _display_world_coords                                                    
    xw = coords[self._x_index].format_coord(world[self._x_index])                                    
  File "/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/wcsaxes-0.4.dev506-py2.7.egg/wcsaxes/coordinate_helpers.py", line 183, in format_coord                                              
    spacing = self._fl_spacing                                                                       
AttributeError: 'CoordinateHelper' object has no attribute '_fl_spacing'                             

If you suspect this is an IPython bug, please report it at:
    https://github.com/ipython/ipython/issues              
or send an email to the mailing list at ipython-dev@scipy.org

You can print a more detailed traceback right now with "%tb", or use "%debug"
to interactively debug it.

Extra-detailed tracebacks for bug-reporting purposes can be enabled via:
    %config Application.verbose_crash=True

%tb
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in motion_notify_event(self, x, y, guiEvent)
   1915         event = MouseEvent(s, self, x, y, self._button, self._key,
   1916                            guiEvent=guiEvent)
-> 1917         self.callbacks.process(s, event)
   1918
   1919     def leave_notify_event(self, guiEvent=None):

/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/cbook.pyc in process(self, s, *args, **kwargs)
    531                     del self.callbacks[s][cid]
    532                 else:
--> 533                     proxy(*args, **kwargs)
    534
    535

/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/cbook.pyc in __call__(self, *args, **kwargs)
    406             mtd = self.func
    407         # invoke the callable and return the result
--> 408         return mtd(*args, **kwargs)
    409
    410     def __eq__(self, other):

/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in mouse_move(self, event)
   2759
   2760             try:
-> 2761                 s = event.inaxes.format_coord(event.xdata, event.ydata)
   2762             except (ValueError, OverflowError):
   2763                 pass

/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/wcsaxes-0.4.dev506-py2.7.egg/wcsaxes/core.pyc in _display_world_coords(self, x, y)
     59         world = coords._transform.transform(np.array([pixel]))[0]
     60
---> 61         xw = coords[self._x_index].format_coord(world[self._x_index])
     62         yw = coords[self._y_index].format_coord(world[self._y_index])
     63

/melkor/d1/guenther/soft/anaconda/lib/python2.7/site-packages/wcsaxes-0.4.dev506-py2.7.egg/wcsaxes/coordinate_helpers.pyc in format_coord(self, value)
    181             value = value * u.degree
    182             value = value.to(fl._unit).value
--> 183         spacing = self._fl_spacing
    184         string = fl.formatter(values=[value] * fl._unit, spacing=spacing)
    185         return string[0]

AttributeError: 'CoordinateHelper' object has no attribute '_fl_spacing'

@astrofrog
Copy link
Owner

Huh, weird! Will investigate :)

@astrofrog
Copy link
Owner

Ok this is a bug that occurs because with the Qt backend, it calls format_coord before the axes have been drawn the first time (to show the 'hover-over coords'). Working on a solution.

astrofrog added a commit that referenced this pull request Jun 4, 2015
cannot open more than one figure with wcs
@astrofrog astrofrog merged commit f3627c1 into master Jun 4, 2015
astrofrog added a commit that referenced this pull request Nov 28, 2016
cannot open more than one figure with wcs
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant