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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 4 22:58:08 EST 2011


Author: ychemin
Date: 2011-01-04 19:58:08 -0800 (Tue, 04 Jan 2011)
New Revision: 44876

Modified:
   grass/trunk/imagery/i.modis.qc/i.modis.qc.html
   grass/trunk/imagery/i.modis.qc/main.c
Log:
Added support for MCD43B2

Modified: grass/trunk/imagery/i.modis.qc/i.modis.qc.html
===================================================================
--- grass/trunk/imagery/i.modis.qc/i.modis.qc.html	2011-01-05 00:27:04 UTC (rev 44875)
+++ grass/trunk/imagery/i.modis.qc/i.modis.qc.html	2011-01-05 03:58:08 UTC (rev 44876)
@@ -1,6 +1,6 @@
 <H2>DESCRIPTION</H2>
 
-<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).
+<EM>i.modis.qc</EM> Extracts Requested Quality Assessment flags from the following Modis products: MOD09A1, MOD09Q1, MOD11A1, MOD11A2, MOD13A2, MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 
 <pre>
 <EM>MOD09A1/Q1: MODLAND QA Bits. bits=[0-1]</EM>
@@ -334,6 +334,61 @@
  <li>[1]= class 1: Yes</li>
 </ul> 
 
+
+<pre>
+<EM>MCD43B2: Albedo Quality Ancillary Platform Data 1Km bits[0-3]</EM>
+<EM>SDS: BRDF_Albedo_Ancillary</EM>
+</pre>
+<ul>
+ <li>[0000]= class 0: Satellite Platform: Terra</li>
+ <li>[0001]= class 1: Satellite Platform: Terrra/Aqua</li>
+ <li>[0010]= class 2: Satellite Platform: Aqua</li>
+ <li>[1111]= class 15: Fill Value</li>
+ <li>Classes 3-14: Not used</li>
+</ul>
+
+<pre>
+<EM>MCD43B2: Albedo Quality Ancillary Land/Water Data 1Km bits[4-7]</EM>
+<EM>SDS: BRDF_Albedo_Ancillary</EM>
+</pre>
+<ul>
+ <li>[0000] class 0: Shallow Ocean</li>
+ <li>[0001] class 1: Land (Nothing else but land)</li>
+ <li>[0010] class 2: Ocean and lake shorelines</li>
+ <li>[0011] class 3: Shallow inland water</li>
+ <li>[0100] class 4: Ephemeral water</li>
+ <li>[0101] class 5: Deep inland water</li>
+ <li>[0110] class 6: Moderate or continental ocean</li>
+ <li>[0111] class 7: Deep ocean</li>
+ <li>[1111] class 15: Fill Value</li>
+ <li>Classes 8-14: Not used</li>
+</ul>
+
+<pre>
+<EM>MCD43B2: Albedo Quality Ancillary Sun Zenith Angle at Local Solar Noon Data 1Km bits[8-14]</EM>
+<EM>SDS: BRDF_Albedo_Ancillary</EM>
+</pre>
+<ul>
+   Returns integer value [0-90], 127 is Fill Value
+</ul>
+
+
+<pre>
+<EM>MCD43B2: Band-wise Albedo Quality Data 1Km</EM>
+<EM>SDS: BRDF_Albedo_Band_Quality</EM>
+</pre>
+bits[0-3][4-7][8-11][12-15][16-19][20-23][24-27]<br>
+<ul>
+ <li>[0000]= class 0: best quality, 75% or more with best full inversions</li>
+ <li>[0001]= class 1: good quality, 75% or more with full inversions</li>
+ <li>[0010]= class 2: Mixed, 50% or less full inversions and 25% or less fill values</li> 
+ <li>[0011]= class 3: All magnitude inversions or 50% or less fill values</li> 
+ <li>[0100]= class 4: 75% or more fill values</li> 
+ <li>Classes 5-14: Not Used</li>
+ <li>[1111]= class 15: Fill Value</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-05 00:27:04 UTC (rev 44875)
+++ grass/trunk/imagery/i.modis.qc/main.c	2011-01-05 03:58:08 UTC (rev 44876)
@@ -15,7 +15,7 @@
  *   	    	 for details.
  *
  * CHANGELOG:	 Added support MOD11A1 (Markus, December 2010)
- *		 Added support MOD13A2 (Yann, January 2011)
+ *		 Added support MOD13A2, MCD43B2 (Yann, January 2011)
  *
  *****************************************************************************/
 
@@ -76,7 +76,17 @@
 CELL mod13A2h (CELL pixel);
 CELL mod13A2i (CELL pixel);
 
+    /* MCD43B2 Products (1Km, 8-Days)*/
 
