Ver código fonte

i.modis.qc: activate mod09CMG/mod09CMGs (https://trac.osgeo.org/grass/changeset/61754); minor fixes and msg cosmetics

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@61758 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 10 anos atrás
pai
commit
0c8e389520

+ 31 - 31
imagery/i.modis.qc/i.modis.qc.html

@@ -33,8 +33,8 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
  <li>[0000]= class 0: highest quality</li>
  <li>[0111]= class 1: noisy detector</li>
  <li>[1000]= class 2: dead detector; data interpolated in L1B</li>
- <li>[1001]= class 3: solar zenith ge 86 degrees</li>
- <li>[1010]= class 4: solar zenith ge 85 and lt 86 degrees</li>
+ <li>[1001]= class 3: solar zenith &ge; 86 degrees</li>
+ <li>[1010]= class 4: solar zenith &ge; 85 and &lt; 86 degrees</li>
  <li>[1011]= class 5: missing input</li>
  <li>[1100]= class 6: internal constant used in place of climatological data for at least one atmospheric constant</li>
  <li>[1101]= class 7: correction out of bounds, pixel constrained to extreme allowable value</li>
@@ -91,20 +91,20 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 <em>MOD11A1: Emis Error Flag bits=[4-5]</em>
 </pre>
 <ul>
- <li>[00]= class 0: Average emissivity error le 0.01</li>
- <li>[01]= class 1: Average emissivity error le 0.02</li>
- <li>[10]= class 2: Average emissivity error le 0.04</li>
- <li>[11]= class 3: Average emissivity error gt 0.04</li>
+ <li>[00]= class 0: Average emissivity error &le; 0.01</li>
+ <li>[01]= class 1: Average emissivity error &le; 0.02</li>
+ <li>[10]= class 2: Average emissivity error &le; 0.04</li>
+ <li>[11]= class 3: Average emissivity error &gt; 0.04</li>
 </ul>
 
 <pre>
 <em>MOD11A1: LST Error Flag bits=[6-7]</em>
 </pre>
 <ul>
- <li>[00]= class 0: Average LST error le 1</li>
- <li>[01]= class 1: Average LST error le 2</li>
- <li>[10]= class 2: Average LST error le 3</li> 
- <li>[11]= class 3: Average LST error gt 3</li>
+ <li>[00]= class 0: Average LST error &le; 1</li>
+ <li>[01]= class 1: Average LST error &le; 2</li>
+ <li>[10]= class 2: Average LST error &le; 3</li> 
+ <li>[11]= class 3: Average LST error &gt; 3</li>
 </ul>
 <pre>
 
@@ -131,20 +131,20 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 <em>MOD11A2: Emis Error Flag bits=[4-5]</em>
 </pre>
 <ul>
- <li>[00]= class 0: Average emissivity error le 0.01</li>
- <li>[01]= class 1: Average emissivity error le 0.02</li>
- <li>[10]= class 2: Average emissivity error le 0.04</li>
- <li>[11]= class 3: Average emissivity error gt 0.04</li>
+ <li>[00]= class 0: Average emissivity error &le; 0.01</li>
+ <li>[01]= class 1: Average emissivity error &le; 0.02</li>
+ <li>[10]= class 2: Average emissivity error &le; 0.04</li>
+ <li>[11]= class 3: Average emissivity error &gt; 0.04</li>
 </ul>
 
 <pre>
 <em>MOD11A2: LST Error Flag bits=[6-7]</em>
 </pre>
 <ul>
- <li>[00]= class 0: Average LST error le 1</li>
- <li>[01]= class 1: Average LST error le 2</li>
- <li>[10]= class 2: Average LST error le 3</li> 
- <li>[11]= class 3: Average LST error gt 3</li>
+ <li>[00]= class 0: Average LST error &le; 1</li>
+ <li>[01]= class 1: Average LST error &le; 2</li>
+ <li>[10]= class 2: Average LST error &le; 3</li> 
+ <li>[11]= class 3: Average LST error &gt; 3</li>
 </ul>
 
 <pre>
@@ -248,7 +248,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MOD13A2: Mandatory QA Flags 1Km bits[0-1]</em>
+<em>MOD13A2: Mandatory QA Flags 1km bits[0-1]</em>
 </pre>
 <ul>
  <li>[00]= class 0: VI produced, good quality</li>
@@ -275,7 +275,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MOD13A2: Aerosol quantity Flags 1Km bits[6-7]</em>
+<em>MOD13A2: Aerosol quantity Flags 1km bits[6-7]</em>
 </pre>
 <ul>
  <li>[00]= class 0: Climatology</li>
@@ -285,7 +285,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MOD13A2: Adjacent cloud detected 1Km bit[8]</em>
+<em>MOD13A2: Adjacent cloud detected 1km bit[8]</em>
 </pre>
 <ul>
  <li>[00]= class 0: No</li>
@@ -293,7 +293,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MOD13A2: Atmosphere BRDF correction performed 1Km bit[9]</em>
+<em>MOD13A2: Atmosphere BRDF correction performed 1km bit[9]</em>
 </pre>
 <ul>
  <li>[00]= class 0: No</li>
@@ -301,7 +301,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MOD13A2: Mixed clouds 1Km bit[10]</em>
+<em>MOD13A2: Mixed clouds 1km bit[10]</em>
 </pre>
 <ul>
  <li>[00]= class 0: No</li>
@@ -309,7 +309,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MOD13A2: Land/Water Flags 1Km bits[11-13]</em>
+<em>MOD13A2: Land/Water Flags 1km bits[11-13]</em>
 </pre>
 <ul>
  <li>[000]= class 0: Shallow Ocean</li>
@@ -323,7 +323,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MOD13A2: Possible Snow/Ice 1Km bits[14]</em>
+<em>MOD13A2: Possible Snow/Ice 1km bits[14]</em>
 </pre>
 <ul>
  <li>[0]= class 0: No</li>
@@ -331,7 +331,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MOD13A2: Possible Shadow 1Km bits[15]</em>
+<em>MOD13A2: Possible Shadow 1km bits[15]</em>
 </pre>
 <ul>
  <li>[0]= class 0: No</li>
@@ -340,7 +340,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 
 
 <pre>
-<em>MCD43B2: Albedo Quality Ancillary Platform Data 1Km bits[0-3]</em>
+<em>MCD43B2: Albedo Quality Ancillary Platform Data 1km bits[0-3]</em>
 <em>SDS: BRDF_Albedo_Ancillary</em>
 </pre>
 <ul>
@@ -352,7 +352,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MCD43B2: Albedo Quality Ancillary Land/Water Data 1Km bits[4-7]</em>
+<em>MCD43B2: Albedo Quality Ancillary Land/Water Data 1km bits[4-7]</em>
 <em>SDS: BRDF_Albedo_Ancillary</em>
 </pre>
 <ul>
@@ -369,7 +369,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 </ul>
 
 <pre>
-<em>MCD43B2: Albedo Quality Ancillary Sun Zenith Angle at Local Solar Noon Data 1Km bits[8-14]</em>
+<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>
@@ -378,7 +378,7 @@ MCD43B2. This does include MOD09A1 QA_state_500m layer (see Notes).
 
 
 <pre>
-<em>MCD43B2: Band-wise Albedo Quality Data 1Km</em>
+<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>
@@ -399,7 +399,7 @@ 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).
 
 <h2>TODO</h2>
