|
From: Phil E. <pel...@gm...> - 2013-03-02 09:37:27
|
Perhaps something like: from matplotlib import pyplot as plt from netCDF4 import Dataset import numpy as np url=*' http://www.marine.csiro.au/dods/nph-dods/dods-data/climatology-netcdf/levitus_monthly_temp_98.nc '* ds = Dataset(url) temp = ds.variables[*'TEMP'*] lats = ds.variables[*'**lat**'*] lons = ds.variables[*'**lon**'*] depths = ds.variables[*'z'*] # filter all but one latitude lat_index = np.where(lats[:] == 0.5)[0][0] lats = lats[lat_index] # filter a range of longitudes lon_lower_index = np.where(lons[:] == 44.5)[0][0] lon_upper_index = np.where(lons[:] == 100.5)[0][0] lons = lons[lon_lower_index:lon_upper_index] temp = temp[0, :, lat_index, lon_lower_index:lon_upper_index] plt.pcolormesh(lons, depths[:], temp) plt.gca().invert_yaxis() plt.show() The indexing approach used here is quite flakey, so I certainly wouldn't use this in anything operational. Hope this helps, Phil |