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.

Examples


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:

; A variable that contains the offset for the sub-image:
offset = [80, 20]
; The dimensions of the sub-image:
count = [70, 70]
; 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:
stride = [2, 3]
; Open the NetCDF file:
id = NCDF_OPEN('dave.nc')
; Get the variable ID for the image:
image = NCDF_VARID(id, 'image')
; Get the full image:
NCDF_VARGET, id, image, fullimage
; Extract the sub-sampled image:
NCDF_VARGET, id, image, subimage, $
   COUNT=count, STRIDE=stride, OFFSET=offset
; Close the NetCDF file:
NCDF_CLOSE, id

Syntax


NCDF_VARGET, Cdfid, Varid, Value [, COUNT=vector] [, OFFSET=vector] [, STRIDE=vector]

Arguments


Cdfid

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

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. COUNT is a 1-based vector with an element for each dimension of the data to be read. The default matches the size of the variable so that all data is read.

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, ...].

Version History


Pre 4.0

Introduced

See Also


NCDF_VARGET1, NCDF_VARID, NCDF_VARINQ, NCDF_VARPUT