-Add one Day products.
+Add more daily products.
 
 <h2>SEE ALSO</h2>
 

+ 115 - 29
imagery/i.modis.qc/main.c

@@ -8,7 +8,7 @@
  * 		 (MOD09Q/MOD09A), Modis LST (MOD11A1, MOD11A2), Modis Vegetation
  *		 (MOD13A2)
  *
- * COPYRIGHT:    (C) 2008 -2011 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2008 -2014 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
@@ -53,19 +53,39 @@ CELL mod09A1si(CELL pixel);
 CELL mod09A1sj(CELL pixel);
 CELL mod09A1sk(CELL pixel);
 
-    /* MOD11A1 Products (1Km, daily) */ 
+    /* MOD09CMG Products (5000m, daily) */
+CELL mod09CMGa(CELL pixel);
+CELL mod09CMGc(CELL pixel, int bandno);
+CELL mod09CMGd(CELL pixel);
+CELL mod09CMGe(CELL pixel);
+CELL mod09CMGia(CELL pixel);
+CELL mod09CMGib(CELL pixel);
+CELL mod09CMGic(CELL pixel);
+CELL mod09CMGid(CELL pixel);
+CELL mod09CMGie(CELL pixel);
+CELL mod09CMGif(CELL pixel);
+CELL mod09CMGig(CELL pixel);
+CELL mod09CMGih(CELL pixel);
+CELL mod09CMGii(CELL pixel);
+CELL mod09CMGij(CELL pixel);
+CELL mod09CMGik(CELL pixel);
+CELL mod09CMGil(CELL pixel);
+CELL mod09CMGim(CELL pixel);
+CELL mod09CMGin(CELL pixel);
+
+    /* MOD11A1 Products (1km, daily) */ 
 CELL mod11A1a(CELL pixel);
 CELL mod11A1b(CELL pixel);
 CELL mod11A1c(CELL pixel);
 CELL mod11A1d(CELL pixel);
 
