I have a question regarding the extraction of explicit flag information on a pixel level. I am working with MODIS SST level 2 files and would like to understand the meaning of the flag value which is hard to reconstruct from the coding system. I am aware of the information here https://oceancolor.gsfc.nasa.gov/atbd/ocl2flags/ and had a look into this question https://oceancolor.gsfc.nasa.gov/forum/oceancolor/topic_show.pl?tid=7363. I also read the l2_flags and the associating code values to given flag names:
int geophysical_data/l2_flags[pixels_per_line,number_of_lines] (Chunking: [91,909]) (Compression: shuffle,level 4)
long_name: Level-2 Processing Flags
flag_meanings: ATMFAIL LAND PRODWARN HIGLINT HILT HISATZEN COASTZ SPARE STRAYLIGHT CLDICE COCCOLITH TURBIDW HISOLZEN SPARE LOWLW CHLFAIL NAVWARN ABSAER SPARE MAXAERITER MODGLINT CHLWARN ATMWARN SPARE SEAICE NAVFAIL FILTER SPARE BOWTIEDEL HIPOL PRODFAIL SPARE
For one SST nc.file (A2002185) I found the following flag values: 1073742624, 1073742384, 1073742368, 1073742352, 1073742592, 1073742336, 1073742416, 1073742354.
Are those codes actually bit values? How to get from there to specific single-flag pixels (e.g. only the cloud-ice-flag)?
Your help is highly appreciated. Thanks a lot!
This description contains the following description of flag_masks and flag_meanings:
"The flag_masks and flag_meanings attributes describe a number of independent Boolean conditions using bit field notation by setting unique bits in each flag_masks value. The flag_masks attribute is the same type as the variable to which it is attached, and contains a list of values matching unique bit fields. The flag_meanings attribute is defined as above, one for each flag_masks value. A flagged condition is identified by performing a bitwise AND of the variable value and each flag_masks value; a non-zero result indicates a true condition. Thus, any or all of the flagged conditions may be true, depending on the variable bit settings."
So, for example, the cloud-ice flag (CLDICE) is the 10th entry in the flag_meanings attribute, and corresponds to the 10th flag_masks value, 512. The setting of this flag for a given pixel is determined by a logical AND of the flag value and 512. For the sample flags you provided:
1073742624, 1073742384, 1073742368, 1073742352, 1073742592, 1073742336, 1073742416, 1073742354
a logical AND with 512 gives this result:
512 512 512 512 512 512 512 512
indicating that all of the associated pixels have been flagged for cloud-ice.
- User Services
- Posts: 1437
- Joined: Wed Sep 18, 2019 6:15 pm America/New_York
- Been thanked: 1 time
There is a qual_sst field which defines the quality level and a flags_sst which specify the flags set that are used in the determination of the quality bit.