MODIS Atmosphere
MODIS Atmosphere Home Products  Images  Validation  News  Staff  Forum  Reference  Tools  Help
Aerosol Product  Water Vapor Product  Cloud Product  Atmosphere Profile Product  Cloud Mask Product   Joint Atmosphere ProductLevel-2 Products
Daily Global Product  Eight-Day Global Product  Monthly Global ProductLevel-3 Products       Filled Land Surface Albedo ProductFilled Normalized Difference Vegetative Index ProductOne-Minute Land Ecosystem Classification ProductLevel-3 Ancillary Land Surface Products
TOOLS
Graphical User Interface Tools
Web Based Tools
Command Line Programs
Bit Interpretation
Get Help

Bit Interpretation

MODIS Atmosphere Bit Flag SDS's

Most MODIS Atmosphere HDF data products contain one or more "bit flag" Scientific Data Set (SDS) arrays. Bit flag SDS names may contain the string "Quality_Assurance" or may have a more descriptive name like "Cloud_Mask". However, they all have one common attribute - bit flag arrays contain multiple flags stored in particular (fixed) bit positions of the array.

All of the bit flag arrays in MODIS Atmosphere HDF data products are described more completely in the QA Plan. The current version (v2.3) of the QA Plan was drafted in October 2002; a new version, which will cover Collection 005 updates, is scheduled to be released in early 2005 and will be made available on this web site.

It should be noted that within MODIS Atmosphere, the term QA (or Quality Assurance) is loosely defined to include a wide variety of flags that detail 1.) Confidence or Quality , 2.) Processing Path, 3.) Status or Outcome, 4.) Retrieval Method, 5.) Data or Scene Characteristics, and 6.) Metadata or Ancillary Input Source.


Bit and Byte Array Indexing Convention: "Zero-based"

The convention for indexing arrays varies from language to language. Array indexing in FORTRAN typically starts at 1; and array indexing in C typically starts at 0. However, almost all tools used for bit extraction (in both FORTRAN and C) use an index start convention of 0 for both bits and bytes. In addition, the HDF interface is based in the C (0-based) language. Therefore a 0-based start convention for indexing (numbering) the bits and bytes is used here.

Indexing Starts at 0



Bit and Byte Array Ordering Convention: "Big-Endian"

Bit-String Dumps

If you use a tool that dumps bit registers (01001001), you need to keep in mind that standard HDF data products (including all MODIS HDF data) are written using the big-endian referencing scheme. Since HDF is platform-independent, the HDF library will perform no byte-order conversion on big-endian platforms; if the platform being used is little-endian, the library will convert the byte-order of the variables to big-endian.

Therefore, when "stripping bits" from a Bit String SDS's (Quality Assurance or Cloud Mask arrays, for example) using bit manipulation tools, the bits will always be numbered from right (bit 0) to left (bit 7). That is, the least significant bit (20) is on the right and most significant bit (27) is on the left.

Big Endian Convention

Numerical Whole-Byte Dumps

If you use ncdump or other tools to dump full-byte values (numbers from 0 to 255) from the bit string arrays (SDS's); you can recreate the bit flags using either the Big or Little Endian convention. One simply converts the numbers to 8 bit registers of 0 or 1 where the first bit (bit 0) is the lowest order (least significant) bit (20) and the last bit (bit 7) is the highest order (most significant) bit (27).

One then queries groups of seqential bits (matching the length of each flag) in the proper bit order from 0 to 7 and interprets the value of those bits (using the same least significant to most significant convention) to obtain the correct flag value.

Big Endian Convention Little Endian Convention



Example

Interpreting the Cloud_Mask SDS (1st byte only!)

The first byte of the (commonly used) Cloud_Mask SDS is made up of the following 6 flags. (For complete documentation of the Cloud_Mask SDS, see Cloud Mask: Format & Content).

Cloud Mask (Bit) Flag Description Key: 1st byte only
All bit and byte numbering starts at 0
Right (least significant bit) to Left (most significant bit)
Byte #0
Bits Flag Description Flag Interpretation
0 Cloud Mask Status Flag 0 = Not Determined
1 = Determined
1-2 Unobstructed FOV Cloudiness Flag 0 = Cloudy
1 = Probably Cloudy
2 = Probably Clear
3 = Confident Clear
3 Day/Night Flag 0 = Night
1 = Day
4 Sunglint Flag 0 = Yes
1 = No
5 Snow/Ice Background Flag 0 = Yes
1 = No
6-7 Land/Water Flag 0 = Water
1 = Coastal
2 = Desert
3 = Land

Suppose the following flags were set:

  • Cloud Mask Status = 1 = Determined
  • Unobstructed FOV Cloudiness = 2 = Probably Clear
  • Day/Night Path = 0 = Night
  • Sunglint Path = 1 = No
  • Snow/Ice Background Path = 1 = No
  • Land/Water Path = 3= Land

Bit-String Dump

Stripping the bits using a bit manipulation tool would yield the following results. Flags are then counted from the right (Big Endian Convention), and least to most significant bits are ordered from right to left for each flag.

Big Endian Convention

Numerical Whole-Byte Dump

However if one uses ncdump or another tool to dump the full-byte numeric value from the array, one gets a byte value of 245. One can then recreate the individual bit flags using either the Big or Little Endian convention, as long as one starts counting the bits (and assigning flags) from the least significant to the most significant bit.

Big Endian Convention Little Endian Convention