cdflib.setVarCompression

Specify compression settings used with variable

Syntax

cdflib.setVarCompression(cdfId,varNum,ctype,cparams)

Description

cdflib.setVarCompression(cdfId,varNum,ctype,cparams) configures the compression setting for a variable in a Common Data Format (CDF) file.

Input Arguments

cdfId

Identifier of a CDF file, returned by a call to cdflib.create or cdflib.open.

varNum

Numeric value identifying a variable in the file. Variable identifiers (variable numbers) are zero-based.

ctype

One of the following text strings, or its numeric equivalent, specifying the compression type.

Text StringCompression Type
'NO_COMPRESSION'No compression.
'RLE_COMPRESSION'Run-length encoding compression
'HUFF_COMPRESSION'Huffman compression
'AHUFF_COMPRESSION'Adaptive Huffman compression
'GZIP_COMPRESSION'GNU's zip compression

cparams

Optional parameter specifying any additional parameters required by the compression type. Currently, the only compression type that uses this parameter is 'GZIP_COMPRESSION'. For this compression type, you use cparms to specify the level of compression as a numeric value between 1 and 9.

Examples

Create a CDF, create a variable, and then set the compression used by the variable. To run this example, you must be in a folder with execute permission.

cdfid = cdflib.create('mycdf.cdf');

% Create a variable in the file.
varNum = cdflib.createVar(cdfid,'Time','cdf_int1',1,[],true,[]);

% Specify the compression used by the variable.
cdflib.setVarCompression(cdfid,0,'GZIP_COMPRESSION',8)

% Check the compression setting of the variable
[ctype params percent] = cdflib.getVarCompression(cdfid,0)

ctype =

GZIP_COMPRESSION

params =

     8

percent =

     0

% Clean up
cdflib.delete(cdfid);
clear cdfid

References

This function corresponds to the CDF library C API routine CDFsetzVarCompression.

To use this function, you must be familiar with the CDF C interface. Read the CDF documentation at the CDF Web site.

For copyright information, see the cdfcopyright.txt file.

Was this topic helpful?