Recipe: python program example2

Revision as of 11:34, 6 March 2017 by Weiyuan.jiang (talk | contribs) (Created page with "<syntaxhighlight lang="python"> from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import CSnative # llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon # are the...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import CSnative


# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
# resolution = 'c' means use crude resolution coastlines.

m = Basemap(projection='cyl',llcrnrlat=-90,urcrnrlat=90,\
            llcrnrlon=-180,urcrnrlon=180,resolution='c')
m.drawcoastlines()


# The subscript starts with 0 in python
# Users should specify the time, level, fieldname (var), and filename
Time = 0
Level = 0
var = 'T'
filename='HU_getc180forweyium_c180.geosgcm_prog.20000414_2200z.nc4'

lons, lats, data = CSnative.get_csdata(filename, var, Time, Level);

m.pcolor(lons-180,lats,data,tri=True)

plt.show()