-    /* MOD11A2 Products (1Km, 8-Days) */ 
+    /* MOD11A2 Products (1km, 8-Days) */ 
 CELL mod11A2a(CELL pixel);
 CELL mod11A2b(CELL pixel);
 CELL mod11A2c(CELL pixel);
 CELL mod11A2d(CELL pixel);
 
-    /* MOD13A2 Products (1Km, 16-Days) */ 
+    /* MOD13A2 Products (1km, 16-Days) */ 
 CELL mod13A2a (CELL pixel);
 CELL mod13A2b (CELL pixel);
 CELL mod13A2c (CELL pixel);
@@ -76,7 +96,7 @@ CELL mod13A2g (CELL pixel);
 CELL mod13A2h (CELL pixel);
 CELL mod13A2i (CELL pixel);
 
-    /* MCD43B2 Products (1Km, 8-Days)*/
+    /* MCD43B2 Products (1km, 8-Days)*/
 
 /* SDS: BRDF_Albedo_Ancilliary */
 CELL mcd43B2a(CELL pixel);
@@ -106,7 +126,7 @@ int main(int argc, char *argv[])
     int outfd;
     char *product;
     char *qcchan;
-    int bandno;
+    int bandno=0;
     CELL *inrast;
     CELL *outrast;
     RASTER_MAP_TYPE data_type_output = CELL_TYPE;
@@ -122,7 +142,7 @@ int main(int argc, char *argv[])
     G_add_keyword(_("vegetation"));
     G_add_keyword(_("MODIS"));
     module->description =
-	_("Extracts quality control parameters from Modis QC layers.");
+	_("Extracts quality control parameters from MODIS QC layers.");
 
     /* Define the different options */ 
     input = G_define_standard_option(G_OPT_R_INPUT);
@@ -144,6 +164,8 @@ int main(int argc, char *argv[])
 	       "mod09Q1;%s;"
 	       "mod09A1;%s;"
 	       "mod09A1s;%s;"
+	       "mod09CMG;%s;"
+	       "mod09CMGs;%s;"
 	       "mod11A1;%s;"
 	       "mod11A2;%s;"
 	       "mod13A2;%s;"
@@ -152,13 +174,15 @@ int main(int argc, char *argv[])
 	       _("surf. refl. 250m 8-days"),
 	       _("surf. refl. 500m 8-days"),
 	       _("surf. refl. 500m 8-days, State QA"),