+/* SDS: BRDF_Albedo_Ancilliary */
+CELL mcd43B2a(CELL pixel);
+CELL mcd43B2b(CELL pixel);
+CELL mcd43B2c(CELL pixel);
+
+/* SDS: BRDF_Albedo_Band_Quality */
+CELL mcd43B2qa(CELL pixel, int bandno);
+
+
 int main(int argc, char *argv[]) 
 {
     struct Cell_head cellhd;	/*region+header info */
@@ -124,7 +134,10 @@
                             "mod09A1s;surf. refl. 500m 8-days, State QA;"
                             "mod11A1;LST 1Km daily (Day/Night);"
                             "mod11A2;LST 1Km 8-days (Day/Night);"
-                            "mod13A2;VI 1Km 16-days;");
+                            "mod13A2;VI 1Km 16-days;"
+                            "mcd43B2;Brdf-Albedo Quality (Ancillary SDS) 1Km 8-days;"
+                            "mcd43B2q;Brdf-Albedo Quality (BRDF SDS) 1Km 8-days;"
+			    );
     input->answer = "mod13A2";
 
     input1 = G_define_option();
@@ -159,13 +172,18 @@
                             "pixel_adjacent_to_cloud;mod09A1s: StateQA Internal Snow Mask"
 			    "modland_qa;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");
+			    "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;mod13A2: 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"
+			    "platform;mcd43B2: Quality of BRDF correction performed"
+			    "land_water;mcd43B2: Quality of BRDF correction performed"
+			    "sun_z_angle_at_local_noon;mcd43B2: Quality of BRDF correction performed"
+			    "brdf_correction_performed;mcd43B2q: Quality of BRDF correction performed"
+			    );
     input1->answer = "modland_qa";
 
     input2 = G_define_standard_option(G_OPT_R_INPUT);
@@ -178,14 +196,14 @@
     input_band->required = NO;
     input_band->gisprompt = "old,value";
     input_band->description =
-	_("Band number of Modis product mod09Q1=[1,2],mod09A1=[1-7]");
-    input_band->descriptions =_("1;mod09Q1/A1 Band 1: Red;"
-                                "2;mod09Q1/A1 Band 2: NIR;"
-                                "3;mod09A1 Band 3: Blue;"
-                                "4;mod09A1 Band 4: Green;"
-                                "5;mod09A1 Band 5: SWIR 1;"
-                                "6;mod09A1 Band 6: SWIR 2;"
-                                "7;mod09A1 Band 7: SWIR 3;");
+	_("Band number of Modis product mod09Q1=[1,2],mod09A1=[1-7], mcd43B2q=[1-7]");
+    input_band->descriptions =_("1;Band 1: Red;"
+                                "2;Band 2: NIR;"
+                                "3;Band 3: Blue;"
+                                "4;Band 4: Green;"
+                                "5;Band 5: SWIR 1;"
+                                "6;Band 6: SWIR 2;"
+                                "7;Band 7: SWIR 3;");
 
     output = G_define_standard_option(G_OPT_R_OUTPUT);
     output->key = "output";
@@ -204,9 +222,10 @@
 	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"))))
+    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"));
 
     if (!strcmp(qcflag, "data_quality")) {
@@ -216,38 +235,33 @@
 	    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"));
-
     /*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, "mod35_snow_ice") && (strcmp(product, "mod09A1s"))))
+    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, "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"))))
+    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"));
 
+    /*mcd43B2*/
+    if ((strcmp(qcflag, "platform") && !(strcmp(product, "mcd43B2"))) ||
+        (strcmp(qcflag, "land_water") && !(strcmp(product, "mcd43B2"))) ||
+        (strcmp(qcflag, "sun_z_angle_at_local_noon") && !(strcmp(product, "mcd43B2"))))
+        G_fatal_error(_("This flag is only available for MCD43B2 @ 1Km products"));
 
+     /*mcd43B2q*/
+    if (strcmp(product, "mcd43B2q") && (bandno < 1 || bandno > 7))
+	    G_fatal_error(_("Band number out of allowed range [1-7]"));
+
     infd = Rast_open_old(qcchan, "");
 
     Rast_get_cellhd(qcchan, "", &cellhd);
@@ -408,8 +422,30 @@
 		/*calculate mod13A2 possible presence of shadow flag  */ 
                     c = mod13A2i(c);
             }
+            else if (!strcmp(product, "mcd43B2"))
+            {
+	        if (!strcmp(qcflag, "platform")) 
+		/*calculate mcd43B2: SDS: BRDF_Albedo_Ancillary */
+		/* Satellite platform identification flag  */ 
+                    c = mcd43B2a(c);
+	        if (!strcmp(qcflag, "land_water")) 
+		/*calculate mcd43B2: SDS: BRDF_Albedo_Ancillary */
+		/* Land Water types in pixel flag  */ 
+                    c = mcd43B2b(c);
+	        if (!strcmp(qcflag, "sun_z_angle_at_local_noon")) 
+		/*calculate mcd43B2: SDS: BRDF_Albedo_Ancillary */
+		/* Sun Zenith Angle at Local Solar Noon flag  */ 
+                    c = mcd43B2c(c);
+            }
+            else if (!strcmp(product, "mcd43B2q"))
+            {
+	        if (!strcmp(qcflag, "brdf_correction_performed")) 
+		/*calculate mcd43B2: SDS: BRDF_Albedo_Band_Quality */
+		/* BRDF correction performed Quality flag  */ 
+                    c = mcd43B2qa(c, bandno);
+            }
 	    else
-                G_fatal_error(_("Unknown flag name, please check spelling"));
+                G_fatal_error(_("Unknown names and/or combination, please check spelling"));
 
 	    outrast[col] = c;
 	}



More information about the grass-commit mailing list