Cartopy bug?

428 views
Skip to first unread message

Ivan Paspaldzhiev

unread,
Apr 5, 2016, 6:31:25 AM4/5/16
to Iris
Hello,

I'm trying to do something very simple:

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
ax
= plt.axes(projection = ccrs.Geodetic())

Yet:

TypeError                                 Traceback (most recent call last)
<ipython-input-4-465130cc1897> in <module>()
----> 1 ax = plt.axes(projection = ccrs.Geodetic())


C
:\Users\Ivan\Anaconda2\lib\site-packages\matplotlib\pyplot.pyc in axes(*args, **kwargs)
   
865     nargs = len(args)
   
866     if len(args) == 0:
--> 867         return subplot(111, **kwargs)
   
868     if nargs > 1:
   
869         raise TypeError('Only one non keyword arg to axes allowed')


C
:\Users\Ivan\Anaconda2\lib\site-packages\matplotlib\pyplot.pyc in subplot(*args, **kwargs)
   
1020
   
1021     fig = gcf()
-> 1022     a = fig.add_subplot(*args, **kwargs)
   
1023     bbox = a.bbox
   
1024     byebye = []


C
:\Users\Ivan\Anaconda2\lib\site-packages\matplotlib\figure.pyc in add_subplot(self, *args, **kwargs)
   
985         else:
   
986             projection_class, kwargs, key = process_projection_requirements(
--> 987                 self, *args, **kwargs)
   
988
   
989             # try to find the axes with this key in the stack


C
:\Users\Ivan\Anaconda2\lib\site-packages\matplotlib\projections\__init__.pyc in process_projection_requirements(figure, *args, **kwargs)
   
102     else:
   
103         raise TypeError('projection must be a string, None or implement a '
--> 104                             '_as_mpl_axes method. Got %r' % projection)
   
105
   
106     # Make the key without projection kwargs, this is used as a unique


TypeError: projection must be a string, None or implement a _as_mpl_axes method. Got <cartopy._crs.Geodetic object at 0x000000000625D410>

The same type of error happens for projections Geocentric, Globe and LinearRing, from the ones I tried, if that is of any help? Most others (PlateCarree, Mercator, Robinson etc.) work fine. However, I specifically need Geodetic.

What I'm trying to do is I have data that is on a rotated pole grid (EURO-CORDEX data) and I want to subset a region defined by regular lat-lon coordinates. I used this question to convert my regular lat-lon bounding box edges to my data's coordinate system and what I want to now do is mask out the data in the bounding box and plot the result, so I can see if the location I've subset is the one I actually want. 

I can't see what I'm doing wrong here?

Cheers

Ivan

Ivan Paspaldzhiev

unread,
Apr 5, 2016, 6:42:12 AM4/5/16
to Iris
Forgot to add, Cartopy 0.13.1, IPython 4.0.3.

pp-mo

unread,
Apr 11, 2016, 11:28:27 AM4/11/16
to Iris
Geodetic and Geocentric etc are coordinate reference systems (CRS), they are not projections.
That is, they don't relate geographical locations to positions on a flat 2d plane.

The classes that work with matlplotlib are the various subclasses of "cartopy.crs.Projection".
These also inherit from CRS, but add extra functions.

For a plot whose coordinates are linear latitude and longitude values you want PlateCarree (aka Equidistant Cylindrical) .

pp-mo

unread,
Apr 11, 2016, 11:30:29 AM4/11/16
to scitoo...@googlegroups.com
I just realised it is stated here :

http://scitools.org.uk/cartopy/docs/latest/crs/index.html

Towards the bottom:
There are a few non-Projection subclasses. [[of CRS]]
These represent coordinate reference systems which are 3 dimensional and could not be drawn directly on a piece of paper.
 . . .

 

Reply all
Reply to author
Forward
0 new messages