-	       _("LST 1Km daily (Day/Night)"),
-	       _("LST 1Km 8-days (Day/Night)"),
-	       _("VI 1Km 16-days"),
-	       _("Brdf-Albedo Quality (Ancillary SDS) 1Km 8-days"),
-	       _("Brdf-Albedo Quality (BRDF SDS) 1Km 8-days"));
+	       _("surf. refl. 5000m daily"),
+	       _("surf. refl. 5000m daily, State QA"),
+	       _("LST 1km daily (Day/Night)"),
+	       _("LST 1km 8-days (Day/Night)"),
+	       _("VI 1km 16-days"),
+	       _("Brdf-Albedo Quality (Ancillary SDS) 1km 8-days"),
+	       _("Brdf-Albedo Quality (BRDF SDS) 1km 8-days"));
     productname->descriptions = desc_productname;
-    productname->options = "mod09Q1,mod09A1,mod09A1s,mod11A1,mod11A2,mod13A2,mcd43B2,mcd43B2q";
+    productname->options = "mod09Q1,mod09A1,mod09A1s,mod09CMG,mod09CMGs,mod11A1,mod11A2,mod13A2,mcd43B2,mcd43B2q";
     productname->answer = "mod13A2";
     
     qcname = G_define_option();
@@ -220,17 +244,17 @@ int main(int argc, char *argv[])
 	       _("mod11A2: Average Emissivity Error Classes"),
 	       _("mod11A2: MODIS Land General Quality Assessment"),
 	       _("mod11A2: Average LST Error Classes"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
-	       _("mod09A1s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
+	       _("mod09*s: StateQA Internal Snow Mask"),
 	       _("mod13A2: MODIS Land General Quality Assessment"),
 	       _("mod13A2: Quality estimation of the pixel"),
 	       _("mod13A2: Quantity range of Aerosol"),
@@ -253,7 +277,7 @@ int main(int argc, char *argv[])
     input_band->type = TYPE_STRING;
     input_band->required = NO;
     input_band->description =
-      _("Band number of Modis product (mod09Q1=[1,2],mod09A1=[1-7], mcd43B2q=[1-7])");
+      _("Band number of MODIS product (mod09Q1=[1,2],mod09A1=[1-7], mcd43B2q=[1-7])");
     desc_input_band = NULL;
     G_asprintf(&desc_input_band,
                "1;%s;2;%s;3;%s;4;%s;5;%s;6;%s;7;%s",
@@ -282,7 +306,7 @@ int main(int argc, char *argv[])
     /*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"));
+	G_fatal_error(_("This bit flag is only available for MOD09Q1 @ 250m products"));
 
     if (!strcmp(qcflag, "data_quality")) {
 	if (bandno < 1 || bandno > 7)
@@ -299,20 +323,30 @@ int main(int argc, char *argv[])
 	(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"));
+	G_fatal_error(_("This bit flag is only available for MOD09A1s @ 500m products"));
+
+    /*mod09CMG*/
+    if ((strcmp(qcflag, "cirrus_detected") && !(strcmp(product, "mod09CMGi"))) ||
+	(strcmp(qcflag, "cloud_shadow") && !(strcmp(product, "mod09CMGi"))) ||
+	(strcmp(qcflag, "cloud_state") && !(strcmp(product, "mod09CMGi"))) ||
+	(strcmp(qcflag, "internal_cloud_algorithm") && !(strcmp(product, "mod09CMGi"))) ||
+	(strcmp(qcflag, "internal_fire_algorithm") && !(strcmp(product, "mod09CMGi"))) ||
+	(strcmp(qcflag, "internal_snow_mask") && !(strcmp(product, "mod09CMGi"))) ||
+	(strcmp(qcflag, "mod35_snow_ice") && !(strcmp(product, "mod09CMGi"))))
+	G_fatal_error(_("This bit flag is only available for mod09CMGi @ 5000m 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"));
+        G_fatal_error(_("This bit 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"));
+        G_fatal_error(_("This bit flag is only available for MCD43B2 @ 1km products"));
 
      /*mcd43B2q*/
     if (strcmp(product, "mcd43B2q") && (bandno < 1 || bandno > 7))
@@ -382,6 +416,21 @@ int main(int argc, char *argv[])
                 /*calculate different orbit from 500m flag  */ 
                     c = mod09Q1f(c);
             }
+            else if (!strcmp(product, "mod09CMG"))
+            {
+	        if (!strcmp(qcflag, "modland_qa")) 
+		/*calculate modland QA bits extraction  */ 
+		    c = mod09CMGa(c);
+	        if (!strcmp(qcflag, "data_quality"))
+		/*calculate modland QA bits extraction  */ 
+		    c = mod09CMGc(c, bandno);
+	        if (!strcmp(qcflag, "atcorr")) 
+		/*calculate atmospheric correction flag  */ 
+		    c = mod09CMGd(c);
+	        if (!strcmp(qcflag, "adjcorr")) 
+		/*calculate adjacency correction flag  */ 
+		    c = mod09CMGe(c);
+	    }
             else if (!strcmp(product, "mod11A1"))
             {
                 if (!strcmp(qcflag, "mandatory_qa"))
@@ -448,6 +497,43 @@ int main(int argc, char *argv[])
 		/*calculate mod09A1s internal snow mask flag  */ 
                     c = mod09A1sk(c);
             }
+            else if (!strcmp(product, "mod09CMGs"))
+            {
+	        /* NOTE: we simply reuse the MOD09A1s functions - TODO: check if appropriate */
+	        if (!strcmp(qcflag, "cloud_state"))
+		/*calculate mod09A1s cloud state flag  */ 
+                    c = mod09A1sa(c);
+	        if (!strcmp(qcflag, "cloud_shadow")) 
+		/*calculate mod09A1s cloud shadow flag  */ 
+                    c = mod09A1sb(c);
+	        if (!strcmp(qcflag, "land_water")) 
+		/*calculate mod09A1s land/water flag  */ 
+                    c = mod09A1sc(c);
+	        if (!strcmp(qcflag, "aerosol_quantity")) 
+		/*calculate mod09A1s aerosol quantity flag  */ 
+                    c = mod09A1sd(c);
+	        if (!strcmp(qcflag, "cirrus_detected")) 
+		/*calculate mod09A1s cirrus detected flag  */ 
+                    c = mod09A1se(c);
+	        if (!strcmp(qcflag, "internal_cloud_algorithm")) 
+		/*calculate mod09A1s internal cloud algorithm flag  */ 
+                    c = mod09A1sf(c);
+	        if (!strcmp(qcflag, "internal_fire_algorithm")) 
+		/*calculate mod09A1s internal fire algorithm flag  */ 
+                    c = mod09A1sg(c);
+	        if (!strcmp(qcflag, "mod35_snow_ice")) 
+		/*calculate mod09A1s MOD35 snow/ice flag  */ 
+                    c = mod09A1sh(c);
+	        if (!strcmp(qcflag, "pixel_adjacent_to_cloud")) 
+		/*calculate mod09A1s pixel adjacent to cloud flag  */ 
+                    c = mod09A1si(c);
+	        if (!strcmp(qcflag, "brdf_correction_performed")) 
+		/*calculate mod09A1s BRDF correction performed flag  */ 
+                    c = mod09A1sj(c);
+	        if (!strcmp(qcflag, "internal_snow_mask")) 
+		/*calculate mod09A1s internal snow mask flag  */ 
+                    c = mod09A1sk(c);
+            }
             else if (!strcmp(product, "mod13A2"))
             {
                 if (!strcmp(qcflag, "modland_qa")) 

+ 1 - 1
imagery/i.modis.qc/mod09CMGii.c

@@ -5,7 +5,7 @@
 
 #include <grass/raster.h>
 
-CELL mod09A1ii(CELL pixel) 
+CELL mod09CMGii(CELL pixel) 
 {
     CELL qctemp;