On Thu, 2014-06-26 at 23:14 -0700, billyi wrote: > Oh my, it WAS the meshgrid! Thank you so much! > When reading the coordinates like: > lat = FB.variables['lat'][:,:] > lon = FB.variables['lon'][:,:] > > And plotting (without meshgrid!): > m.pcolormesh(lon, lat, masked_fb, latlon=True) > > it works! Now I feel stupid. > And I think the longitudes and latitudes are not monotonic, but I don't know > the way to check this, other than checking the array like lon[:] in > terminal. Is there a better way?
Yes. Consider: py> all(lon[:-1] <= lon[1:]) If True, then lon is monotonically increasing. Otherwise it's not. Description: lon[:-1] is a slice that takes every element of lon except the last one. lon[1:] is a slice that takes every element of lon except the first one. The comparison operator will create a bool numpy array whose elements will be True for each element "i" if the i'th element is less than or equal to the i+1'th element. Applying the "all" (or numpy.all) functions to this bool array will return True if every element is true and False otherwise. Faster, easier, and less error-prone than printing out the array and checking it yourself. Of course you could do something more explicit: py> monotonic = True py> for i in range(len(lon)-1): py> if lon[i] > lon[i+1]: py> monotonic = False py> break HTH, Jason ------------------------------------------------------------------------------ Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users