aryDelta

Compress an array using delta compression

Description:

This function creates a copy of the supplied array stored in DELTA form, which provides a lossless compression scheme for integer data. This scheme assumes that adjacent integer values in the input array tend to be close in value, and so differences between adjacent values can be represented in fewer bits than the absolute values themselves. The differences are taken along a nominated pixel axis within the supplied array (specified by argument ZAXIS).

In practice, the scheme is limited currently to representing differences between adjacent values using a HDS integer data type (specified by argyument TYPE) - that is, arbitrary bit length is not yet supported. So for instance an _INTEGER input array can be compressed by storing differences as _WORD or _BYTE values, but a _WORD input array can only be compressed by storing differences as _BYTE values.

Any input value that differs from its earlier neighbour by more than the data range of the selected data type is stored explicitly using the data type of the input array.

Further compression is achieved by replacing runs of equal input values by a single occurrence of the value with a correspsonding repetition count.

It should be noted that the degree of compression achieved is dependent on the nature of the data, and it is possible for the compressed array to occupy more space than the uncompressed array. The compression factor actually achieved is returned in argument " zratio" (the ratio of the supplied array size to the compressed array size). A minmum allowed compression ratio may be specified via argument " minrat" . If the compression ratio is less than this value, then the returned copy is left uncompressed.

Invocation

void aryDelta( Ary ary1, int zaxis, const char type, float minrat, AryPlace place, float zratio, Ary ary2, int status )

Notes:

Parameters :

ary1
The input array identifier. This can be stored in any form. If it is already stored in DELTA form, it is uncompressed and then re-compressed using the supplied compression parameters. If is is stored in SCALED form, the internal integer values are compressed and the scale and zero terms are copied into the DELTA array.
zaxis
The one-based index of the pixel axis along which differences are to be taken. If this is zero, a default value will be selected that gives the greatest compression. An error will be reported if a value less than zero or greater than the number of axes in the input array is supplied.
type
The data type in which to store the differences between adjacent input values. This must be one of _BYTE , _WORD or _INTEGER . Additionally, a blank string may be supplied in which case a default value will be selected that gives the greatest compression.
minrat
The minimum allowed ZRATIO value. If compressing the input array results in a ZRATIO value smaller than or equal to MINRAT, then the returned array is left uncompressed. If the supplied value is zero or negative, then the array will be compressed regardless of the compression ratio.
place
Address of an array placeholder pointer (e.g. generated by the aryPlace function), which indicates the position in the data system where the new array will reside. The placeholder is annulled by this function, and a value of NULL will be returned.
zratio
Returned holding the compression factor actually achieved (the ratio of the supplied array size to the compressed array size). Genuine compressions are represented by values more than 1.0, but values less than 1.0 may be returned if the input data is not suited to delta compression (i.e. if the " compression" actually expands the array storage). Note, the returned value of ZRATIO may be smaller than MINRAT, in which case the supplied array is left unchanged. The returned compression factor is approximate as it does not take into account the space occupied by the HDS metadata describing the extra components of a DELTA array (i.e. the component names, data types, dimensions, etc). This will only be significant for very small arrays.
ary2
Returned holding a pointer to the new DELTA array.
status
The global status.