The NCDF_VARPUT procedure writes a hyperslab of values to a NetCDF variable. The NetCDF file must be in data mode to use this procedure.
Examples
Suppose that you wish to create a 100x100 byte (0 & 1) checker board:
offset_even = [0,0] & offset_odd = [1,1]
count = [50,50] & stride = [2,2]
black = BYTARR(50,50, /NOZERO) > 1B
id = NCDF_CREATE('checker.nc', /CLOBBER)
NCDF_CONTROL, id, /FILL
xid = NCDF_DIMDEF(id, 'x', 100)
yid = NCDF_DIMDEF(id, 'y', 100)
zid = NCDF_DIMDEF(id, 'yy', /UNLIMITED)
vid = NCDF_VARDEF(id, 'board', [yid, xid], /BYTE)
NCDF_DIMRENAME, id, zid, 'z'
NCDF_CONTROL, id, /ENDEF
check_id = NCDF_DIMID(id,'z')
NCDF_DIMINQ, id, check_id, dim_name, dim_size
HELP, check_id, dim_name, dim_size
IDL prints:
CHECK_ID LONG = 2
DIM_NAME STRING = 'z'
DIM_SIZE LONG = 0
Note that the DIM_SIZE is 0 because no records have been written yet for this dimension.
NCDF_VARPUT, id, vid, black, $
COUNT=count, STRIDE=stride, OFFSET=offset_even
NCDF_VARPUT, id, vid, black, $
COUNT=count, STRIDE=stride, OFFSET=offset_odd
NCDF_VARGET, id, vid, output
WINDOW, XSIZE=100, YSIZE=100
TVSCL, output
stride = [2,3]
NCDF_VARPUT, id, vid, black, $
COUNT=count, STRIDE=stride, OFFSET=offset_odd
IDL prints:
% NCDF_VARPUT: Requested write is larger than the available data area.
You will need to change the OFFSET/COUNT/STRIDE, or redefine the variable dimensions. You attempted to access 150 elements in a 100 array.
NCDF_CLOSE, id
Syntax
NCDF_VARPUT, 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
Data values to be written to the NetCDF file. If the data type of Value does not match that of the NetCDF variable, it is converted to the correct data type before writing. Value must have a dimensionality less than or equal to that of the variable being written.
Keywords
COUNT
An optional vector containing the counts to be used in writing Value. COUNT is a 1-based vector with an element for each dimension of the data to be written. Note that counts do not have to match the dimensions of Value. The default count vector is the dimensionality of Value.
OFFSET
An optional vector containing the starting position to write. The default start position is [0, 0, ...].
STRIDE
An optional vector containing the strides, or writing intervals, between written values of the NetCDF variable. The default stride vector is that for a contiguous write, [1, 1, ...].
Version History
See Also
NCDF_VARGET, NCDF_VARGET1, NCDF_VARID, NCDF_VARINQ