Skip to content

Instantly share code, notes, and snippets.

@mjharriso
Created October 17, 2016 18:32
Show Gist options
  • Save mjharriso/140a45d9c23665e24d131c65daa6a8ee to your computer and use it in GitHub Desktop.
Save mjharriso/140a45d9c23665e24d131c65daa6a8ee to your computer and use it in GitHub Desktop.
Reanalysis on ortho projection using Basemap and MIDAS
from midas.rectgrid import *
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
tlev=184
grid=quadmesh(path='swdn_merra_2014.nc',var='swdn',cyclic=True)
map=Basemap(projection='ortho',lat_0=-45,lon_0=-100,resolution='l')
x,y=map(grid.x_T,grid.y_T)
S=state('swdn_merra_2014.nc',grid=grid,fields=['swdn'],time_indices=np.arange(tlev,tlev+1))
#S=state('uv10_merra_2014.nc',grid=grid,fields=['u10','v10'],time_indices=np.arange(tlev,tlev+1))
#w=np.sqrt(S.u10**2. + S.v10**2.)
#cs=map.contourf(x,y,sq(w),np.arange(0,20,1),extend='max',cmap=plt.cm.spectral)
cs=map.contourf(x,y,sq(S.swdn),np.arange(0,1250,50),extend='max',cmap=plt.cm.spectral)
map.colorbar(cs)
map.drawcoastlines()
map.drawmeridians(np.arange(-280,80,30))
map.drawparallels(np.arange(-90,0,30))
#tit='Wind Speed '+str(S.var_dict['u10']['dates'][0])
tit='SWdn '+str(S.var_dict['swdn']['dates'][0])
plt.title(tit)
plt.savefig('/home/mjh/sample.png')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment