Howdy,

I’m a recent refugee from GMT (Generic Mapping Tools) and am very happy to have found matplotlib.

I’ve been having one nagging issue however that I must resolve as I require this ability. Basically, I need to mask 2d arrays and plot the result with pcolor via basemap.

From the documentation it seems this should be fairly straight forward and I’m hoping that this is the case.

Here is an example of problem.

## ···

from pylab import *

import matplotlib.numerix.ma as ma # matplotlibrc has numerix : numpy

from matplotlib.toolkits.basemap import Basemap, shiftgrid, addcyclic

import numpy as N

.

.

.

im = 144

jm = 93

lons = N.array([0., … 357.5],dtype=float)

lats = N.array([-90., … 90.],dtype=float)

topo_screen = N.zeros((jm,im),dtype=‘float’)

topo_screen[10] = 1

new_test = 100.*

N.ones((jm,im),dtype=‘float’)

masked_test = ma.masked_where(topo_screen,new)

This works and a screen dump of masked_test seem correct.

A call to pcolor however results in the following:

matplotlib version 0.90.1

verbose.level helpful

interactive is False

units is True

platform is linux2

numerix numpy 1.0.1

.

.

.

/usr/local/lib/python2.5/site-packages/numpy/core/ma.py:604: UserWarning: Cannot automatically convert masked array to numeric because data is masked in one or more locations.

Is this an embarrassingly simple error on my part? I hope so. Any help would be much appreciated.

Mike

Mike,

pcolor has had masked array support for a long time. Please send a minimal but complete example of a script that fails; based on what you sent below, I can't tell what the problem is.

Eric

Mike Bauer wrote:

## ···

Howdy,

I'm a recent refugee from GMT (Generic Mapping Tools) and am very happy to have found matplotlib.

I've been having one nagging issue however that I must resolve as I require this ability. Basically, I need to mask 2d arrays and plot the result with pcolor via basemap.

From the documentation it seems this should be fairly straight forward and I'm hoping that this is the case.

Here is an example of problem.

-------------------------------------------

from pylab import *

import matplotlib.numerix.ma <http://matplotlib.numerix.ma> as ma # matplotlibrc has numerix : numpy

from matplotlib.toolkits.basemap import Basemap, shiftgrid, addcyclic

import numpy as N

.

im = 144

jm = 93

lons = N.array([0., ... 357.5],dtype=float)

lats = N.array([-90., ... 90.],dtype=float)

topo_screen = N.zeros((jm,im),dtype='float')

topo_screen[10] = 1

new_test = 100.* N.ones((jm,im),dtype='float')

masked_test = ma.masked_where(topo_screen,new)

This works and a screen dump of masked_test seem correct.

A call to pcolor however results in the following:

matplotlib version 0.90.1

verbose.level helpful

interactive is False

units is True

platform is linux2

numerix numpy 1.0.1

.

/usr/local/lib/python2.5/site-packages/numpy/core/ma.py:604: UserWarning: Cannot automatically convert masked array to numeric because data is masked in one or more locations.

-------------------------------------------

Is this an embarrassingly simple error on my part? I hope so. Any help would be much appreciated.

Mike

------------------------------------------------------------------------

-------------------------------------------------------------------------

This SF.net email is sponsored by: Microsoft

Defy all challenges. Microsoft(R) Visual Studio 2005.

http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

------------------------------------------------------------------------

_______________________________________________

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users