[GRASS-SVN] r44850 - grass/trunk/imagery/i.modis.qc

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 3 22:29:54 EST 2011


Author: ychemin
Date: 2011-01-03 19:29:54 -0800 (Mon, 03 Jan 2011)
New Revision: 44850

Added:
   grass/trunk/imagery/i.modis.qc/mod13A2a.c
   grass/trunk/imagery/i.modis.qc/mod13A2b.c
   grass/trunk/imagery/i.modis.qc/mod13A2c.c
   grass/trunk/imagery/i.modis.qc/mod13A2d.c
   grass/trunk/imagery/i.modis.qc/mod13A2e.c
   grass/trunk/imagery/i.modis.qc/mod13A2f.c
   grass/trunk/imagery/i.modis.qc/mod13A2g.c
   grass/trunk/imagery/i.modis.qc/mod13A2h.c
   grass/trunk/imagery/i.modis.qc/mod13A2i.c
Modified:
   grass/trunk/imagery/i.modis.qc/i.modis.qc.html
   grass/trunk/imagery/i.modis.qc/main.c
Log:
Added support to MOD13A2 VI Quality

Modified: grass/trunk/imagery/i.modis.qc/i.modis.qc.html
===================================================================
--- grass/trunk/imagery/i.modis.qc/i.modis.qc.html	2011-01-04 00:59:46 UTC (rev 44849)
+++ grass/trunk/imagery/i.modis.qc/i.modis.qc.html	2011-01-04 03:29:54 UTC (rev 44850)
@@ -1,6 +1,6 @@
 <H2>DESCRIPTION</H2>
 
-<EM>i.modis.qc</EM> Extracts Requested Quality Assessment flags from the following Modis products: MOD09A1, MOD09Q1 and MOD11A2. This does include MOD09A1 QA_state_500m layer (see Notes).
+<EM>i.modis.qc</EM> Extracts Requested Quality Assessment flags from the following Modis products: MOD09A1, MOD09Q1, MOD11A1, MOD11A2, MOD13A2. This does include MOD09A1 QA_state_500m layer (see Notes).
 
 <pre>
 <EM>MOD09A1/Q1: MODLAND QA Bits. bits=[0-1]</EM>
@@ -244,8 +244,96 @@
  <li>[1]= class 1: No snow</li>
 </ul>
 
+<pre>
+<EM>MOD13A2: Mandatory QA Flags 1Km bits[0-1]</EM>
+</pre>
+<ul>
+ <li>[00]= class 0: VI produced, good quality</li>
+ <li>[01]= class 1: VI produced, but check other QA</li>
+ <li>[10]= class 2: Pixel produced, but most probably cloud</li>
+ <li>[11]= class 3: Pixel not produced due to other reasons than clouds</li>
+</ul>
 
+<pre>
+<EM>MOD13A2: VI Usefulness Flag bits[2-5]</EM>
+</pre>
+<ul>
+ <li>[0000]= class 0: Highest quality</li>
+ <li>[0001]= class 1: Lower quality</li>
+ <li>[0010]= class 2: Decreasing quality</li>
+ <li>[0100]= class 3: Decreasing quality</li>
+ <li>[1000]= class 4: Decreasing quality</li>
+ <li>[1001]= class 5: Decreasing quality</li>
+ <li>[1010]= class 6: Decreasing quality</li>
+ <li>[1100]= class 7: Lowest quality</li>
+ <li>[1101]= class 8: Quality so low that it is not useful</li>
+ <li>[1110]= class 9: L1B data faulty</li>
+ <li>[1111]= class 10: Not useful for any other reason/not processed</li>
+<ul>
 
+<pre>
+<EM>MOD13A2: Aerosol quantity Flags 1Km bits[6-7]</EM>
+<ul>
+ <li>[00]= class 0: Climatology</li>
+ <li>[01]= class 1: Low</li>
+ <li>[10]= class 2: Average</li>
+ <li>[11]= class 3: High</li>
+</ul>
+
+<pre>
+<EM>MOD13A2: Adjacent cloud detected 1Km bit[8]</EM>
+</pre>
+<ul>
+ <li>[00]= class 0: No</li>
+ <li>[01]= class 1: Yes</li>
+</ul>
+
+<pre>
+<EM>MOD13A2: Atmosphere BRDF correction performed 1Km bit[9]</EM>
+</pre>
+<ul>
+ <li>[00]= class 0: No</li>
+ <li>[01]= class 1: Yes</li>
+</ul>
+
+<pre>
+<EM>MOD13A2: Mixed clouds 1Km bit[10]</EM>
+</pre>
+<ul>
+ <li>[00]= class 0: No</li>
+ <li>[01]= class 1: Yes</li>
+</ul>
+
+<pre>
+<EM>MOD13A2: Land/Water Flags 1Km bits[11-13]</EM>
+</pre>
+<ul>
+ <li>[000]= class 0: Shallow Ocean</li>
+ <li>[001]= class 1: Land (Nothing else but land)</li>
+ <li>[010]= class 2: Ocean Coastlines and lake shorelines</li>
+ <li>[011]= class 3: Shallow inland water</li>
+ <li>[100]= class 4: Ephemeral water</li>
+ <li>[101]= class 5: Deep inland water</li>
+ <li>[110]= class 6: Moderate or continental ocean</li>
+ <li>[111]= class 7: Deep ocean</li>
+</ul>
+
+<pre>
+<EM>MOD13A2: Possible Snow/Ice 1Km bits[14]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: No</li>
+ <li>[1]= class 1: Yes</li>
+</ul>
+
+<pre>
+<EM>MOD13A2: Possible Shadow 1Km bits[15]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: No</li>
+ <li>[1]= class 1: Yes</li>
+</ul> 
+
 <H2>NOTES</H2>
 In MOD09A1: It seems that cloud related info is not filled properly in the standard QC (MOD09A1 in this module) since version 3, State-QA 500m images (MOD09A1s in this module) should be used (see Vermote et al., 2008).<br>
 

Modified: grass/trunk/imagery/i.modis.qc/main.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/main.c	2011-01-04 00:59:46 UTC (rev 44849)
+++ grass/trunk/imagery/i.modis.qc/main.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -5,14 +5,18 @@
  * AUTHOR(S):    Yann Chemin - yann.chemin at gmail.com
  * PURPOSE:      Converts Quality Control indicators into human readable classes
  * 		 for Modis surface reflectance products 250m/500m
- * 		 (MOD09Q/MOD09A)
+ * 		 (MOD09Q/MOD09A), Modis LST (MOD11A1, MOD11A2), Modis Vegetation
+ *		 (MOD13A2)
  *
- * COPYRIGHT:    (C) 2008 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2008 -2011 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *   	    	 License (>=v2). Read the file COPYING that comes with GRASS
  *   	    	 for details.
- * 
+ *
+ * CHANGELOG:	 Added support MOD11A1 (Markus, December 2010)
+ *		 Added support MOD13A2 (Yann, January 2011)
+ *
  *****************************************************************************/
 
 
@@ -36,7 +40,7 @@
 CELL mod09A1c(CELL pixel, int bandno);
 CELL mod09A1d(CELL pixel);
 CELL mod09A1e(CELL pixel);
-    /* MOD09A1 Products (500m, 8Days, State QA) */
+    /* MOD09A1 Products (500m, 8-Days, State QA) */
 CELL mod09A1sa(CELL pixel);
 CELL mod09A1sb(CELL pixel);
 CELL mod09A1sc(CELL pixel);
@@ -61,6 +65,18 @@
 CELL mod11A2c(CELL pixel);
 CELL mod11A2d(CELL pixel);
 
+    /* MOD13A2 Products (1Km, 16-Days) */ 
+CELL mod13A2a (CELL pixel);
+CELL mod13A2b (CELL pixel);
+CELL mod13A2c (CELL pixel);
+CELL mod13A2d (CELL pixel);
+CELL mod13A2e (CELL pixel);
+CELL mod13A2f (CELL pixel);
+CELL mod13A2g (CELL pixel);
+CELL mod13A2h (CELL pixel);
+CELL mod13A2i (CELL pixel);
+
+
 int main(int argc, char *argv[]) 
 {
     struct Cell_head cellhd;	/*region+header info */
@@ -105,7 +121,8 @@
                             "mod09A1;surf. refl. 500m 8-days;"
                             "mod09A1s;surf. refl. 500m 8-days, State QA;"
                             "mod11A1;LST 1Km daily (Day/Night);"
-                            "mod11A2;LST 1Km 8-days (Day/Night);");
+                            "mod11A2;LST 1Km 8-days (Day/Night);"
+                            "mod13A2;VI 1Km 16-days;");
     input->answer = "mod09Q1";
 
     input1 = G_define_option();
