Recipe: python program example2: Difference between revisions

From GEOS-5
Jump to navigation Jump to search
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..."
 
No edit summary
 
Line 11: Line 11:


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


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


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


plt.show()
plt.show()
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 05:38, 29 March 2017

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=0,urcrnrlon=360,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,lats,data,tri=True)

plt.show()