South Polar Stereographic Projection not producing right plot
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- python
- Domain
- data-visualization
Research direction
Start by running plot_field_pole.py with heff.H1987.nc for both the S and N arguments, as described in the issue. Compare the Basemap spstere and npstere paths, focusing on the pcolormesh result. Done means the South Polar Stereographic projection produces a correctly colored plot rather than a solid color.
Written by the indexing model from the issue text.
Description
Hi,
This may be a followup of a previous closed issue (https://github.com/matplotlib/basemap/issues/118).
I am making polar stereographic projection pcolormesh plots of some sea ice data. It works fine with the Northern Hemisphere, but produces solid color for the South.
The problem was replicated on both Linux and Windows with different versions of Python, numpy, matplotlib and basemap. I am using basemap-1.1.0 with matplotlib-1.5.3 in winpython-3.5 on Windows 10 to produced the following figures.
Here is an example script:
from netCDF4 import Dataset
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import array
import matplotlib.cm as cm
from mpl_toolkits.basemap import Basemap
import glob
import struct
import datetime
import time
import sys
from pylab import *
POLE=sys.argv[3]
fname=sys.argv[1]
fld=sys.argv[2]
print(fname)
ncfile = Dataset(fname, 'r', format='NETCDF4')
fbot=ncfile.variables[fld][0]
if 'lon' in ncfile.variables:
LON=ncfile.variables['lon'][:]
if 'lon_scaler' in ncfile.variables:
LON=ncfile.variables['lon_scaler'][:]
if 'LON' in ncfile.variables:
LON=ncfile.variables['LON'][:]
if 'lat' in ncfile.variables:
LAT=ncfile.variables['lat'][:]
if 'lat_scaler' in ncfile.variables:
LAT=ncfile.variables['lat_scaler'][:]
if 'LAT' in ncfile.variables:
LAT=ncfile.variables['LAT'][:]
if 'kmt' in ncfile.variables:
kmt=ncfile.variables['kmt'][:]
lon=LON
lat=LAT
if len(LON.shape) == 1:
lon,lat=np.meshgrid(LON,LAT)
if 'kmt' in ncfile.variables:
fbot=ma.masked_where(kmt<1, fbot)
ncfile.close()
meridians=[1,0,1,1]
fig=figure(figsize=(12,12), facecolor='w')
if POLE=='N':
m = Basemap(projection='npstere',lon_0=0,boundinglat=45)
if POLE=='S':
m = Basemap(projection='spstere',lon_0=180,boundinglat=-45)
m.drawcoastlines()
m.fillcontinents()
m.drawcountries()
plt.title(fld)
x, y =m(lon,lat)
m.pcolormesh(x,y,fbot,vmin=float(sys.argv[4]), vmax=float(sys.argv[5]))
m.drawparallels(np.arange(-90.,120.,15.),labels=[1,0,0,0]) # draw parallels
m.drawmeridians(np.arange(0.,420.,30.),labels=meridians) # draw meridians
plt.colorbar(orientation='vertical',extend='both',shrink=0.8)
plt.show()
A netcdf file to reproduce the problem can be downloaded here
ftp://pscftp.apl.washington.edu/zhang/Global_seaice/heff.H1987.nc.gz
Once untared, the following call to the above script (named plot_field_pole.py)
python plot_field_pole.py heff.H1987.nc heff S 0.0 3.0
will give the wrong plot.

while
python plot_field_pole.py heff.H1987.nc heff N 0.0 3.0
produced correct one.

The only difference between the two commands is Basemap(projection='spstere') or
Basemap(projection='npstere')
Any help will be much appreciated.
Bin Zhao
- Dominant language
- Python
- Stars
- 817
- Forks
- 395
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from matplotlib/basemap
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
matplotlib/basemap#368 ·
-
Python 3.14 wheels Open
Difficulty 4/5 3-5 days Newbie friendliness 48/100
matplotlib/basemap#652 · 2 comments · 5 reactions ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
matplotlib/basemap#649 · 2 reactions ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
matplotlib/basemap#646 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
matplotlib/basemap#645 · 2 comments ·
All issues in matplotlib/basemap
Similar issues
-
documentation help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
simonw/sqlite-utils#872 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100