Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cdo sellonlatbox,-180,180,-90,90 input.nc output.nc
- from matplotlib import pyplot as plt
- import numpy as np
- from mpl_toolkits import basemap
- fig,axes = plt.subplots(nrows=3, ncols=1)
- mp1 = basemap.Basemap(ax = axes[0], projection = 'cyl', lon_0=180, lat_0=0)
- mp2 = basemap.Basemap(ax = axes[1], projection = 'cyl', lon_0=0, lat_0=0)
- mp3 = basemap.Basemap(ax = axes[2], projection = 'cyl', lon_0=0, lat_0=0)
- for mp in mp1, mp2, mp3:
- mp.drawcoastlines()
- mp.drawcountries()
- mp.drawmeridians(np.arange(0,360,30))
- mp.drawparallels(np.arange(-90,90,30))
- ##some data:
- lons = np.arange(0,360)
- lats = np.arange(-90,91)
- lons,lats = np.meshgrid(lons,lats)
- data = np.sin(2*np.pi*lons/360)+np.sin(np.pi*lats/180)
- ##first plot
- mp1.pcolormesh(lons,lats,data)
- ##second plot
- mp2.pcolormesh(lons,lats,data)
- ##third plot (with longitudes re-ordered)
- lons = lons%180-180*(lons//180) ##re-computing lons to be from -180 to 180
- lon_order = np.argsort(lons, axis = 1) ##computing new order of lons
- lat_order = np.argsort(lats, axis = 0) ## ... and lats (maybe unnecessary)
- mp3.pcolormesh(lons[lat_order,lon_order],lats, data[lat_order,lon_order])
- plt.show()
Add Comment
Please, Sign In to add comment