NCDF_VARGET

The NCDF_VARGET procedure retrieves a hyperslab of values from a netCDF variable. The netCDF file must be in data mode to use this procedure.

Calling Sequence

NCDF_VARGET, Cdfid, Varid, Value

Arguments

Cdfid

The netCDF ID, returned from a previous call to NCDF_OPEN or NCDF_CREATE.

Varid

The netCDF variable ID, returned from a previous call to NCDF_VARDEF or NCDF_VARID, or the name of the variable.

Value

A named variable in which the values are returned. NCDF_VARGET sets Value 's size and data type as appropriate.

Keywords

COUNT

An optional vector containing the counts to be used in reading Value . The default count vector is that for a single read, [1, 1, ...], as in NCDF_VARGET1.

OFFSET

An optional vector containing the starting position for the read. The default start position is [0, 0, ...].

STRIDE

An optional vector containing the strides, or sampling intervals, between accessed values of the netCDF variable. The default stride vector is that for a contiguous read, [1, 1, ...].

Example

Suppose that a 230 by 230 image is saved in the netCDF file dave.nc . The following commands extract both the full image and a 70x70 sub-image starting at [80,20] sampling every other X pixel and every third Y pixel:

offset = [80, 20] ; A variable that contains the offset for the sub-image.

count = [70, 70] ; The dimensions of the sub-image.

stride = [2, 3] ; Create a variable to be used as a value for the STRIDE keyword. Every other X element and every third Y element will be sampled.

id = NCDF_OPEN('dave.nc') ; Open the NetCDF file.

image = NCDF_VARID(id, 'image') ; Get the variable ID for the image.

NCDF_VARGET, id, image, fullimage G; et the full image.

NCDF_VARGET, id, image, subimage, $

             COUNT=count, STRIDE=stride, OFFSET=offset
; Extract the sub-sampled image.

NCDF_CLOSE, id ; Close the NetCDF file.

See Also

NCDF_VARGET1 , NCDF_VARID , NCDF_VARINQ , NCDF_VARPUT