grid - Convert netcdf "land" variable to latitude and longitude with Python -
i have global meteorological dataset , want access data grid (lat,lon). however, data compressed, i.e. parameters of interest not have dimensions (lat, lon), "land". "land" 1d array of integers.
i imported file in python using
import scipy.io.netcdf netcdf
path = '/path/.../ncfile.nc'
ncfile = netcdf.netcdf_file(path,'r')
then checked variables there , found that, e.g. "rainf" variable has dimensions (tstep, land). researched on internet , found file landmask_gswp.nc (http://dods.ipsl.jussieu.fr/gswp/fixed/landmask_gswp.nc), supposed contain information need, is, how extract information (lat, lon) "land". file contains variables nav_lat, nav_lon , landmask. nav_lat , nav_lon relate, understanding, coordinate variables x , y latitude , longitude. "landmask" 2d array , contains information ocean = 0 or land = 1. indeed, number of landpoints agrees length of "land" 1d array. however, cannot figure out how extract (lat, lon) information it. appreciated.
i hope made problem understandable; not experienced programming and/or using netcdf, hope can out! in advance!
you can extract variables ncfile using
lat = ncfile.variables['nav_lat'][:,:] lon = ncfile.variables['nav_lon'][:,:] this create 2d numpy arrays lat , lon.
Comments
Post a Comment