Unpacking LAC/HRPT Data
Unpacking LAC/HRPT Data

This appendix describes a user procedure for unpacking five channel LAC/HRPT data received on CCTs from SSB. This procedure can be readily adapted to selected channel format LAC/HRPT data or GAC data.

As described in Section 3.2, LAC/HRPT data are written on tape as two physical records per scan. Each scan contains data from all five channels plus Earth location and calibration information. The data are 10-bit samples. Data from the 5 channels are interleaved, i.e., the first data sample in the scan is from Channel 1, the next from Channel 2, then Channel 3, Channel 4, and Channel 5, with this sequence repeating through the scan. The 10-bit data samples are packed three to a four-byte (8 bits/byte) group (i.e., three to a 32-bit word).

The unpacking procedure described below unpacks the data and rearranges it so that data from the same channel are collected together and stored in sequence (i.e., all of the data for Channel 1 followed by all of the data for Channel 2, etc.). Thus, the original five channel scan is sorted into five consecutive single channel scan lines. The individual 10-bit data samples are also unpacked and stored in consecutive pairs of bytes (or 16-bit words, or 32-bit halfwords). Access to Earth location and calibration information is also provided.

The procedure will be outlined in a sequence of steps:

  1. Define four arrays to be used as data buffers.
    1. ISCAN (3700 @ 32 bits) - This buffer will hold a complete Earth scan (2 physical records) of unpacked HRPT data.
    2. IEARTH (102 @ 16 bits) - This buffer will contain the Earth location information.
    3. IDATA (2048, 5 @ 16 bits) - This buffer will contain the unpacked 2048 data samples for each of five channels.
    4. d. IBUF (10242 @ 16 bits) - This buffer will hold data at an intermediate point in the procedure
  2. Equivalence IEARTH(1) and ISCAN(27). This "points" IEARTH to that portion of the Earth scan containing the Earth location information.
  3. Skip the first three records on the tape (the first is the TBM Header record and the next two are the data set header records).
  4. Read the next record into ISCAN(1) through ISCAN(1850). This is the first half of an Earth scan.
  5. Read the next record into ISCAN(1851) through ISCAN(3700). This is the second half of an Earth scan.
  6. The Earth location information is now available in IEARTH as described in the Level 1b format. For example, IEARTH(1) and IEARTH(2) are the latitude and longitude respectively for the first reference point (#25). To convert to units of degrees, divide each by 128.
  7. The calibration coefficients are now available in ISCAN(4) through ISCAN(13), as described in the Level 1b format. The use of these calibration coefficients is described in Section 3.3.
  8. Use subroutine UNPK10 to unpack the 10-bit data samples into 16-bit elements of IBUF. A listing of UNPK10 is included below. The FORTRAN call is:

    CALL UNPK10(ISCAN(113),IBUF,3414)

    where ISCAN(113) is the start of the HRPT data in ISCAN, IBUF is a temporary buffer for the unpacked but still interleaved data samples, and 3414 is the number of 32-bit elements of ISCAN from each of which UNPK10 will extract three data samples (and store them in three 16-bit elements of IBUF).

  9. Move data samples from IBUF into IDATA so that data from each channel can be separately accessed (i.e., IDATA(N,1) will refer to the Nth sample along the scan line for Channel 1, IDATA(N,2) for Nth sample for Channel 2, etc.). This is done by the following FORTRAN loop:
      DO m  I  = 1,5       (5 Channels)
           K = I 
           DO m  J  = 1,2048    (2048 Samples/Channel)
           IDATA(J,I) = IBUF(K) 
         m  K = K + 5
  10. The 10-bit data values are now accessible in IDATA as desired, concluding the procedure.

In the case of two channel selected data (i.e., where the user has specified that data from only two designated channels were to be provided) UNPK10 is not used because the data samples have already been unpacked into 16-bit elements. In the case of either one or two channel selected data, the references to the calibration and Earth location information are as shown.

In the case of five channel GAC data, the procedure may be used as shown with changes for the record length and position and amount of the Earth location information.

A listing of UNPK10 follows:

   DIMENSION ISCAN(3700), IBUF(10242)
   DATA MASK1/Z3FF00000/
   DATA MASK2/Z000FFC00/
   DATA MASK3/Z000003FF/
   J = 0
   DO 10 I = 1,N
   J = J + 1
   J = J + 1
   J = J + 1
The arrays used in UNPK10 are defined as follows: ISCAN is the input Earth scan buffer, 3700 @ 32-bit elements for LAC/HRPT. IBUF is the output buffer for unpacked data elements, 10242 @ 16-bit elements for LAC/HRPT. N is the number of elements of ISCAN to be unpacked, 3414 for LAC/HRPT.

MASK1 is a 32-bit mask with ones set in the 10-bit positions of the first 10-bit data sample in a 32-bit element of ISCAN. MASK2 and MASK3 are the same for the second and third data samples.

The function LAND(A,B) performs a logical "AND" on A and B, with the result left in A. The effect in this routine of the use of LAND and the MASK is to zero all bits in IWORD except those of the data sample specified by the MASK, thus isolating it.

The function SHIFTR(A,N) performs a right shift of the contents of A by N places, and is equivalent to a division of A by 2N. The purpose of UNPK10 is to right justify the isolated data sample in IWORD, preparatory to moving it to the output buffer IBUF.

UNPK10 proceeds through the input scan buffer, unpacking the words one by one and storing in IBUF the three data samples obtained from each input element, until the entire input scan has been processed.

Source: http://www.ncdc.noaa.gov