@@ -138,7 +155,15 @@
                             "land_water;mod09A1s: StateQA Internal Snow Mask"
                             "mod35_snow_ice;mod09A1s: StateQA Internal Snow Mask"
                             "pixel_adjacent_to_cloud;mod09A1s: StateQA Internal Snow Mask"
-);
+			    "modland_qa_bits;mod13A2: MODIS Land General Quality Assessment"
+			    "vi_usefulness;mod13A2: Quality estimation of the pixel"
+			    "aerosol_quantity:mod13A2: Quantity range of Aerosol"
+			    "pixel_adjacent_to_cloud:mod13A2: if pixel is a cloud neighbour"
+			    "brdf_correction_performed:mod13A2: if BRDF correction performed"
+			    "mixed_clouds:mod13A2: if pixel mixed with clouds"
+			    "land_water: separate land from various water objects"
+			    "possible_snow_ice:mod13A2: if snow/ice present in pixel"
+			    "possible_shadow:mod13A2: if shadow is present in pixel");
     input1->answer = "modland_qa_bits";
 
     input2 = G_define_standard_option(G_OPT_R_INPUT);
@@ -177,7 +202,7 @@
 	bandno = atoi(input_band->answer);
 
     result = output->answer;
-
+    /*mod09Q1*/
     if ((!strcmp(qcflag, "cloud") && (strcmp(product, "mod09Q1"))) || 
 	(!strcmp(qcflag, "diff_orbit_from_500m") && (strcmp(product, "mod09Q1"))))
 	G_fatal_error(_("This flag is only available for MOD09Q1 @ 250m products"));
@@ -189,31 +214,38 @@
 	    G_fatal_error(_("mod09Q1 product only has 2 bands"));
     }
     
+    /*mod11A1*/
     if ((!strcmp(qcflag, "mandatory_qa") && (strcmp(product, "mod11A1"))) ||
         (!strcmp(qcflag, "data_quality_flag") && (strcmp(product, "mod11A1"))) ||
         (!strcmp(qcflag, "emis_error") && (strcmp(product, "mod11A1"))) ||
         (!strcmp(qcflag, "lst_error") && (strcmp(product, "mod11A1"))))
         G_fatal_error(_("This flag is only available for MOD11A1 @ 1Km products"));
-
+    /*mod11A2*/
     if ((!strcmp(qcflag, "mandatory_qa") && (strcmp(product, "mod11A2"))) || 
 	(!strcmp(qcflag, "data_quality_flag") && (strcmp(product, "mod11A2"))) ||
 	(!strcmp(qcflag, "emis_error") && (strcmp(product, "mod11A2"))) ||
 	(!strcmp(qcflag, "lst_error") && (strcmp(product, "mod11A2"))))
 	G_fatal_error(_("This flag is only available for MOD11A2 @ 1Km products"));
 
-    if ((!strcmp(qcflag, "aerosol_quantity") && (strcmp(product, "mod09A1s"))) || 
-	(!strcmp(qcflag, "brdf_correction_performed") && (strcmp(product, "mod09A1s"))) ||
+    /*mod09A1*/
+    if (
 	(!strcmp(qcflag, "cirrus_detected") && (strcmp(product, "mod09A1s"))) ||
 	(!strcmp(qcflag, "cloud_shadow") && (strcmp(product, "mod09A1s"))) ||
 	(!strcmp(qcflag, "cloud_state") && (strcmp(product, "mod09A1s"))) ||
 	(!strcmp(qcflag, "internal_cloud_algorithm") && (strcmp(product, "mod09A1s"))) ||
 	(!strcmp(qcflag, "internal_fire_algorithm") && (strcmp(product, "mod09A1s"))) ||
 	(!strcmp(qcflag, "internal_snow_mask") && (strcmp(product, "mod09A1s"))) ||
-	(!strcmp(qcflag, "land_water") && (strcmp(product, "mod09A1s"))) ||
-	(!strcmp(qcflag, "mod35_snow_ice") && (strcmp(product, "mod09A1s"))) ||
-	(!strcmp(qcflag, "pixel_adjacent_to_cloud") && (strcmp(product, "mod09A1s"))))
+	(!strcmp(qcflag, "mod35_snow_ice") && (strcmp(product, "mod09A1s"))))
 	G_fatal_error(_("This flag is only available for MOD09A1s @ 500m products"));
 
+    /*mod13A2*/
+    if ((!strcmp(qcflag, "vi_usefulness") && (strcmp(product, "mod13A2"))) ||
+        (!strcmp(qcflag, "mixed_clouds") && (strcmp(product, "mod13A2"))) ||
+        (!strcmp(qcflag, "possible_snow_ice") && (strcmp(product, "mod13A2"))) ||
+        (!strcmp(qcflag, "possible_shadow") && (strcmp(product, "mod13A2"))))
+        G_fatal_error(_("This flag is only available for MOD13A2 @ 1Km products"));
+
+
     infd = Rast_open_old(qcchan, "");
 
     Rast_get_cellhd(qcchan, "", &cellhd);
@@ -344,6 +376,36 @@
 		/*calculate mod09A1s internal snow mask flag  */ 
                     c = mod09A1sk(c);
             }
+            else if (!strcmp(product, "mod13A2"))
+            {
+                if (!strcmp(qcflag, "modland_qa")) 
+		/*calculate mod11A2 MODIS Land Quality flags  */ 
+                    c = mod13A2a(c);
+	        if (!strcmp(qcflag, "vi_usefulness"))
+		/*calculate mod13A2 estimate of vi usefulness flag  */ 
+                    c = mod13A2b(c);
+                if (!strcmp(qcflag, "aerosol_quantity")) 
+		/*calculate mod13A2 aerosol quantity range flag  */ 
+                    c = mod13A2c(c);
+	        if (!strcmp(qcflag, "pixel_adjacent_to_cloud")) 
+		/*calculate mod13A2 adjacent cloud detected flag  */ 
+                    c = mod13A2d(c);
+	        if (!strcmp(qcflag, "brdf_correction_performed")) 
+		/*calculate mod13A2 BRDF correction performed flag  */ 
+                    c = mod13A2e(c);
+	        if (!strcmp(qcflag, "mixed_clouds")) 
+		/*calculate mod13A2 pixel has clouds flag  */ 
+                    c = mod13A2f(c);
+	        if (!strcmp(qcflag, "land_water")) 
+		/*calculate mod13A2 land and water types screening flag  */ 
+                    c = mod13A2g(c);
+	        if (!strcmp(qcflag, "possible_snow_ice")) 
+		/*calculate mod13A2 possible presence of snow or ice flag  */ 
+                    c = mod13A2h(c);
+	        if (!strcmp(qcflag, "possible_shadow")) 
+		/*calculate mod13A2 possible presence of shadow flag  */ 
+                    c = mod13A2i(c);
+            }
 	    else
                 G_fatal_error(_("Unknown flag name, please check spelling"));
 

