next up previous contents
Next: Supplemental Codes Up: Centrally Defined Codes Previous: Unit Codes   Contents


Packing Codes

The packing codes are used in the PAKSPEC.CODE record field and specify the packing method for the data. Each code is stored in an integer at least 32 bits long.

Only two packing methods are currently defined. They both apply to gridded fields only. The first one has a code value of 1 and is called NMC scaling. This method packs data for each of the grid points of the last Level 1 dimension over all of the other Level 1 dimensions. For example, if the Level 1 dimensions consist of an array of $72 \times 91 \times 6$, then the data will be packed over the $72
\times 91$ values for each of the six grid points in the third dimension of the array. This method needs two parameters for each grid point to unpack the data. One parameter is the midpoint of the data, defined as


\begin{displaymath}A = \frac{\max + \min}{2}.\end{displaymath}

The other parameter is a scaling factor, given as


\begin{displaymath}n = {\rm int} \left[\ln (\max - A) \ln (2) \right] + 1 \end{displaymath}

The data are then packed by using


\begin{displaymath}pdata = {\rm round} \left[ (data - A) 2^{15-n} \right] .\end{displaymath}

The packed data values and the parameter $n$ are short integers. The parameter $A$ is a floating-point number. These parameters are stored as $(n, A)$ in the PAKVAL.INFO field. Note that $n$ and $A$ are vectors. To unpack the data, the reverse procedure is followed:


\begin{displaymath}data = 2^{n-15} pdata + A.\end{displaymath}

The second packing method is somewhat similar to the first. There are three parameters. The first is a pointer into the Level 1 indices to indicate which dimension the packing applies. Using the example above, this value would be 2 (assuming a starting point of 0.) The next two parameters are very similar to the two parameters above. The first parameter is the minimum value of the data and the second is a scaling factor, given as


\begin{displaymath}s = \frac{\max - \min}{32766}.\end{displaymath}

The data are then packed by using


\begin{displaymath}pdata = {\rm round} \left( \frac{data - \min}{s} \right) + 1. \end{displaymath}

The packed data are short integers, while the two parameters are floating-point values. The parameters are stored as $(index, \min, s)$ in the PAKVAL.INFO field. Note that $\min$ and $s$ are vectors. To unpack the data, the reverse procedure is followed:


\begin{displaymath}data = s (pdata - 1) + \min.\end{displaymath}

The advantage to the first method is that more precision is retained than in the second method. The disadvantage is that exponentiation must be used in unpacking the data, which is a slow and computationally costly step.


next up previous contents
Next: Supplemental Codes Up: Centrally Defined Codes Previous: Unit Codes   Contents
Eric Nash 2003-09-25