-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix for Basemap.pcolormesh 'ortho' projection #476
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3426,6 +3426,27 @@ def pcolormesh(self,x,y,data,**kwargs): | |
if the dimensions are the same, then the last row and column of data will be ignored. | ||
""" | ||
ax, plt = self._ax_plt_from_kw(kwargs) | ||
# fix for invalid grid points | ||
if ((np.any(x > 1e20) or np.any (y > 1e20)) and | ||
len(x.shape) == 2 and len(y.shape) == 2): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of |
||
if not x.shape == y.shape: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or clearer would be |
||
raise Exception('pcolormesh: x and y need same dimension') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a |
||
nx,ny = x.shape | ||
if nx < data.shape[0] or ny < data.shape[1]: | ||
raise Exception('pcolormesh: data dimension needs to be at least that of x and y.') | ||
mask = ( | ||
(x[:-1,:-1] > 1e20) | | ||
(x[1:,:-1] > 1e20) | | ||
(x[:-1,1:] > 1e20) | | ||
(x[1:,1:] > 1e20) | | ||
(y[:-1,:-1] > 1e20) | | ||
(y[1:,:-1] > 1e20) | | ||
(y[:-1,1:] > 1e20) | | ||
(y[1:,1:] > 1e20) | ||
) | ||
# we do not want to overwrite original array | ||
data = data[:nx-1,:ny-1].copy() | ||
data[mask] = np.nan | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to do some testing with this. I am pretty sure some numpy rules changed recently regarding boolean indexing using masks that don't exactly match the shape of the array being indexed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is why I make a copy of slice of data with the correct dimensions: |
||
self._save_use_hold(ax, kwargs) | ||
try: | ||
ret = ax.pcolormesh(x,y,data,**kwargs) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extraneous space