Guest User

Untitled

a guest
Jan 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. cdo sellonlatbox,-180,180,-90,90 input.nc output.nc
  2.  
  3. from matplotlib import pyplot as plt
  4. import numpy as np
  5. from mpl_toolkits import basemap
  6.  
  7. fig,axes = plt.subplots(nrows=3, ncols=1)
  8.  
  9. mp1 = basemap.Basemap(ax = axes[0], projection = 'cyl', lon_0=180, lat_0=0)
  10. mp2 = basemap.Basemap(ax = axes[1], projection = 'cyl', lon_0=0, lat_0=0)
  11. mp3 = basemap.Basemap(ax = axes[2], projection = 'cyl', lon_0=0, lat_0=0)
  12.  
  13. for mp in mp1, mp2, mp3:
  14. mp.drawcoastlines()
  15. mp.drawcountries()
  16. mp.drawmeridians(np.arange(0,360,30))
  17. mp.drawparallels(np.arange(-90,90,30))
  18.  
  19.  
  20. ##some data:
  21. lons = np.arange(0,360)
  22. lats = np.arange(-90,91)
  23. lons,lats = np.meshgrid(lons,lats)
  24. data = np.sin(2*np.pi*lons/360)+np.sin(np.pi*lats/180)
  25.  
  26. ##first plot
  27. mp1.pcolormesh(lons,lats,data)
  28.  
  29. ##second plot
  30. mp2.pcolormesh(lons,lats,data)
  31.  
  32. ##third plot (with longitudes re-ordered)
  33. lons = lons%180-180*(lons//180) ##re-computing lons to be from -180 to 180
  34.  
  35. lon_order = np.argsort(lons, axis = 1) ##computing new order of lons
  36. lat_order = np.argsort(lats, axis = 0) ## ... and lats (maybe unnecessary)
  37.  
  38. mp3.pcolormesh(lons[lat_order,lon_order],lats, data[lat_order,lon_order])
  39.  
  40. plt.show()
Add Comment
Please, Sign In to add comment