Last active
August 29, 2015 14:00
-
-
Save adcroft/11063641 to your computer and use it in GitHub Desktop.
Demo of SSH using a basemap projection and "blue marble" image for land
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import netCDF4 | |
| import matplotlib.pyplot as plt | |
| import numpy | |
| from mpl_toolkits.basemap import Basemap | |
| lon = netCDF4.Dataset('/archive/gold/datasets/MOM6z_SIS_025/siena/mosaic.unpacked/ocean_hgrid.nc').variables['x'][::2,::2] | |
| lat = netCDF4.Dataset('/archive/gold/datasets/MOM6z_SIS_025/siena/mosaic.unpacked/ocean_hgrid.nc').variables['y'][::2,::2] | |
| ssh = netCDF4.Dataset('/archive/aja/awg/tikal_201403/MOM6z_SIS_025_c192L48_am4a1_2000climo_bergs/gfdl.ncrc2-intel-prod-openmp/history/unpack/00040301.ocean_daily.nc').variables['ssh'][1] | |
| m = Basemap(projection='kav7',lon_0=-120,resolution=None) | |
| m.drawmapboundary(fill_color='0.3') | |
| im0 = m.bluemarble(scale=0.5) | |
| im1 = m.pcolormesh(numpy.minimum(lon,60.),lat,ssh,shading='flat',cmap=plt.cm.spectral,latlon=True) | |
| plt.clim(-2,1) | |
| m.drawparallels(numpy.arange(-90.,99.,30.)) | |
| m.drawmeridians(numpy.arange(-180.,180.,60.)) | |
| cb = m.colorbar(im1,"bottom", size="5%", pad="2%") | |
| plt.title('Sea surface height [m]') | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment