Advertisement
Guest User

Untitled

a guest
Aug 20th, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. precipfile = "/Users/bolvin/oc.197901.sg"
  2. num_lon = 144
  3. num_lat = 72
  4.  
  5. fileobj = open(precipfile, mode='rb')
  6.  
  7. data = np.fromfile (fileobj, dtype ='f')
  8.  
  9. data.byteswap(True)
  10.  
  11. datat = np.reshape(data, (num_lon, num_lat), order = 'FORTRAN')
  12.  
  13. datamasked = np.ma.masked_where(datat < 0.0, datat)
  14.  
  15. my_cmap = matplotlib.colors.LinearSegmentedColormap('my_colormap',uneven_rgb)
  16.  
  17. my_cmap.set_bad('k', 0.8)
  18.  
  19. plt.figure(figsize = (20,10))
  20.  
  21. mapproj = Basemap(projection = 'cyl', llcrnrlat=-90.0, llcrnrlon=0.0, urcrnrlat=90.0, urcrnrlon=360.0)
  22.  
  23. mapproj.drawcoastlines()
  24. mapproj.drawcountries()
  25. mapproj.drawparallels(np.array([-90.0,-60.0,-30.0, 0.0, 30.0, 60.0, 90.0]), labels=[0,0,0,0])
  26. mapproj.drawmeridians(np.array([0.0, 90.0, 180.0, 270.0, 360.0]), labels=[0,0,0,0])
  27.  
  28.  
  29. myplot = plt.imshow(datamasked.T, interpolation = 'nearest', cmap = my_cmap,
  30. norm = matplotlib.colors.Normalize(vmin = 0.0, vmax = 20.0, clip = False),
  31. extent = (0.0, 360.0, -90.0, 90.0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement