The BZIP2_UNCOMPRESS function uncompresses a given input byte array using the bzip2 compression algorithm, and returns a byte array containing the original uncompressed data. The uncompression is done using the Python bz2 library.

If you know the dimensions and data type of the original data, then you can use the DIMENSIONS and TYPE keywords to restore the data to its correct shape and type. Otherwise, IDL will automatically uncompress the data to a one-dimensional byte array containing all of the original uncompressed data.

Examples


Here, we compress and uncompress a float array:

data = findgen(100, 200)
zdata = bzip2_compress(data)
help, zdata
dataout = bzip2_uncompress(zdata, TYPE=4, DIMENSIONS=[100, 200])
print, array_equal(dataout, data)

IDL prints:

zdata          BYTE      = Array[18282]
  1

Since the float array has a total of 80,000 bytes, the compression space savings is about 77%.

Syntax


Result = bzip2_uncompress( Array [, DIMENSIONS=value] [, TYPE=value] )

Arguments


Array

Set this argument to a valid bzip2-compressed array.

Keywords


DIMENSIONS

Set this keyword to a scalar or array of dimensions for the result. If DIMENSIONS is not specified then a one-dimensional array is returned.

Note: To avoid unexpected results, the dimensions specified by the DIMENSIONS keyword should match the original dimensions of the array passed into bzip2_compress. IDL will throw an error if the number of elements is not equal to the size of the uncompressed data.

TYPE

Set this keyword to an integer or a string giving the IDL data type for the result. If TYPE is not specified, then an array of type BYTE is returned.

Note: To avoid unexpected results, the type specified by the TYPE keyword should match the original type of the array passed into ZLIB_COMPRESS.

Version History


9.2.0

Introduced

See Also


ZLIB_COMPRESS, ZLIB_UNCOMPRESS, BZIP2_COMPRESS