Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

netcdf.defVarChunking

Define chunking behavior for NetCDF variable

Syntax

netcdf.defVarChunking(ncid,varid,storage,chunkDims)

Description

netcdf.defVarChunking(ncid,varid,storage,chunkDims). sets the chunk settings for the variable specified by varid. Chunking is a technique to improve performance. storage specifies the type of chunking to use and chunkDims specifies the extents of the chunk size. You must specify the chunk size used with a variable after creating the variable but before you write data to the variable.

You cannot specify the chunk size for variables in a NetCDF file created with the netCDF-3 mode (CLASSIC_MODEL).

Input Arguments

ncid

Identifier of NetCDF file, returned by netcdf.create or netcdf.open, or of a NetCDF group, returned by netcdf.defGrp.

varid

Identifier of a NetCDF variable, returned by netcdf.defVar.

storage

Text string specifying whether NetCDF should break the variable into chunks when writing to a file. If set to CHUNKED, NetCDF breaks the variable into chunks; if set to CONTIGUOUS, NetCDF does not break the data into chunks.

chunkDims

Array specifying the dimensions of the chunk.

Because MATLAB® uses FORTRAN-style ordering, the order of dimensions in chunkdims is reversed relative to what would be in the C API.

If storage is CONTIGUOUS, you can omit chunkDims.

Default: Chunk size determined by the NetCDF library.

Examples

This example creates a NetCDF file and specifies the chunking behavior of a variable.

ncid = netcdf.create('myfile.nc','NETCDF4');
latdimid = netcdf.defDim(ncid,'lat',1800);
londimid = netcdf.defDim(ncid,'col',3600);
varid = netcdf.defVar(ncid,'earthgrid','double',[latdimid londimid]);
netcdf.defVarChunking(ncid,varid,'CHUNKED',[180 360]);
netcdf.close(ncid);

References

This function corresponds to the nc_def_var_chunking function in the NetCDF library C API.

For copyright information, read the netcdfcopyright.txt and mexnccopyright.txt files.

Was this topic helpful?