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

wcsaxes get_transform errors when sliced WCS given #11958

Open
DanRyanIrish opened this issue Jul 19, 2021 · 0 comments
Open

wcsaxes get_transform errors when sliced WCS given #11958

DanRyanIrish opened this issue Jul 19, 2021 · 0 comments

Comments

@DanRyanIrish
Copy link
Contributor

Description

wcsaxes.transforms.get_transform does not recognise sliced WCS objects. When one is entered, a TypeError is returned saying TypeError: output_system should be a WCS instance, string, or a coordinate frame instance

Expected behavior

Actual behavior

Steps to Reproduce

  1. [First Step]
  2. [Second Step]
  3. [and so on...]
# Put your Python code snippet here.
# Let wcs1 and wcs2 be two FITS WCS objects, describing arrays data1 and data2.
# data1/wcs1 is an image, while data2/wcs2 is an image cube.  So slice data2/wcs2 to overplot.
>>> data3 = data2[0]
>>> wcs3 = wcs2[0]

>>> import matplotlib
>>> ax = plt.subplot(projection=wcs1)
>>> ax.imshow(data1)
>>> ax.contour(data3, transform=ax.get_transform(wcs3), colors='red')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_26357/1992842180.py in <module>
      1 ax = plt.subplot(projection=wcs1)
      2 ax.imshow(data1)
----> 3 ax.contour(data3, transform=ax.get_transform(wcs3), colors='red')

~/miniconda3/envs/foxsi2/lib/python3.9/site-packages/astropy/visualization/wcsaxes/core.py in get_transform(self, frame)
    564                 * :class:`~astropy.coordinates.BaseCoordinateFrame` instance.
    565         """
--> 566         return self._get_transform_no_transdata(frame).inverted() + self.transData
    567 
    568     def _get_transform_no_transdata(self, frame):

~/miniconda3/envs/foxsi2/lib/python3.9/site-packages/astropy/visualization/wcsaxes/core.py in _get_transform_no_transdata(self, frame)
    603             else:
    604 
--> 605                 coordinate_transform = CoordinateTransform(self._transform_pixel2world.frame_out, frame)
    606 
    607                 if coordinate_transform.same_frames:

~/miniconda3/envs/foxsi2/lib/python3.9/site-packages/astropy/visualization/wcsaxes/transforms.py in __init__(self, input_system, output_system)
     87             self.output_system = self._output_system_name
     88         else:
---> 89             raise TypeError("output_system should be a WCS instance, string, or a coordinate frame instance")
     90 
     91         if self.output_system == self.input_system:

TypeError: output_system should be a WCS instance, string, or a coordinate frame instance

System Details

Linux-5.8.0-59-generic-x86_64-with-glibc2.31
Python 3.9.6 | packaged by conda-forge | (default, Jul 11 2021, 03:39:48)
[GCC 9.3.0]
Numpy 1.21.1
astropy 4.2.1 (Same issue with 4.3rc1)
Scipy 1.7.0
Matplotlib 3.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants