# Presentation: 694028

## LDOPE QA Tools

- Sadashiva Devadiga (SSAI)
- MODIS LDOPE
- January 18, 2007

## Overview

- Introduction
- Summary of QA tools
- Command line syntax
- Application of tools
- Reading metadata and SDS attributes
- Reading L2G product
- Reading QA bits
- Filtering Science Data using QA information
- Creating Mosaic of Gridded products
- Simple SDS Math
- Creating coarse product
- Summary

## Introduction

- MODIS Land HDF-EOS Product format
- Metadata stored as global attributes
- Core metadata
- Archive metadata
- HDF-EOS Structural metadata
- Product specific attributes  (in some products)
- Science Data Sets
- Science Parameter datasets
- “500m Surface Reflectance Band 1”, . . .  in MOD09A1, “1 km 16 days NDVI” . . . in MOD13A2
- QA datasets
- “500m Surface Reflectance Data State” and “500m Surface Reflectance Band Quality” in MOD09A1
- “1 km 16 days VI Quality” in MOD13A2

## Introduction

- QA tools are developed with feedback from the MODIS Land ST
- Incorporate the scientific knowledge, experience and insights gained during the substantial MODLAND product development period
- QA Tools are generic and can be applied to any MODIS Land products
- Tools run at command line and use unix-like command syntax
- Output of the tools are HDF files or text files
- Tools are compatible with C4 and C5 data
- A subset of these tools are being distributed to the public from LPDAAC *(*_[http://edcdaac.usgs.gov/landdaac/tools/ldope/index.asp](http://edcdaac.usgs.gov/landdaac/tools/ldope/index.asp)__)_
- Available for following operating systems – Irix/Linux/Solaris/Windows
- Documentation available on installation and usage

## Summary of LDOPE QA Tools

## Summary of LDOPE QA Tools

## Command Line Syntax

- A tool consists of a command name followed by one or more arguments of these type
- arguments indicating certain processing parameters
- arguments that are input filenames.
- Command Format
- command_name	-argument_name=argument_value	filename(s)
- Common arguments and meaning
- -help		Print help message for the command.
- -help filename	Print valid values for the various command line 				arguments of this command.
- -sds		Input SDS names.
- -of		Output filename.
- -meta		Copy metadata from the input file to the output 				file.
- -bit		Bit numbers.
- -xy		Pixel location in sample and line number.
- -bn		band numbers.

## Example: Reading Metadata

- read_meta –core MOD11A2.A2001065.h20v10.005.2007002071908.hdf

- read_meta –arch MOD11A2.A2001065.h20v10.005.2007002071908.hdf

- read_meta –qa MOD09A1.A2000305.h19v10.005.2006330133549.hdf

- read_meta -m=INPUTPOINTER,PGEVERSION MOD09A1.A2000305.h20v10.005.2006330041025.hdf

## Example: Reading SDS Attributes

- read_sds_attributes MOD11A2.A2001065.h20v10.005.2007002071908.hdf

- read_sds_attributes -sds="1 km 16 days VI Quality"  MOD13A2.A200305.h20v10.005.2006330041025.hdf

## Example: Reading L2G

**Task**: Read one or more layers from a L2G compact format file
**Tool**: read_l2g
**Input**: L2G HDF file
**Output**: HDF file containing user requested layers from the input HDF file.
**Example**: Read the first two layers of surface reflectance for bands 1, 3, and 4 from the input L2G compact format file MOD09GHK.A2007001.h17v07.005.2007007183940.hdf
**Command**: read_l2g –layer=1,2 –sds=sur_refl_b01,sur_refl_b03,sur_refl_b04
- –of=Layers.MOD09GHK.A2007001.h17v07.005.2007007183940.hdf
-  MOD09GHK.A2007001.h17v07.005.2007007183940.hdf
**Result**: Output HDF file will contain six SDS
- 	sur_refl_b01_layer1
- 	sur_refl_b02_layer1
- 	sur_refl_b03_layer1
- 	sur_refl_b01_layer2
- 	sur_refl_b02_layer2
- 	sur_refl_b03_layer2

## Example: Reading L2G

- Layers.MOD09GHK.A2007001.h17v07.005.2007007183940.hdf

- RGB Composite of surface reflectance from bands 1, 3 and 4 – Layer 1

- RGB Composite of surface reflectance from bands 1, 3 and 4 – Layer 2

## Example: Reading L2G

**Task**: Read one or more granules from a L2G compact format file
**Tool**: read_l2g
**Input**: L2G HDF file (and the pointer file in case of C4)
**Output**: HDF file containing user requested layers from the input HDF file.
**Example**: Read surface reflectance for bands 1, 3, and 4 for all the granules in the input L2G compact format file MOD09GHK.A2007001.h17v07.005.2007007183940.hdf
**Command**: read_l2g –gpidx –sds=sur_refl_b01,sur_refl_b03,sur_refl_b04
- –of=Granules.MOD09GHK.A2007001.h17v07.005.2007007183940.hdf
- -ptr=MODPTHKM.A2007001.h17v07.005.2007007180905.hdf
-  MOD09GHK.A2007001.h17v07.005.2007007183940.hdf
**Result**: Output HDF file will contain 9 SDS (for this example)
- 	sur_refl_b01_gpnt1	sur_refl_b01_gnpt2 	 sur_refl_b01_gnpt3
- 	sur_refl_b02_gpnt1 	sur_refl_b01_gnpt2 	 sur_refl_b01_gnpt3
- 	sur_refl_b03_gpnt1 	sur_refl_b01_gnpt2 	 sur_refl_b01_gnpt3

## Example: Reading L2G

- Granules.MOD09GHK.A2007001.h17v07.005.2007007183940.hdf

- RGB Composite of surface reflectance from bands 1, 3 and 4

- Granule 1

- Granule 2

- Granule 3

## Example: Reading QA Information

**Task**: Decode the pixel level QA
**Tool**: unpack_sds_bits
**Input**: HDF file containing the QA SDS
**Output**: HDF file containing one or more SDS where each SDS corresponds to an user requested qa flag
**Example**: Decode the “aerosol flag”, “internal cloud mask”, “MOD35 cloud mask” and the “land water mask” from MOD09A
**Command**: Unpack_sds_bits –sds=sur_refl_state_500m –bit=0-1,3-5,6-7,10 –of= QA_MOD09A1.A2000305.h20v10.005.2006330041025.hdf MOD09A1.A2000305.h20v10.005.2006330041025.hdf
**Result**: Output HDF file will contain four SDS
- 	bit_0-1_sur_refl_state_500m
- 	bit_3-5_sur_refl_state_500m
- 	bit_6-7_sur_refl_state_500m
- 	bit_10_sur_refl_state_500m

## Example: Reading QA Information

- MOD09A1.A2000305.h20v10.005.2006330041025.hdf

- RGB Composite of surface reflectance from bands 1, 3 and 4

- Aerosol flag: Red (0): Climatology, green (1): low, sea green (2): average, high (3): yellow

## Example: Reading QA Information

- MOD09A1.A2000305.h20v10.005.2006330041025.hdf

- Internal Cloud Mask, green (0): clear, yellow (1): cloudy

- MOD35 Cloud Mask, green (0, 1): clear, yellow (2, 3): cloudy

## Example: Reading QA Information

- MOD09A1.A2000305.h20v10.005.2006330041025.hdf

- RGB Composite of surface reflectance from bands 1, 3 and 4

- Land water mask: Green (1): land, blue (2): coastline and shoreline, cyan (3, 5): inland water

## Example: Filtering Science Data Using pixel level QA

**Task**: Filter good quality surface reflectance from MOD09A1 over land where good quality is defined as observations flagged as “low to medium aerosol AND clear AND band quality is good”
**Tool**: mask_sds
**Input**: HDF file containing the SDS to be filtered and file containing QA SDS
**Output**: HDF file containing one or more SDS where observations are filtered by the user specified constraint.
**Example**: Mask or filter good quality observations from surface reflectance bands 1, 3, and 4 of MOD09A1.A2000305.h20v10.005.2006330041025.hdf
**Command**: mask_sds –sds=sur_refl_b01,sur_refl_b03,sur_refl_b04 –mask= “MOD09A1.A2000305.h20v10.005.2006330041025.hdf,sur_refl_state_500m,6-7>00,AND,*,*,6-7<11,AND,*,*,10==0,AND,*,*,3-5==001,AND,*,sur_refl_qc_500m,0-1==00”
- -of=Masked. MOD09A1.A2000305.h20v10.005.2006330041025.hdf MOD09A1.A2000305.h20v10.005.2006330041025.hdf
**Result**: Output HDF file will contain three SDS
- 	sur_refl_b01
- 	sur_refl_b02
- 	sur_refl_b03

## Example: Filtering Science Data Using pixel level QA

- MOD09A1.A2000305.h20v10.005.2006330041025.hdf

- RGB Composite of surface reflectance from bands 1, 3 and 4

- RGB Composite of surface reflectance from bands 1, 3 and 4. Red: fill value forced by the constraint filtering

## Example: Mosaic of Gridded Products

**Task**: Make a mosaic of two or more input gridded MODIS Land product
**Tool**: mosaic_sds
**Input**: HDF file
**Output**: HDF file containing the mosaic
**Example**: Make mosaics of NDVI and EVI over South Africa (tiles horizontal 19 – 21 and vertical 10-12) for day 2000305
**Command**: mosaic_sds –sds=“1 km 16 days NDVI,1 km 16 days EVI”
- –of=Mosaic.MOD13A2.A2000305.SA.005.hdf
- MOD13A2.A2000305.h19v10.005.2006330014908.hdf MOD13A2.A2000305.h19v11.005.2006330021418.hdf
- MOD13A2.A2000305.h19v12.005.2006330070823.hdf MOD13A2.A2000305.h20v10.005.2006329010717.hdf
- MOD13A2.A2000305.h20v11.005.2006329033507.hdf MOD13A2.A2000305.h20v12.005.2006330023220.hdf
- MOD13A2.A2000305.h21v10.005.2006330015405.hdf MOD13A2.A2000305.h21v11.005.2006330021629.hdf
**Result**: Output HDF file will contain two SDS
- 	1 km 16 days NDVI
- 	1 km 16 days EVI

## Example: Mosaic of Gridded Products

- Mosaic.MOD13A2.A2000305.SA.005.hdf

- 1 km 16 days NDVI

- 1 km 16 days EVI

## Example: Simple SDS Math

**Task**: Compute difference/sum/division  of two SDSs
**Tool**: math_sds
**Input**: HDF file
**Output**: HDF file containing the sds math result
**Example**: Compute the difference between day and night LST in MOD11A2.A2001065.h20v10.005.2007002071908.hdf
**Command**: math_sds –math=“LST_Day_1km, MOD11A2.A2001065.h20v10.005.2007002071908.hdf - LST_Night_1km, MOD11A2.A2001065.h20v10.005.2007002071908.hdf,INT16,0,0,-1,-2”
- -of=LST_Diff. MOD11A2.A2001065.h20v10.005.2007002071908.hdf
**Result**: Output HDF file will contain 1 SDS
- 	LST_Day_1km – LST_Night_1km

## Example: Simple SDS Math

- MOD11A2.A2001065.h20v10.005.2007002071908.hdf

- LST_Day_1km

- LST_Night_1km

- LST_Day_1km – LST_Night_1km

- Red: -ve, green 0 – 2K, yellow: 2 – 6K, purple > 6k

## Example: Making Coarse Products

**Task**: Make coarse resolution SDS from the full resolution SDS by sub sampling
**Tool**: reduce_sds
**Input**: HDF file containing full resolution SDS
**Output**: HDF file containing the coarse resolution SDS
**Example**: Create coarse resolution 5 km data sets by sub sampling the full resolution surface reflectance bands 1, 3, and 4 in MOD09A1.A2000305.h20v10.005.2006330041025.hdf
**Command**: reduce_sds –sub –rf=10 –sds=sur_refl_b01,sur_refl_b03,sur_refl_b04
- –of=CRS_SS. MOD09A1.A2000305.h20v10.005.2006330041025.hdf MOD09A1.A2000305.h20v10.005.2006330041025.hdf
**Result**: Output HDF file will contain 3 SDS
- 	sur_refl_b01
- 	sur_refl_b03
- 	sur_refl_b04

## Example: Making Coarse Products

- MOD09A1.A2000305.h20v10.005.2006330041025.hdf

- RGB Composite of surface reflectance from bands 1, 3 and 4

## Example: Making Coarse Products

**Task**: Make coarse resolution SDS from the full resolution SDS by averaging
**Tool**: reduce_sds
**Input**: HDF file containing full resolution SDS
**Output**: HDF file containing the coarse resolution SDS
**Example**: Create coarse resolution 5 km data sets by averaging the full resolution surface reflectance bands 1, 3, and 4 in MOD09A1.A2000305.h20v10.005.2006330041025.hdf
**Command**: reduce_sds –avg –rf=10 –sds=sur_refl_b01,sur_refl_b03,sur_refl_b04
- –of=CRS_SS. MOD09A1.A2000305.h20v10.005.2006330041025.hdf MOD09A1.A2000305.h20v10.005.2006330041025.hdf
**Result**: Output HDF file will contain 3 SDS
- 	sur_refl_b01
- 	sur_refl_b03
- 	sur_refl_b04

## Example: Making Coarse Products

- MOD09A1.A2000305.h20v10.005.2006330041025.hdf

- RGB Composite of surface reflectance from bands 1, 3 and 4

## Example: Making Coarse Products

**Task**: Make coarse resolution land cover product from the full resolution SDS by majority class
**Tool**: reduce_sds
**Input**: HDF file containing full resolution SDS
**Output**: HDF file containing the coarse resolution SDS
**Example**: Create coarse resolution 5 km land cover by majority voting from the full resolution land cover SDS in MOD12Q1.A2001001.h20v11.004.2004358134406.hdf
**Command**: reduce_sds –cl –rf=5 –sds=Land_Cover_Type1
- –of=CRS.MOD12Q1.A2001001.h20v11.004.2004358134406.hdf
- MOD12Q1.A2001001.h20v11.004.2004358134406.hdf
**Result**: Output HDF file will contain 3 SDS
- 	Land_Cover_Type1

## Example: Making Coarse Products

- MOD12Q1.A2001001.h20v11.004.2004358134406.hdf

- Water
- Open shrub lands
- croplands
- Broadleaf forest, mixed forest, closed shrub lands
- Savanna
- Deciduous needle leaf forest
- grassland

## Summary

- Fixing bugs
- New tools are under development – e.g. new l2g reader for C5
- User feedbacks/comments welcome