CDF_COMPRESSION =============== The CDF_COMPRESSION procedure sets or returns the compression mode for a CDF file and/or variables. Compression parameters should be set before values are written to the CDF file. Special Note About Temporary File Location CDF creates temporary files whenever files/variables are compressed or uncompressed. By default, these files are created in the system designated temporary directory: "/tmp" for Unix-based, or defined directory by environment variable "TMP" or "TEMP" for Windows or "SYS$SCRATCH" for VMS. Users can set the environment variable CDF_TMP (Unix or Windows) or CDF$TMP (VMS) to set the temporary directory explicitly. If none is defined, the current directory will be used, which was the default place for pre-3.6.1 CDF. Examples ; Create a CDF file and define the compression. ; Compression only works on Single-File CDFs: id=CDF_CREATE('demo.cdf',[10,20],/CLOBBER,/SINGLE_FILE) CDF_COMPRESSION,id,SET_COMPRESSION=1 ; (Run-length encoding) att_id=CDF_ATTCREATE(id, 'Date',/GLOBAL) CDF_ATTPUT,id,'Date',att_id,systime() ; Change the compression type for the file to GZIP by using ; SET_GZIP_LEVEL: CDF_COMPRESSION,id,SET_GZIP_LEVEL=7 ; Retrieve compression information: CDF_COMPRESSION,id,GET_GZIP_LEVEL=glevel,GET_COMPRESSION=gcomp HELP,glevel,gcomp ; Create and compress an rVariable: rid=CDF_VARCREATE(id,'rvar0',[1,1],/CDF_FLOAT) CDF_COMPRESSION,id,SET_VAR_COMPRESSION=2,VARIABLE='rvar0' CDF_VARPUT,id,'rvar0',findgen(10,20,5) CDF_COMPRESSION,id,GET_VAR_COMPRESSION=v_comp,VARIABLE=rid,$ GET_VAR_GZIP_LEVEL=v_glevel HELP,v_comp,v_glevel ; Create and compress a zVariable: zid=CDF_varcreate(id,'zvar0',[1,1,1],DIM=[10,20,30],/ZVARIABLE,$ /CDF_DOUBLE) ; You can set a compression and check it in the same call: CDF_COMPRESSION,id,SET_VAR_GZIP_LEVEL=9,VARIABLE=zid,/ZVARIABLE,$ GET_VAR_GZIP_LEVEL=v_gzip HELP,v_gzip CDF_VARPUT,id,zid,dindgen(10,20,30),/ZVARIABLE ; File and variable keywords can be combined in the same call ; (Set calls are processed before Get calls) CDF_COMPRESSION,id,GET_VAR_COMPRESSION=v_comp,VARIABLE='zvar0',$ /ZVARIABLE, SET_COMPRESSION=2,GET_COMPRESSION=file_comp HELP,file_comp,v_comp CDF_DELETE,id IDL Output GLEVEL LONG = 7 GCOMP LONG = 5 V_COMP LONG = 2 V_GLEVEL LONG = 0 (Note that V_GLEVEL is 0, since the variable compression is not GZIP.) V_GZIP LONG = 9 FILE_COMP LONG = 2 V_COMP LONG = 5 Syntax CDF_COMPRESSION, Id [, GET_COMPRESSION=variable] [, GET_GZIP_LEVEL=variable] $ [, GET_VAR_BLOCKINGFACTOR=variable] $ [, GET_VAR_COMPRESSION=variable] $ [, GET_VAR_GZIP_LEVEL=variable] $ [, SET_COMPRESSION={0 | 1 | 2 | 3 | 5}] $ [, SET_GZIP_LEVEL=integer{1 to 9}] $ [, SET_VAR_BLOCKINGFACTOR=value] $ [, SET_VAR_COMPRESSION={0 | 1 | 2 | 3 | 5}] $ [, SET_VAR_GZIP_LEVEL=integer{1 to 9}] $ [, VARIABLE=variable name or index] [, /ZVARIABLE] Arguments Id The CDF ID of the file being compressed or queried, as returned from a previous call to CDF_OPEN or CDF_CREATE. Note that CDF compression only works for single-file CDF files (see CDF_CREATE). Keywords GET_COMPRESSION Set this keyword to a named variable to retrieve the compression type used for the single-file CDF file. Note that individual CDF variables may compression types different that the one for the rest of the CDF file. GET_GZIP_LEVEL Set this keyword to a named variable in which the current GZIP effort level (1-9) for the CDF file is returned. If the compression type for the file is not GZIP (5), then a value of zero is returned. GET_VAR_BLOCKINGFACTOR Set this keyword to a named variable to retrieve the variable's blocking factor. The blocking factor (as the number of records) defines the number of continuous records placed in a block for a variable when the data is written. A bigger blocking factor normally could provide a better performance while reading/writing the data. GET_VAR_COMPRESSION Set this keyword to a named variable to retrieve the compression type for the variable identified by the VARIABLE keyword. GET_VAR_GZIP_LEVEL Set this keyword to a named variable in which the GZIP effort level (1-9) for variable specified by the VARIABLE keyword is returned. If the compression type for the variable is not GZIP (5), then a value of zero is returned. SET_COMPRESSION Set this keyword to the compression type to be used for the single-file CDF file. Note that individual CDF variables may use compression types different than the one for the rest of the CDF file. Valid compression types are: 0 = No Compression 1 = Run-Length Encoding 2 = Huffman 3 = Adaptive Huffman 5 = GZIP (see the optional GZIP_LEVEL keyword) SET_GZIP_LEVEL This keyword is used to indicate the desired effort for the GZIP compression. This effort must be expressed as a scalar in the range (1-9). If GZIP_LEVEL is not specified upon entry then the default effort level is taken to be 5. If the SET_GZIP_LEVEL keyword is set to a valid value, and the keyword SET_COMPRESSION is not specified, the SET_COMPRESSION is set to GZIP (5). SET_VAR_BLOCKINGFACTOR Set this keyword to a value, which represents the variable's blocking factor. The blocking factor (as the number of records) defines the number of continuous records placed in a block for a variable when the data is written. A bigger blocking factor normally could provide a better performance while reading/writing the data. SET_VAR_COMPRESSION Set this keyword to the compression type for the variable identified by the VARIABLE keyword. If the variable is a zVariable, and is referred to by index in the VARIABLE keyword, then the keyword ZVARIABLE must be set. The desired variable compression should be set before variable data is added with CDF_VARPUT. Valid compression types are: 0 = No Compression 1 = Run-Length Encoding 2 = Huffman 3 = Adaptive Huffman 5 = GZIP (see the optional GZIP_LEVEL keyword) SET_VAR_GZIP_LEVEL Set this keyword to the GZIP effort level (1-9). If the compression type for the variable is not GZIP (5), no action is performed. VARIABLE Set this keyword to the name of a variable or a variable index to set the current variable. This keyword is mandatory when queering/setting the compression parameters of a rVariable or zVariable. Note that if VARIABLE is set to the index of a zVARIABLE, the ZVARIABLE keyword must also be set. If ZVARIABLE is not set, the variable is assumed to be an rVariable. ZVARIABLE Set this keyword if the current variable is a zVARIABLE and is referred to by index in the VARIABLE keyword. For example: CDF_COMPRESSION, id, VARIABLE=0, /ZVARIABLE,$ GET_VAR_COMPRESSION=vComp Version History 5.3 Introduced See Also CDF_CONTROL, CDF_CREATE, CDF_OPEN, CDF_VARNUM © 2015 Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation. All Rights Reserved. This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, this information may be restricted from transfer to various embargoed countries under U.S. laws and regulations.