Problem with contour(x,y,z)

Hi all,
I need to use contour with data for x,y and z coordinates. My data is
contained in 3 numarray arrays called xi,z and rho.

I can call contour with either of these 3 arrays without any problem. But when
it comes to pass the 3 arrays, here's the error I get:

In [19]:contour(xi,z,rho)

···

---------------------------------------------------------------------------
exceptions.TypeError Traceback (most recent
call last)

/home/ngirard/.python/<console>

/usr/lib/python2.4/site-packages/matplotlib/pylab.py in contour(*args,
**kwargs)
   1784 hold(h)
   1785 try:
-> 1786 ret = gca().contour(*args, **kwargs)
   1787 draw_if_interactive()
   1788 except:

/usr/lib/python2.4/site-packages/matplotlib/axes.py in contour(self, *args,
**kwargs)
   1251
   1252 def contour(self, *args, **kwargs):
-> 1253 return self._contourHelper.contour(*args, **kwargs)
   1254 contour.__doc__ = ContourSupport.contour.__doc__
   1255

/usr/lib/python2.4/site-packages/matplotlib/contour.py in contour(self, *args,
**kwargs)
    675 tlinewidths = [(w,) for w in linewidths]
    676
--> 677 C = _contour.Cntr(x, y, z.filled(), z.mask())
    678 for level, color, width in zip(lev, tcolors, tlinewidths):
    679 nlist = C.trace(level, points = 1)

TypeError: Arguments x, y, z, (optional) mask must be arrays.

I really don't understand where the problem is. All arrays are of the same
nature:

In [20]:for a in [xi,z,rho]:
   .20.: shape(a)
   .20.: type(a)
   .20.:
Out[20]:(1025, 1024)
Out[20]:<class 'numarray.numarraycore.NumArray'>
Out[20]:(1025, 1024)
Out[20]:<class 'numarray.numarraycore.NumArray'>
Out[20]:(1025, 1024)
Out[20]:<class 'numarray.numarraycore.NumArray'>

Do you have any idea to help me solve this problem ?

Thanks in advance,
cheers,
Nicolas

Nicolas Girard wrote:

Hi all,
I need to use contour with data for x,y and z coordinates. My data is contained in 3 numarray arrays called xi,z and rho.

I can call contour with either of these 3 arrays without any problem. But when it comes to pass the 3 arrays, here's the error I get:

In [19]:contour(xi,z,rho)
---------------------------------------------------------------------------
exceptions.TypeError Traceback (most recent call last)

/home/ngirard/.python/<console>

/usr/lib/python2.4/site-packages/matplotlib/pylab.py in contour(*args, **kwargs)
  1784 hold(h)
  1785 try:
-> 1786 ret = gca().contour(*args, **kwargs)
  1787 draw_if_interactive()
  1788 except:

/usr/lib/python2.4/site-packages/matplotlib/axes.py in contour(self, *args, **kwargs)
  1251
  1252 def contour(self, *args, **kwargs):
-> 1253 return self._contourHelper.contour(*args, **kwargs)
  1254 contour.__doc__ = ContourSupport.contour.__doc__
  1255

/usr/lib/python2.4/site-packages/matplotlib/contour.py in contour(self, *args, **kwargs)
   675 tlinewidths = [(w,) for w in linewidths]
   676
--> 677 C = _contour.Cntr(x, y, z.filled(), z.mask())
   678 for level, color, width in zip(lev, tcolors, tlinewidths):
   679 nlist = C.trace(level, points = 1)

TypeError: Arguments x, y, z, (optional) mask must be arrays.

I really don't understand where the problem is. All arrays are of the same nature:

In [20]:for a in [xi,z,rho]:
  .20.: shape(a)
  .20.: type(a)
  .20.:
Out[20]:(1025, 1024)
Out[20]:<class 'numarray.numarraycore.NumArray'>
Out[20]:(1025, 1024)
Out[20]:<class 'numarray.numarraycore.NumArray'>
Out[20]:(1025, 1024)
Out[20]:<class 'numarray.numarraycore.NumArray'>

Do you have any idea to help me solve this problem ?

Thanks in advance,
cheers,
Nicolas

Nicolas: Sounds like you need to set numerix='numarray'. Try this at the beginning of your script:

from matplotlib import rcParams
rcParams['numerix']= 'numarray'

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/CDC R/CDC1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

Jeff : a huge thanks for your damn fast answer ! I was so desperate that I had
fired up IDL, which I hadn't done for months ! I'm so glad to be able to
stick with matplotlib !

cheers,
Nicolas

···

On Thursday 08 September 2005 23:55, Jeff Whitaker wrote:

Nicolas: Sounds like you need to set numerix='numarray'. Try this at
the beginning of your script:

from matplotlib import rcParams
rcParams['numerix']= 'numarray'

-Jeff