In [6]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as mcm
import matplotlib.colors as mcolors
from mpl_toolkits.basemap import Basemap

In [7]:
ascfile = open('file.asc').read()
im = np.ones((1024,1024))*np.nan
for i, line in enumerate(ascfile.split("\n")[:-1]):
             im[i] = np.array(list(line)).astype(int)
np.unique(im)
lats = np.fromfile('imslat_24km.dat', dtype=np.dtype('f4'))
lons = np.fromfile('imslon_24km.dat', dtype=np.dtype('f4'))
lats.shape = (1024,1024)
lons.shape = (1024,1024)

In [8]:
print lats[-12,512]


0.109788

In [10]:
#1 sea, 2 land,3 sea ice, 4 snow, 0 out of bounds
bounds = np.unique(im)
cmap = mcolors.ListedColormap(['red', 'blue', 'green', 'yellow', 'white'])
norm = mcolors.BoundaryNorm(bounds, cmap.N)
fig = plt.figure(figsize=(10,10))
ax = fig.add_subplot(1,1,1)

m = Basemap(projection='npstere', boundinglat=0, lon_0=lons[512, 512], ax=ax)
ims = m.imshow(im, cmap=cmap, norm=norm)

m.drawcountries()
m.drawcoastlines()
fig.colorbar(ims)


Out[10]:
<matplotlib.colorbar.Colorbar at 0x106accd50>

In [ ]: