CoastWatch
CWF
Caribbean Regional Node

Information | Data | Software | Sites | Education | Feedback | News


Introduction

The CoastWatch binary file format, traditionally referred to as IMGMAP or "image map", is composed of two main parts -- the image header followed by an image data stream. The image header contains information about the data dimensions, channel number, time, location, calibration, etc. The image data stream contains the data and graphics pixel values, possibly in a compressed form. The data compression uses an algorithm that takes advantage of small data differences between adjacent pixels, where as the graphics are compressed with a simple run length encoding scheme. The process of reading visible or thermal data from a CWF file usually includes the following steps:

Image Header

The image header has a variable size, depending on the data compression and size of the image. In compressed files (header word 39 below), the header is always 1024 bytes long. In uncompressed files the header is two times the number of data columns in length, so for example an uncompressed file with 1200 data columns will have a header size of 2400 bytes.

The table below gives the header value locations and codes. Note that each header value is a two-byte word (16-bit) integer value.

    Word 0      Satellite designator (two EBCDIC characters)
                    Byte 1 = N
                    Byte 2 = B (NOAA-6)
                             C (NOAA-7)
                             D (NOAA-8)
                             E (NOAA-9)
                             F (NOAA-10)
                             G (NOAA-11)
                             H (NOAA-12)
                             J (NOAA-14)
                             K (NOAA-15)
                             L (NOAA-16)
                             M (NOAA-17)   ... etc
    Word 1      Satellite ID 
                    0 = morning satellite (AM)
                    1 = afternoon satellite (PM)
    Word 2      Data set type 
                    1 = LAC
                    2 = GAC
                    3 = HRPT
    Word 3      Projection type 
                    0 = unmapped
                    1 = mercator
                    2 = polar stereographic
                    3 = linear lat/lon
    Word 4      Beginning latitude of image area * 128 (N = +, S = -)
    Word 5      Ending latitude of image area * 128 (N = +, S = -)
    Word 6      Beginning longitude of image area * 128 (E = +, W = -)
    Word 7      Ending longitude of image area * 128 (E = +, W = -)
    Word 8      Image map resolution * 100
                    kilometers/pixel (mercator, polar)
                    degrees/pixel (linear)
                    sampling interval (unmapped)
    Word 9      Spare
    Word 10     Spare
    Word 11     Polar grid size (polar projection)
    Word 12     Grid size (polar projection)
    Word 13     Image hemisphere
                    1 = northern hemisphere
                   -1 = southern hemisphere
    Word 14     Prime longitude (E = +, W = -) (polar projection)
    Word 15     Horizontal image coordinate of NW corner of image (I offset)
                (not applicable to unmapped or linear)
    Word 16     Vertical image coordinate of NW corner of image (J offset)
                (not applicable to unmapped or linear)
    Word 17     Number of image columns (not applicable to unmapped)
    Word 18     Number of image rows (not applicable to unmapped)
    Word 19     Spare
    Word 20     Spare
    Word 21     Number of records written to unmapped image files
    Word 22     Calibration flag
                    0 = no calibration
                    1 = calibrated to albedos and temperatures
                    2 = calibrated to albedos and GOES counts
    Word 23     Fill option
                    0 = no fill
                    1 = fill with average pixel values
                    2 = fill with adjacent pixel values
    Word 24     Data type
                    1 through 5 = AVHRR channel number
                    6 = MCSST
                    7 = NDVI
                    101 = scan angle
                    102 = satellite zenith angle
                    103 = solar zenith angle
                    104 = relative azimuth angle
                    105 = scan time
                    201 = MCSST split window eqn
                    202 = MCSST dual window eqn
                    203 = MCSST triple window eqn 
                    204 = CPSST split window eqn
                    205 = CPSST dual window eqn
                    206 = CPSST triple window eqn 
                    207 = NLSST split window eqn
                    208 = NLSST dual window eqn
                    209 = NLSST triple window eqn 
                    301 = Ocean reflectance
                    302 = Turbidity
                    401 = Cloud mask
    Word 25     Data ID
                    0 = visible
                    1 = IR
                    2 = ancillary
                    3 = cloud mask
                    4 = graphics
    Word 26     Sun normalization flag
                    0 = not performed
                    1 = performed
    Word 27     Limb correction flag
                    0 = not performed
                    1 = performed
    Word 28     Non-linearity correction flag
                    0 = not performed
                    1 = performed
    Word 29     Number of orbits processed (for composited images)
    Word 30     Number of channel images written to output file
    Word 31     Size of image pixel
    Word 32     Starting block number of image data
    Word 33     Ending block number of image data
    Word 34     Number of ancillary images written to output file
    Word 35     Size of ancillary pixel
    Word 36     Starting block number of ancillary data
    Word 37     Ending block number of ancillary data
    Word 38     Block size of output image files
    Word 39     Image file compression flag 
                    0 = uncompressed file
                    2 = compressed file
    Word 40     ID of MCSST equation used to compute SST
                    0 = no sst
                    1 = NOAA-9 Day Split Eqn.
                    2 = NOAA-9 Night Split Eqn.
                    3 = NOAA-9 Night Triple Eqn.
                    4 = NOAA-10 Day Eqn.
                    5 = NOAA-10 Night Eqn.
                    6 = NOAA-11 Day Split Eqn.
                    7 = NOAA-11 Night Split Eqn.
                    8 = NOAA-11 Night Dual Eqn.
                    9 = NOAA-11 Night Triple Eqn.
    Word 41     Percentage of non-zero pixels
    Word 42     Horizontal shift offset 
    Word 43     Vertical shift offset 
    Word 44     Horizontal skew offset 
    Word 45     Vertical skew offset 
    Word 46     Spare
    Word 47     Spare
    Word 48     Spare
    Word 49     Spare
    Word 50     Orbital node over target area
                   -1 = ascending node
                    1 = descending node
                    2 = both
    Word 51     Day/night flag
                    0 = day
                    1 = night
    Word 52     Image data start row
    Word 53     Image data start column
    Word 54     Image data end row
    Word 55     Image data end column
    Word 56     Start year of orbit 1
    Word 57     Start Julian day of orbit 1
    Word 58     Start month and date of orbit 1 (MMDD format)
    Word 59     Start hour and minute of orbit 1 (HHMM format)
    Word 60     Start seconds of orbit 1
    Word 61     Start milliseconds of orbit 1
    Word 62     End year of orbit 1
    Word 63     End Julian day of orbit 1
    Word 64     End month and date of orbit 1 (MMDD format)
    Word 65     End hour and minute of orbit 1 (HHMM format)
    Word 66     End seconds of orbit 1
    Word 67     End milliseconds of orbit 1
    Word 68     Processing block ID (Orbit number)
    Word 69     Ramp/Auto calibration of orbit 1
    Word 70     Number of data gaps in orbit 1
    Word 71     Sync errors in orbit 1
    Word 72     TIP parity errors in orbit 1
    Word 73     Auxiliary errors in orbit 1
    Word 74     Calibration parameters ID of orbit 1
    Word 75     DACS status of orbit 1
    Word 76     Slope of channel 1 calibration (*10000)
    Word 77     Intercept of channel 1 calibration (*10000)
    Word 78     Slope of channel 2 calibration (*10000)
    Word 79     Intercept of channel 2 calibration (*10000)
    Word 80     Spare
    Word 81     Spare
    Word 82     Spare
    Word 83-115 Repetition of word 50-82 for orbit 2
    Word 116-148 Repetition of word 50-82 for orbit 3, etc.
