You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromastropy.ioimportfitsfromastropy.wcsimportWCSimportmatplotlib.pyplotaspltimportnumpyasnpheader="""WCSAXES = 3 / Number of coordinate axesCRPIX1 = 1.0 / Pixel coordinate of reference pointCRPIX2 = 386.5 / Pixel coordinate of reference pointCRPIX3 = 32.0 / Pixel coordinate of reference pointPC2_2 = 0.999988496304 / Coordinate transformation matrix elementPC2_3 = -0.13517896595 / Coordinate transformation matrix elementPC3_2 = 0.000939457726278 / Coordinate transformation matrix elementPC3_3 = 0.999988496304 / Coordinate transformation matrix elementCDELT1 = 1.29800001159E-12 / [m] Coordinate increment at reference pointCDELT2 = 4.6208333333333E-05 / [deg] Coordinate increment at reference pointCDELT3 = 0.00055428900205556 / [deg] Coordinate increment at reference pointCUNIT1 = 'm' / Units of coordinate increment and valueCUNIT2 = 'deg' / Units of coordinate increment and valueCUNIT3 = 'deg' / Units of coordinate increment and valueCTYPE1 = 'WAVE' / Vacuum wavelength (linear)CTYPE2 = 'HPLT-TAN' / Coordinate type codegnomonic projectionCTYPE3 = 'HPLN-TAN' / Coordinate type codegnomonic projectionCRVAL1 = 1.33168328015E-07 / [m] Coordinate value at reference pointCRVAL2 = -0.029883055555556 / [deg] Coordinate value at reference pointCRVAL3 = 0.22718416666667 / [deg] Coordinate value at reference pointLONPOLE = 180.0 / [deg] Native longitude of celestial poleLATPOLE = -0.029883055555556 / [deg] Native latitude of celestial pole"""wcs=WCS(header=header)
data=np.random.random((64, 772, 2055))
ax=plt.subplot(projection=wcs, slices=('x', 0, 'y'))
ax.imshow(data[:,0,:])
ax.coords[0].grid()
plt.show()
results in this error:
Traceback (most recent call last):
File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.7/site-packages/matplotlib/backends/backend_qt5.py", line 505, in _draw_idle
self.draw()
File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.7/site-packages/matplotlib/backends/backend_agg.py", line 388, in draw
self.figure.draw(self.renderer)
File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.7/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.7/site-packages/matplotlib/figure.py", line 1709, in draw
renderer, self, artists, self.suppressComposite)
File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.7/site-packages/matplotlib/image.py", line 135, in _draw_list_compositing_images
a.draw(renderer)
File "/home/stuart/Git/astropy/astropy/visualization/wcsaxes/core.py", line 454, in draw
super().draw(renderer, inframe=inframe)
File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.7/site-packages/matplotlib/artist.py", line 38, in draw_wrapper
return draw(artist, renderer, *args, **kwargs)
File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 2647, in draw
mimage._draw_list_compositing_images(renderer, self, artists)
File "/home/stuart/.virtualenvs/sunpy-dev/lib/python3.7/site-packages/matplotlib/image.py", line 135, in _draw_list_compositing_images
a.draw(renderer)
File "/home/stuart/Git/astropy/astropy/visualization/wcsaxes/core.py", line 43, in draw
self.axes.draw_wcsaxes(renderer)
File "/home/stuart/Git/astropy/astropy/visualization/wcsaxes/core.py", line 411, in draw_wcsaxes
coord._draw_grid(renderer)
File "/home/stuart/Git/astropy/astropy/visualization/wcsaxes/coordinate_helpers.py", line 533, in _draw_grid
self._update_grid_lines()
File "/home/stuart/Git/astropy/astropy/visualization/wcsaxes/coordinate_helpers.py", line 868, in _update_grid_lines
pixel = self.transform.inverted().transform(xy_world)
File "/home/stuart/Git/astropy/astropy/visualization/wcsaxes/wcsapi.py", line 231, in transform
raise ValueError(f"Expected {self.wcs.world_n_dim} world coordinates, got {len(world)} ")
ValueError: Expected 3 world coordinates, got 2
I think the coordinate isn't separable? Printing the transformation gives the below, with correlations between pixel dim 0 and world dims {1, 2}.
SlicedLowLevelWCS Transformation
This transformation has 2 pixel and 3 world dimensions
Array shape (Numpy order): None
Pixel Dim Axis Name Data size Bounds
0 None None None
1 None None None
World Dim Axis Name Physical Type Units
0 None em.wl m
1 None custom:pos.helioprojective.lat deg
2 None custom:pos.helioprojective.lon deg
Correlation between pixel and world axes:
Pixel Dim
World Dim 0 1
0 yes no
1 no yes
2 no yes
Running the following code:
results in this error:
without the grid call it's fine.
cc @astrofrog
The text was updated successfully, but these errors were encountered: