Commits
cpkrehbiel authored 0ae7585b212
598 598 | *** |
599 599 | # 4. Quality Filtering |
600 600 | #### This section demonstrates how to decode bit values, determine which values to keep and which values to mask, and how to apply masks to the VNP09GA data arrays. Begin by importing the Quality Flag 5 from the VNP09GA HDF-EOS5 file. |
601 601 | |
602 602 | |
603 603 | ```python |
604 604 | qf = f[[a for a in all_datasets if 'QF5' in a][0]][()] # Import QF5 SDS |
605 605 | ``` |
606 606 | |
607 607 | #### Surface Reflectance Quality Flag QF5 contains an overall quality determination (good/bad) for each 1 km surface reflectance band (M1-M7). |
608 - | ![Table 14. Surface Reflectance Quality Flags (QF5).](https://git.earthdata.nasa.gov/projects/LPDUR/repos/nasa_viirs_surfacereflectance/raw/VNP09GA.001_QF5_Table.png?at=refs%2Fheads%2Fmasin) |
608 + | ![Table 14. Surface Reflectance Quality Flags (QF5).](https://git.earthdata.nasa.gov/projects/LPDUR/repos/nasa_viirs_surfacereflectance/raw/VNP09GA.001_QF5_Table.png?at=refs%2Fheads%2Fmain) |
609 609 | #### Above are the bit field mappings for Quality Flag layer 5. This table can also be found in the [VIIRS SR Version 1.6 User Guide](https://lpdaac.usgs.gov/documents/124/VNP09_User_Guide_V1.6.pdf ) under Section 3.3, Table 14 (pp. 34-35). Below, use the 4th, 5th, 6th, and 7th bits to assure that the overall quality for the bands used in this example (M3, M4, M5, M7) are set to 0, or Good. |
610 610 | <div class="alert alert-block alert-warning" > |
611 611 | <b>Note: Remember that bits are read from right to left (bit 0 is the Least Significant Bit).</b> |
612 612 | </div> |
613 613 | |
614 614 | *** |
615 615 | ## 4a. Decode Bit Values |
616 616 | #### Below, set the number of bits and create a list of all possible combinations (bit values). Based on the table above, only include pixels where the QF5 layer values are equal to 0 for bit numbers 4-7, meaning that the overall quality for bands M3-M5 and M7 are set to Good. |
617 617 | |
618 618 | |
675 675 | |
676 676 | |
677 677 | ```python |
678 678 | # Apply mask to each SR SDS based on the qf layer and the list of good quality values generated above |
679 679 | red = np.ma.MaskedArray(red, np.in1d(qf, goodQF, invert = True)) |
680 680 | green = np.ma.MaskedArray(green, np.in1d(qf, goodQF, invert = True)) |
681 681 | blue = np.ma.MaskedArray(blue, np.in1d(qf, goodQF, invert = True)) |
682 682 | nir = np.ma.MaskedArray(nir, np.in1d(qf, goodQF, invert = True)) |
683 683 | ``` |
684 684 | |
685 - | #### Below, run through the same steps as above, this time using the Surface Reflectance Quality Flag QF2, which contains a land/water mask that can be used to mask out water pixels in the surface reflectance arrays. More information on QF2 can be found in Section 3.3, Table 11 (pp. 32-33) in the [VIIRS SR Version 1.6 User Guide](https://lpdaac.usgs.gov/documents/124/VNP09_User_Guide_V1.6.pdf). |
685 + | #### Below, run through the same steps as above, this time using the Surface Reflectance Quality Flag QF2, which contains a land/water mask that can be used to mask out water pixels in the surface reflectance arrays. More information on QF2 can be found in Section 3.3, Table 11 (pp. 32-33) in the [VIIRS SR Version 1.6 User Guide](https://lpdaac.usgs.gov/documents/124/VNP09_User_Guide_V1.6.pdf). |
686 686 | |
687 687 | |
688 688 | ```python |
689 689 | qf2 = f[[a for a in all_datasets if 'QF2' in a][0]][()] # Import QF5 SDS |
690 690 | land = [] # Create an empty list used to store bit values classified as land |
691 691 | ``` |
692 692 | |
693 693 | #### Below, exclude each value where bits 0-2 are classified as: |
694 694 | > 010: Inland water |
695 695 | 011: Sea Water |