njtbx-icon
Netcdf-Java Toolbox
previous Function nj_attget
Function nj_info Next

 
 
Function nj_grid_varget

PURPOSE ^

NJ_GRID_VARGET - Get gridded variable data and associated grid coordinates

SYNOPSIS ^

function [data, grid]=nj_grid_varget(ncRef,var,start, count, stride)

DESCRIPTION ^

NJ_GRID_VARGET - get variable data and associated grid coordinates from local NetCDF file, NetCDF URL or OpenDAP URL

 Usage:    
   [data, grid]=nj_grid_varget(file,var,start,count,stride);
 where,
   ncRef - Reference to netcdf file. It can be either of two
           a. local file name or a URL  or
           b. An 'mDataset' matlab object, which is the reference to already
              open netcdf file.
              [ncRef=mDataset(uri)]
   var  =  variable to extract          
           start = A 1-based array specifying the position in the file to begin reading or corner of a
                   hyperslab e.g [1 2 1]. Specify 'inf' for last index.
                   The values specified must not exceed the size of any
                   dimension of the data set.
           count = A 1-based array specifying the length of each dimension to read. e.g [6 10 inf]. 
                   Specify 'inf' to get all the values from start index.
           stride = A 1-based array specifying the interval between the
                    values to read. e.g [1 2 2] 
        
     Any of these URI types will work:
     Local NetCDF:  ncRef='bora_feb.nc';
     Remote NetCDF: ncRef='http://coast-enviro.er.usgs.gov/models/test/bora_feb.nc';
     OpenDAP:       ncRef='http://coast-enviro.er.usgs.gov/cgi-bin/nph-dods/models/test/bora_feb.nc';
     Local NcML:    ncRef='bora_feb.ncml';
     Remote NcML:   ncRef='http://coast-enviro.er.usgs.gov/models/test/bora_feb.ncml';

   Any of these syntaxes will return the surface temperature values
   from the first time step: Assuming Array shape is [8,20,60,160]        
           
     Using 'start' 'count' 'stride' arrays to specify indexing%
     [data, grid]=nj_grid_varget(ncRef,'temp',[1 1 1 1],[1 1 30 inf],[1 1 2 2]); % get surface temp from first time step 
          
     The following will return the entire longitude variable
     t=nj_grid_varget(ncRef,'lon_rho');  % get all the lon values

CROSS-REFERENCE INFORMATION ^

This function makes following njTBX API calls:
  • mDataset mDataset class constructor - opens a netcdf file and creates a grid or netcdf mDataset object.
  • getVar mDataset/getVar - Retrieves a matlab variable object.
  • getGeoGridVar mDataset/getGeoGridVar - Get variable into a GeoGrid if it has a Georeferencing coordinate system.
  • getData mGeoGridVar/getData - get the 3D volume data
  • getGrid mGeoGridVar/getGrid - Get grid coordinate and time axes
  • subsetGeoGridVar mGeoGridVar/subsetGeoGridVar - subset gridded variable based on start,count and stride.

See demos using function nj_grid_varget:


previous Function nj_attget
Function nj_info Next
© 2006-2009   Mississippi State University   • License Terms   • Credits