Added: grass/trunk/imagery/i.modis.qc/mod13A2a.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13A2a.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13A2a.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -0,0 +1,18 @@
+/* mod13A2 Mandatory QA Flags 1Km bits[0-1]
+ * 00 -> class 0: VI produced, good quality
+ * 01 -> class 1: VI produced, but check other QA
+ * 10 -> class 2: Pixel produced, but most probably cloud
+ * 11 -> class 3: Pixel not produced due to other reasons than clouds
+ */  
+
+#include <grass/raster.h>
+
+CELL mod13A2a (CELL pixel) 
+{
+    CELL qctemp;
+    qctemp = pixel & 0x03;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod13A2b.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13A2b.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13A2b.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -0,0 +1,27 @@
+/* mod13A2 VI Usefulness Flag bits[2-5]
+ * 0000 -> class 0: Highest quality
+ * 0001 -> class 1: Lower quality
+ * 0010 -> class 2: Decreasing quality
+ * 0100 -> class 3: Decreasing quality
+ * 1000 -> class 4: Decreasing quality
+ * 1001 -> class 5: Decreasing quality
+ * 1010 -> class 6: Decreasing quality
+ * 1100 -> class 7: Lowest quality
+ * 1101 -> class 8: Quality so low that it is not useful
+ * 1110 -> class 9: L1B data faulty
+ * 1111 -> class 10: Not useful for any other reason/not processed
+ */  
+
+#include <grass/raster.h>
+
+CELL mod13A2b(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 2;		/*bits [2-5] become [0-4] */
+    qctemp = pixel & 0x0F;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod13A2c.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13A2c.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13A2c.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -0,0 +1,20 @@
+/* mod13A2 Aerosol quantity Flags 1Km bits[6-7]
+ * 00 -> class 0: Climatology
+ * 01 -> class 1: Low
+ * 10 -> class 2: Average
+ * 11 -> class 3: High
+ */  
+
+#include <grass/raster.h>
+
+CELL mod13A2c (CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 6;		/*bits [6-7] become [0-1] */
+    qctemp = pixel & 0x03;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod13A2d.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13A2d.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13A2d.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -0,0 +1,18 @@
+/* mod13A2 Adjacent cloud detected 1Km bit[8]
+ * 00 -> class 0: No
+ * 01 -> class 1: Yes
+ */  
+
+#include <grass/raster.h>
+
+CELL mod13A2d (CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 8;		/*bit [8] becomes [0] */
+    qctemp = pixel & 0x01;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod13A2e.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13A2e.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13A2e.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -0,0 +1,18 @@
+/* mod13A2 Atmosphere BRDF correction performed 1Km bit[9]
+ * 00 -> class 0: No
+ * 01 -> class 1: Yes
+ */  
+
+#include <grass/raster.h>
+
+CELL mod13A2e (CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 9;		/*bit [9] becomes [0] */
+    qctemp = pixel & 0x01;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod13A2f.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13A2f.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13A2f.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -0,0 +1,18 @@
+/* mod13A2 Mixed clouds 1Km bit[10]
+ * 00 -> class 0: No
+ * 01 -> class 1: Yes
+ */  
+
+#include <grass/raster.h>
+
+CELL mod13A2f (CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 10;		/*bit [10] becomes [0] */
+    qctemp = pixel & 0x01;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod13A2g.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13A2g.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13A2g.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -0,0 +1,24 @@
+/* mod13A2 Land/Water Flags 1Km bits[11-13]
+ * 000 -> class 0: Shallow Ocean
+ * 001 -> class 1: Land (Nothing else but land)
+ * 010 -> class 2: Ocean Coastlines and lake shorelines
+ * 011 -> class 3: Shallow inland water
+ * 100 -> class 4: Ephemeral water
+ * 101 -> class 5: Deep inland water
+ * 110 -> class 6: Moderate or continental ocean
+ * 111 -> class 7: Deep ocean
+ */  
+
+#include <grass/raster.h>
+
+CELL mod13A2g (CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 11;		/*bits [11-13] become [0-2] */
+    qctemp = pixel & 0x07;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod13A2h.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13A2h.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13A2h.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -0,0 +1,18 @@
+/* mod13A2 Possible Snow/Ice 1Km bits[14]
+ * 0 -> class 0: No
+ * 1 -> class 1: Yes
+ */  
+
+#include <grass/raster.h>
+
+CELL mod13A2h(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 14;		/*bit [14] becomes [0] */
+    qctemp = pixel & 0x01;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod13A2i.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13A2i.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13A2i.c	2011-01-04 03:29:54 UTC (rev 44850)
@@ -0,0 +1,18 @@
+/* mod13A2 Possible Shadow 1Km bits[15]
+ * 0 -> class 0: No
+ * 1 -> class 1: Yes
+ */  
+
+#include <grass/raster.h>
+
+CELL mod13A2i (CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 15;		/*bit [15] becomes [0] */
+    qctemp = pixel & 0x01;
+    
+    return qctemp;
+}
+
+



More information about the grass-commit mailing list