Main Content


Compression reserve percentage for variable


percent = cdflib.getVarReservePercent(cdfId,varNum)


percent = cdflib.getVarReservePercent(cdfId,varNum) returns the compression reserve percentage for a variable in a Common Data Format (CDF) file. This operation only applies to compressed variables.

cdfId identifies the CDF file. varNum is a numeric value that identifies the variable. Variable numbers are zero-based.


Open the example CDF file, get the number of a compressed variable, and then determine the reserve percent for the variable.

cdfid ='example.cdf');
varnum = cdflib.getVarNum(cdfid,'Temperature');
percent = cdflib.getVarReservePercent(cdfid,varnum);

More About

collapse all

reserve percentage

Specifies how much extra space to allocate for a compressed variable. This extra space allows the variable to expand when you write additional records to the variable. If you do not specify this room for growth, the library has to move the variable to the end of the file when the size expands and the space at the original location of the variable becomes wasted space.

By default, the reserve percent is 0 (no extra space is reserved). You can specify any percentage between 1 and 100 and values greater than 100. The value specifies the percentage of the uncompressed size of the variable.


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

To use this function, you must be familiar with the CDF C interface. You can access the CDF documentation at the CDF website.