Image Data

The format of the image data will depend on the data ID (header word 25) and compression type (header word 39). For ancillary data including angles and scan times, the data stream is written uncompressed as rows*cols 16-bit integer values. The integer values may be directly converted to ancillary values using standard conversions (see below). Similarly for cloud mask files, the data stream is written uncompressed as rows*cols byte values. Each cloud mask bit value represents a different cloud mask test, with 1 indicating the presence of cloud, and 0 indicating clear ocean. Visible and infrared data may be written either in compressed or uncompressed format. For visible and infrared data in uncompressed format, the image data consists of rows*cols 16-bit values arranged as follows:

    byte        1           2   
    nibble   1     2     1     2
            |-------|   |-------|
            SIII IIII   IIII GGGG         

    bit     7654 3210   7654 3210

    S:  sign bit (always 0)
    I:  image data bit 
    G:  graphics bit
In the case of a compressed data stream, the image data values are compressed and written first, then the graphics are compressed and written. Image data compression is based on the difference between previous and next pixels. The compressed image data is written as a string of bytes, according to the following scheme:

    if ((first pixel of image) or (abs (this pixel - last pixel) > 63))
    {
      write two bytes arranged as:
        byte 1, nibble 1 = 1000
        byte 1, nibble 2 = same as byte 1, nibble 1 in uncompressed
        byte 2, nibble 1 = same as byte 1, nibble 2 in uncompressed
        byte 2, nibble 2 = same as byte 2, nibble 1 in uncompressed
    }
    else
    {
      write one byte arranged as:
        bit 8 = 0
        bit 7 is the sign bit (0 = plus, 1 = minus)
        bits 6 through 0 = abs (this pixel - last pixel)
    }
The graphics compression algorithm uses run length encoding. The graphics are specified as byte pairs, where the first byte is the value of the graphics pixel and the second byte is the number of consecutive pixels (from 0 to 255) of that pixel. The encoding algorithm is as follows:

    n = 1
    run length = 0
    last pixel = graphics at pixel 1
    while (n < rows*cols)
    {
      this pixel = graphics at pixel n
      if (this pixel = last pixel)
      {
        if (run length = 255)
        {
          write two bytes arranged as:
            byte 1 = this pixel
            byte 2 = run length
          run length = 0
        }
        else 
        {
          run length = run length + 1
        }
      }
      else
      {
        write two bytes arranged as:
          byte 1 = last pixel
          byte 2 = run length
        last pixel = this pixel
        run length = 0
      }
      n = n + 1
    }
In order to recover the actual floating-point data values from the 11-bit integer data values in either compressed or uncompressed format, the following conversions are needed (header word 25):
    Visible:
      albedo = pixel_value / 20.47

    Infrared:
      if (0 < pixel_value <= 920)
        temp = (pixel_value - 1)*0.1 + 178.0
      if (921 <= pixel_value <= 1720)
        temp = (pixel_value - 921)*0.05 + 270.0
      if (1721 <= pixel_value <= 2047)
        temp = (pixel_value - 1721)*0.1 + 310.0

    Ancillary:
      angle = pixel_value / 128
      hour = pixel_value / 100
      hour = hour + (pixel_value - hour) / 60

^ Back to main page USDOC | NOAA | NESDIS | CoastWatch