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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Apr 5 11:24:42 EDT 2009


Author: ychemin
Date: 2009-04-05 11:24:42 -0400 (Sun, 05 Apr 2009)
New Revision: 36590

Added:
   grass/trunk/imagery/i.modis.qc/mod09A1a.c
   grass/trunk/imagery/i.modis.qc/mod09A1c.c
   grass/trunk/imagery/i.modis.qc/mod09A1d.c
   grass/trunk/imagery/i.modis.qc/mod09A1e.c
   grass/trunk/imagery/i.modis.qc/mod09A1sa.c
   grass/trunk/imagery/i.modis.qc/mod09A1sb.c
   grass/trunk/imagery/i.modis.qc/mod09A1sc.c
   grass/trunk/imagery/i.modis.qc/mod09A1sd.c
   grass/trunk/imagery/i.modis.qc/mod09A1se.c
   grass/trunk/imagery/i.modis.qc/mod09A1sf.c
   grass/trunk/imagery/i.modis.qc/mod09A1sg.c
   grass/trunk/imagery/i.modis.qc/mod09A1sh.c
   grass/trunk/imagery/i.modis.qc/mod09A1si.c
   grass/trunk/imagery/i.modis.qc/mod09A1sj.c
   grass/trunk/imagery/i.modis.qc/mod09A1sk.c
   grass/trunk/imagery/i.modis.qc/mod09Q1a.c
   grass/trunk/imagery/i.modis.qc/mod09Q1b.c
   grass/trunk/imagery/i.modis.qc/mod09Q1c.c
   grass/trunk/imagery/i.modis.qc/mod09Q1d.c
   grass/trunk/imagery/i.modis.qc/mod09Q1e.c
   grass/trunk/imagery/i.modis.qc/mod09Q1f.c
   grass/trunk/imagery/i.modis.qc/mod11A2a.c
   grass/trunk/imagery/i.modis.qc/mod11A2b.c
   grass/trunk/imagery/i.modis.qc/mod11A2c.c
   grass/trunk/imagery/i.modis.qc/mod11A2d.c
Removed:
   grass/trunk/imagery/i.modis.qc/qc250a.c
   grass/trunk/imagery/i.modis.qc/qc250b.c
   grass/trunk/imagery/i.modis.qc/qc250c.c
   grass/trunk/imagery/i.modis.qc/qc250d.c
   grass/trunk/imagery/i.modis.qc/qc250e.c
   grass/trunk/imagery/i.modis.qc/qc250f.c
   grass/trunk/imagery/i.modis.qc/qc500a.c
   grass/trunk/imagery/i.modis.qc/qc500c.c
   grass/trunk/imagery/i.modis.qc/qc500d.c
   grass/trunk/imagery/i.modis.qc/qc500e.c
Modified:
   grass/trunk/imagery/i.modis.qc/i.modis.qc.html
   grass/trunk/imagery/i.modis.qc/main.c
Log:
Added MOD09A1 StateQA and MOD11A2 QC

Modified: grass/trunk/imagery/i.modis.qc/i.modis.qc.html
===================================================================
--- grass/trunk/imagery/i.modis.qc/i.modis.qc.html	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/i.modis.qc.html	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,11 +1,9 @@
 <H2>DESCRIPTION</H2>
 
-<EM>i.modis.qc</EM> Extracts Requested Quality Assessment flags from Modis 09 A and Q products 
-(Surface_reflectance_250/500m_quality_control_flags).
-This does not yet include QA_state_500m layer (see Notes and TODO).
+<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).
 
 <pre>
-<EM>MODLAND QA Bits 250m/500m bits[0-1]</EM>
+<EM>MOD09A1/Q1: MODLAND QA Bits. bits=[0-1]</EM>
 </pre>
 <ul>
  <li>[00]= class 0: Corrected product produced at ideal quality -- all bands</li>
@@ -15,7 +13,7 @@
 </ul>
 
 <pre>
-<EM>Cloud State 250m Unsigned Int bits[2-3] </EM>
+<EM>MOD09Q1: Cloud State. bits=[2-3] </EM>
 </pre>
 <ul>
  <li>[00]= class 0: Clear -- No clouds</li>
@@ -25,8 +23,8 @@
 </ul>
 
 <pre>
-<EM>Band-wise Data Quality 250m Unsigned Int bits[4-7][8-11]</EM>
-<EM>Band-wise Data Quality 500m long Int bits[2-5][6-9][10-13][14-17][18-21][22-25][26-29]</EM>
+<EM>MOD09Q1: Band-wise Data Quality 250m bits=[4-7][8-11]</EM>
+<EM>MOD09A1: Band-wise Data Quality 500m bits=[2-5][6-9][10-13][14-17][18-21][22-25][26-29]</EM>
 </pre>
 <ul>
  <li>[0000]= class 0: highest quality</li>
@@ -43,7 +41,7 @@
 </ul>
 
 <pre>
-<EM>Atmospheric correction 250m/500m bit[12]/[30]</EM>
+<EM>MOD09A1/Q1: Atmospheric correction bit=[12]/[30]</EM>
 </pre>
 <ul>
  <li>[0]= class 0: Not Corrected product</li>
@@ -51,7 +49,7 @@
 </ul>
 
 <pre>
-<EM>Adjacency correction 250m/500m bit[13][31]</EM>
+<EM>MOD09A1/Q1: Adjacency correction bit=[13]/[31]</EM>
 </pre>
 <ul>
  <li>[0]= class 0: Not Corrected product</li>
@@ -59,39 +57,180 @@
 </ul>
 
 <pre>
-<EM>Different orbit from 500m product, 250m Unsigned Int bit[14]</EM>
+<EM>MOD09Q1: Different orbit from 500m product, bit=[14]</EM>
 </pre>
 <ul>
  <li>[0]= class 0: same orbit as 500m</li>
  <li>[1]= class 1: different orbit from 500m</li>
 </ul>
 
+<pre>
+<EM>MOD11A2: Mandatory QA Flags bits=[0-1]</EM>
+</pre>
+<ul>
+ <li>[00]= class 0: LST produced, good quality, not necessary to examine more detailed QA</li>
+ <li>[01]= class 1: LST produced, other quality, recommend examination of more detailed QA</li>
+ <li>[10]= class 2: LST not produced due to cloud effects</li>
+ <li>[11]= class 3: LST not produced primarily due to reasons other than cloud</li>
+</ul>
 
+<pre>
+<EM>MOD11A2: Data Quality Flag bits=[2-3]</EM>
+</pre>
+<ul>
+ <li>[00]= class 0: Good data quality of L1B in 7 TIR bands</li>
+ <li>[01]= class 1: Other quality data</li>
+ <li>[10]= class 2: TBD</li>
+ <li>[11]= class 3: TBD</li>
+</ul>
+
+<pre>
+<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>
+</ul>
+
+<pre>
+<EM>MOD11A2: LST Error Flag bits=[4-5]</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>
+</ul>
+
+<pre>
+<EM>MOD09A1s: Cloud State bits=[0-1]</EM>
+</pre>
+<ul>
+ <li>[00]= class 0: clear</li>
+ <li>[01]= class 1: cloudy</li>
+ <li>[10]= class 2: mixed</li>
+ <li>[11]= class 3: not set, assumed clear</li>
+</ul>
+
+<pre>
+<EM>MOD09A1s: Cloud shadow bits=[2]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: yes</li>
+ <li>[1]= class 1: no</li>
+</ul>
+
+<pre>
+<EM>MOD09A1s: Land/Water Flag bits=[3-5]</EM>
+</pre>
+<ul>
+ <li>[000]= class 0: Shallow ocean</li>
+ <li>[001]= class 1: 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: Continental/moderate ocean</li>
+ <li>[111]= class 7: Deep ocean</li>
+</ul>
+
+<pre>
+<EM>MOD09A1s: Aerosol Quantity bits=[6-7]</EM>
+</pre>
+<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>MOD09A1s: Cirrus detected bits=[8-9]</EM>
+</pre>
+<ul>
+ <li>[00]= class 0: None</li>
+ <li>[01]= class 1: Small</li>
+ <li>[10]= class 2: Average</li>
+ <li>[11]= class 3: High</li>
+</ul>
+
+<pre>
+<EM>MOD09A1s: Internal Cloud Algorithm Flag bits=[10]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: Cloud</li>
+ <li>[1]= class 1: No cloud</li>
+</ul>
+
+<pre>
+<EM>MOD09A1s: Internal Fire Algorithm Flag bits=[11]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: Fire</li>
+ <li>[1]= class 1: No fire</li>
+</ul>
+
+<pre>
+<EM>MOD09A1s: MOD35 snow/ice flag bits=[12]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: Yes</li>
+ <li>[1]= class 1: No</li>
+</ul>
+
+<pre>
+<EM>MOD09A1s: Pixel adjacent to cloud bits=[13]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: Yes</li>
+ <li>[1]= class 1: No</li>
+</ul>
+
+<pre>
+<EM>MOD09A1s: BRDF correction performed bits=[14]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: Yes</li>
+ <li>[1]= class 1: No</li>
+</ul>
+
+<pre>
+<EM>MOD09A1s: Internal Snow Mask bits=[15]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: Snow</li>
+ <li>[1]= class 1: No snow</li>
+</ul>
+
+
+
 <H2>NOTES</H2>
-It seems that cloud related info is not filled properly since version 3.
-State-QA 500m images should be used (see Vermote et al., 2008).
+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>
 
 <H2>TODO</H2>
-STATE-QA500m flag Processing should be included for detailed cloud status. 
-More testing is required.
+Add one Day products.<br>
 
 <H2>SEE ALSO</H2>
-
-Vermote E.F., Kotchenova S.Y., Ray J.P.
-MODIS Surface Reflectance User's Guide.
-Version 1.2. June 2008.
-MODIS Land Surface Reflectance Science Computing Facility.
+<br>
+<A HREF="https://lpdaac.usgs.gov/lpdaac/products/modis_products_table">MODIS Products</A><br>
+<br>
+Vermote E.F., Kotchenova S.Y., Ray J.P.<br>
+MODIS Surface Reflectance User's Guide.<br>
+Version 1.2. June 2008.<br>
+MODIS Land Surface Reflectance Science Computing Facility.<br>
 <A HREF="http://modis-sr.ltdri.org">Homepage</A><br>
 
 
-<em>
+<EM>
 <A HREF="i.vi.html">i.vi</A><br>
-</em>
+</EM>
 
 
 <H2>AUTHORS</H2>
-Yann Chemin, International Rice Research Institute, The Philippines.<BR>
+Yann Chemin<BR>
 
 
 <p>
-<i>Last changed: $Date: 2008/07/28 15:33:42 $</i>
+<i>Last changed: $Date: 2009/04/05 15:09:33 $</i>

Modified: grass/trunk/imagery/i.modis.qc/main.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/main.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/main.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -22,20 +22,37 @@
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
-    /* 250m Products (MOD09Q) */ 
-CELL qc250a(CELL pixel);
-CELL qc250b(CELL pixel);
-CELL qc250c(CELL pixel, int bandno);
-CELL qc250d(CELL pixel);
-CELL qc250e(CELL pixel);
-CELL qc250f(CELL pixel);
+    /* MOD09Q1 Products (250m, 8-Days) */ 
+CELL mod09Q1a(CELL pixel);
+CELL mod09Q1b(CELL pixel);
+CELL mod09Q1c(CELL pixel, int bandno);
+CELL mod09Q1d(CELL pixel);
+CELL mod09Q1e(CELL pixel);
+CELL mod09Q1f(CELL pixel);
 
+    /* MOD09A1 Products (500m, 8-Days) */ 
+CELL mod09A1a(CELL pixel);
+CELL mod09A1c(CELL pixel, int bandno);
+CELL mod09A1d(CELL pixel);
+CELL mod09A1e(CELL pixel);
+    /* MOD09A1 Products (500m, 8Days, State QA) */
+CELL mod09A1sa(CELL pixel);
+CELL mod09A1sb(CELL pixel);
+CELL mod09A1sc(CELL pixel);
+CELL mod09A1sd(CELL pixel);
+CELL mod09A1se(CELL pixel);
+CELL mod09A1sf(CELL pixel);
+CELL mod09A1sg(CELL pixel);
+CELL mod09A1sh(CELL pixel);
+CELL mod09A1si(CELL pixel);
+CELL mod09A1sj(CELL pixel);
+CELL mod09A1sk(CELL pixel);
 
-    /* 500m Products (MOD09A) */ 
-CELL qc500a(CELL pixel);
-CELL qc500c(CELL pixel, int bandno);
-CELL qc500d(CELL pixel);
-CELL qc500e(CELL pixel);
+    /* MOD11A2 Products (1Km, 8-Days) */ 
+CELL mod11A2a(CELL pixel);
+CELL mod11A2b(CELL pixel);
+CELL mod11A2c(CELL pixel);
+CELL mod11A2d(CELL pixel);
 
 int main(int argc, char *argv[]) 
 {
@@ -44,7 +61,7 @@
     int row, col;
     char *qcflag;		/*Switch for particular index */
     struct GModule *module;
-    struct Option *input1, *input2, *input_band, *output;
+    struct Option *input, *input1, *input2, *input_band, *output;
     struct Flag *flag1;
     struct History history;	/*metadata */
     struct Colors colors;	/*Color rules */
@@ -54,6 +71,7 @@
     /*File Descriptors */ 
     int infd;
     int outfd;
+    char *product;
     char *qcchan;
     int bandno;
     CELL *inrast;
@@ -68,18 +86,47 @@
 	_("Extract quality control parameters from Modis QC layers");
 
     /* Define the different options */ 
+    input = G_define_option();
+    input->key = _("productname");
+    input->type = TYPE_STRING;
+    input->required = YES;
+    input->gisprompt = _("Name of MODIS product type");
+    input->description = _("Name of MODIS product");
+    input->descriptions =_("mod09Q1;surf. refl. 250m 8-days;"
+                            "mod09A1;surf. refl. 500m 8-days;"
+                            "mod09A1s;surf. refl. 500m 8-days, State QA;"
+                            "mod11A2;LST 1Km 8-days (Day/Night);");
+    input->answer = _("mod09Q1");
+
+    input1->answer = _("modland_qa_bits");
     input1 = G_define_option();
     input1->key = _("qcname");
     input1->type = TYPE_STRING;
     input1->required = YES;
     input1->gisprompt = _("Name of QC type to extract");
     input1->description = _("Name of QC");
-    input1->descriptions =_("adjcorr;Adjacency Correction;"
-                            "atcorr;Atmospheric Correction;"
-                            "cloud;Cloud State;"
-                            "data_quality;Band-Wise Data Quality Flag;"
-                            "diff_orbit_from_500m;250m Band is at Different Orbit than 500m;"
-                            "modland_qa_bits;MODIS Land General Quality Assessment;");
+    input1->descriptions =_("adjcorr;mod09: Adjacency Correction;"
+                            "atcorr;mod09: Atmospheric Correction;"
+                            "cloud;mod09: Cloud State;"
+                            "data_quality;mod09: Band-Wise Data Quality Flag;"
+                            "diff_orbit_from_500m;mod09: 250m Band is at Different Orbit than 500m;"
+                            "modland_qa_bits;mod09: MODIS Land General Quality Assessment;"
+                            "data_quality_flag;mod11A2: Detailed Quality Indications;"
+                            "emis_error;mod11A2: Average Emissivity Error Classes;"
+                            "mandatory_qa;mod11A2: MODIS Land General Quality Assessment;"
+                            "lst_error;mod11A2: Average LST Error Classes;"
+                            "aerosol_quantity;mod09A1s: StateQA Internal Snow Mask"
+                            "brdf_correction_performed;mod09A1s: StateQA Internal Snow Mask"
+                            "cirrus_detected;mod09A1s: StateQA Internal Snow Mask"
+                            "cloud_shadow;mod09A1s: StateQA Internal Snow Mask"
+                            "cloud_state;mod09A1s: StateQA Internal Snow Mask"
+                            "internal_cloud_algorithm;mod09A1s: StateQA Internal Snow Mask"
+                            "internal_fire_algorithm;mod09A1s: StateQA Internal Snow Mask"
+                            "internal_snow_mask;mod09A1s: StateQA Internal Snow Mask"
+                            "land_water;mod09A1s: StateQA Internal Snow Mask"
+                            "mod35_snow_ice;mod09A1s: StateQA Internal Snow Mask"
+                            "pixel_adjacent_to_cloud;mod09A1s: StateQA Internal Snow Mask"
+);
     input1->answer = _("modland_qa_bits");
 
     input2 = G_define_standard_option(G_OPT_R_INPUT);
@@ -92,14 +139,14 @@
     input_band->required = NO;
     input_band->gisprompt = "old,value";
     input_band->description =
-	_("Band number of Modis product 250m=[1,2],500m=[1-7]");
-    input_band->descriptions =_("1;250m/500m Band 1: Red;"
-                                "2;250m/500m Band 2: NIR;"
-                                "3;500m Band 3: Blue;"
-                                "4;500m Band 4: Green;"
-                                "5;500m Band 5: SWIR 1;"
-                                "6;500m Band 6: SWIR 2;"
-                                "7;500m Band 7: SWIR 3;");
+	_("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;");
 
     output = G_define_standard_option(G_OPT_R_OUTPUT);
     output->key = _("output");
@@ -107,15 +154,11 @@
 	_("Name of the output QC type classification layer");
     output->answer = _("qc");
 
-    flag1 = G_define_flag();
-    flag1->key = 'A';
-    flag1->description =
-	_("QC for MOD09A product @ 500m instead of default MOD09Q at 250m");
-
     /********************/ 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
+    product = input->answer;
     qcflag = input1->answer;
     qcchan = input2->answer;
     if (input_band->answer)
@@ -123,17 +166,36 @@
 
     result = output->answer;
 
-    if ((!strcmp(qcflag, "cloud") && flag1->answer) || 
-	(!strcmp(qcflag, "diff_orbit_from_500m") && flag1->answer))
-	G_fatal_error(_("This flag is not available for MOD09A @ 500m products"));
+    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")) {
 	if (bandno < 1 || bandno > 7)
 	    G_fatal_error(_("band number out of allowed range [1-7]"));
-	if (!flag1->answer && bandno > 2)
-	    G_fatal_error(_("250m band number is out of allowed range [1,2]"));
+	if (!strcmp(product, "mod09Q1") && bandno > 2)
+	    G_fatal_error(_("mod09Q1 product only has 2 bands"));
     }
+    
+    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"))) ||
+	(!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"))))
+	G_fatal_error(_("This flag is only available for MOD09A1s @ 500m products"));
+
     if ((infd = G_open_cell_old(qcchan, "")) < 0)
 	G_fatal_error(_("Cannot open cell file [%s]"), qcchan);
 
@@ -154,9 +216,7 @@
     /* Process pixels */ 
     for (row = 0; row < nrows; row++)
     {
-	CELL c;
-	CELL qc250chan;
-	CELL qc500chan;
+	CELL c, out;
 	G_percent(row, nrows, 2);
 	if (G_get_c_raster_row(infd, inrast, row) < 0)
 	    G_fatal_error(_("Could not read from <%s>"), qcchan);
@@ -165,54 +225,98 @@
 	for (col = 0; col < ncols; col++)
 	{
 	    c = inrast[col];
-
-	    if (flag1->answer)
-		/* This is a MOD09A at 500m product, QC layer is 32-bit */ 
-		qc500chan = c;
-	    else
-		/* This is a MOD09A at 250m product, QC layer is 16-bit */ 
-		qc250chan =  c;
-
 	    if (G_is_c_null_value(&c))
 		G_set_c_null_value(&outrast[col], 1);
-	    else if (!strcmp(qcflag, "modland_qa_bits")) {
+            else if (!strcmp(product, "mod09A1"))
+            {
+	        if (!strcmp(qcflag, "modland_qa_bits")) 
 		/*calculate modland QA bits extraction  */ 
-		if (flag1->answer)
-		    c = qc500a(qc500chan);
-		else
-		    c = qc250a(qc250chan);
+		    c = mod09A1a(c);
+	        if (!strcmp(qcflag, "data_quality"))
+		/*calculate modland QA bits extraction  */ 
+		    c = mod09A1c(c, bandno);
+	        if (!strcmp(qcflag, "atcorr")) 
+		/*calculate atmospheric correction flag  */ 
+		    c = mod09A1d(c);
+	        if (!strcmp(qcflag, "adjcorr")) 
+		/*calculate adjacency correction flag  */ 
+		    c = mod09A1e(c);
 	    }
-	    else if (!strcmp(qcflag, "cloud"))
+            else if (!strcmp(product, "mod09Q1"))
+            {
+	        if (!strcmp(qcflag, "modland_qa_bits")) 
+		/*calculate modland QA bits extraction  */ 
+		    c = mod09Q1a(c);
+	        if (!strcmp(qcflag, "cloud"))
 		/*calculate cloud state  */ 
 		/* ONLY 250m product! */ 
-		c = qc250b(qc250chan);
-	    else if (!strcmp(qcflag, "data_quality")) {
+		    c = mod09Q1b(c);
+	        if (!strcmp(qcflag, "data_quality"))
 		/*calculate modland QA bits extraction  */ 
-		if (flag1->answer)
-		    c = qc500c(qc500chan, bandno);
-		else
-		    c = qc250c(qc250chan, bandno);
-	    }
-	    else if (!strcmp(qcflag, "atcorr")) {
+		    c = mod09Q1c(c, bandno);
+	        if (!strcmp(qcflag, "atcorr")) 
 		/*calculate atmospheric correction flag  */ 
-		if (flag1->answer)
-		    c = qc500d(qc500chan);
-		else
-		    c = qc250d(qc250chan);
-	    }
-	    else if (!strcmp(qcflag, "adjcorr")) {
+		    c = mod09Q1d(c);
+	        if (!strcmp(qcflag, "adjcorr")) 
 		/*calculate adjacency correction flag  */ 
-		if (flag1->answer)
-		    c = qc500e(qc500chan);
-		else
-		    c = qc250e(qc250chan);
-	    }
-	    else if (!strcmp(qcflag, "diff_orbit_from_500m"))
-		/*calculate different orbit from 500m flag  */ 
-		/* ONLY 250m product! */ 
-		c = qc250f(qc500chan);
+		    c = mod09Q1e(c);
+	        if (!strcmp(qcflag, "diff_orbit_from_500m"))
+                /*calculate different orbit from 500m flag  */ 
+                    c = mod09Q1f(c);
+            }
+            else if (!strcmp(product, "mod11A2"))
+            {
+                if (!strcmp(qcflag, "mandatory_qa")) 
+		/*calculate mod11A2 mandatory qa flags  */ 
+                    c = mod11A2a(c);
+	        if (!strcmp(qcflag, "data_quality_flag"))
+		/*calculate mod11A2 data quality flag  */ 
+                    c = mod11A2b(c);
+                if (!strcmp(qcflag, "emis_error")) 
+		/*calculate mod11A2 emissivity error flag  */ 
+                    c = mod11A2c(c);
+	        if (!strcmp(qcflag, "lst_error")) 
+		/*calculate mod11A2 lst error flag  */ 
+                    c = mod11A2d(c);
+            }
+            else if (!strcmp(product, "mod09A1s"))
+            {
+	        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
-		G_fatal_error(_("Unknown flag name, please check spelling"));
+                G_fatal_error(_("Unknown flag name, please check spelling"));
 
 	    outrast[col] = c;
 	}

Added: grass/trunk/imagery/i.modis.qc/mod09A1a.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1a.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1a.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,22 @@
+/* MODLAND QA Bits 500m long int bits[0-1]
+ * 00 -> class 0: Corrected product produced at ideal quality -- all bands
+ * 01 -> class 1: Corrected product produced at less than idel quality -- some or all bands
+ * 10 -> class 2: Corrected product NOT produced due to cloud effect -- all bands
+ * 11 -> class 3: Corrected product NOT produced due to other reasons -- some or all bands mayb be fill value (Note that a value of [11] overrides a value of [01])
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1a(CELL pixel) 
+{
+    CELL qctemp;
+
+    /* Select bit 0 and 1 (right-side).
+     * hexadecimal "0x03" => binary "11" 
+     * this will set all other bits to null */
+    qctemp = pixel & 0x03;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1c.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1c.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1c.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,28 @@
+/* Band-wise Data Quality 500m long Int 
+ * bits[2-5][6-9][10-13][14-17][18-21][22-25][26-29]
+ * 0000 -> class 0: highest quality
+ * 0111 -> class 1: noisy detector
+ * 1000 -> class 2: dead detector; data interpolated in L1B
+ * 1001 -> class 3: solar zenith >= 86 degrees
+ * 1010 -> class 4: solar zenith >= 85 and < 86 degrees
+ * 1011 -> class 5: missing input
+ * 1100 -> class 6: internal constant used in place of climatological data for at least one atmospheric constant
+ * 1101 -> class 7: correction out of bounds, pixel constrained to extreme allowable value
+ * 1110 -> class 8: L1B data faulty
+ * 1111 -> class 9: not processed due to deep ocean or cloud
+ * Class 10-15: Combination of bits unused
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1c(CELL pixel, int bandno) 
+{
+    CELL qctemp;
+
+    pixel >>= 2 + (4 * (bandno - 1));	/* bitshift [] to [0-3] etc. */
+    qctemp = pixel & 0x0F;    
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1d.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1d.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1d.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* Atmospheric correction 500m long Int bit[30]
+ * 0 -> class 0: Not Corrected product
+ * 1 -> class 1: Corrected product
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1d(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 30;		/* bit no 30 becomes 0 */
+    qctemp = pixel & 0x01;    
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1e.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1e.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1e.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* Adjacency correction 500m long Int bit[31]
+ * 0 -> class 0: Not Corrected product
+ * 1 -> class 1: Corrected product
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1e(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 31;		/* bit no 31 becomes 0 */
+    qctemp = pixel & 0x01; 
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1sa.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1sa.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1sa.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,22 @@
+/* Cloud State unsigned int bits[0-1]
+ * 00 -> class 0: clear
+ * 01 -> class 1: cloudy
+ * 10 -> class 2: mixed
+ * 11 -> class 3: not set, assumed clear
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1sa(CELL pixel) 
+{
+    CELL qctemp;
+
+    /* Select bit 0 and 1 (right-side).
+     * hexadecimal "0x03" => binary "11" 
+     * this will set all other bits to null */
+    qctemp = pixel & 0x03;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1sb.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1sb.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1sb.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* cloud shadow unsigned int bits[2]
+ * 0 -> class 0: yes
+ * 1 -> class 1: no
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1sb(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 2;
+    qctemp = pixel & 0x01;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1sc.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1sc.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1sc.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,24 @@
+/* LAND/WATER FLAG unsigned int bits[3-5]
+ * 000 -> class 0: Shallow ocean
+ * 001 -> class 1: 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: Continental/moderate ocean
+ * 111 -> class 7: Deep ocean
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1sc(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 3;
+    qctemp = pixel & 0x07;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1sd.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1sd.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1sd.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,20 @@
+/* AEROSOL QUANTITY unsigned int bits[6-7]
+ * 00 -> class 0: Climatology
+ * 01 -> class 1: Low
+ * 10 -> class 2: Average
+ * 11 -> class 3: High
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1sd(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 6;
+    qctemp = pixel & 0x03;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1se.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1se.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1se.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,20 @@
+/* CIRRUS DETECTED unsigned int bits[8-9]
+ * 00 -> class 0: None
+ * 01 -> class 1: Small
+ * 10 -> class 2: Average
+ * 11 -> class 3: High
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1se(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 8;
+    qctemp = pixel & 0x03;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1sf.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1sf.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1sf.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* Internal Cloud Algorithm Flag unsigned int bits[10]
+ * 0 -> class 0: Cloud 
+ * 1 -> class 1: No cloud
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1sf(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 10;
+    qctemp = pixel & 0x01;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1sg.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1sg.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1sg.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* Internal Fire Algorithm Flag unsigned int bits[11]
+ * 0 -> class 0: Fire 
+ * 1 -> class 1: No fire
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1sg(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 11;
+    qctemp = pixel & 0x01;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1sh.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1sh.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1sh.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* MOD35 snow/ice flag unsigned int bits [12]
+ * 0 -> class 0: Yes
+ * 1 -> class 1: No
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1sh(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 12;
+    qctemp = pixel & 0x01;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1si.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1si.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1si.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* Pixel adjacent to cloud unsigned int bits[13]
+ * 0 -> class 0: Yes
+ * 1 -> class 1: No
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1si(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 13;
+    qctemp = pixel & 0x01;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1sj.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1sj.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1sj.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* BRDF correction performed unsigned int bits[14]
+ * 0 -> class 0: Yes
+ * 1 -> class 1: No
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1sj(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 14;
+    qctemp = pixel & 0x01;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09A1sk.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09A1sk.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09A1sk.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* Internal Snow Mask unsigned int bits[15]
+ * 0 -> class 0: Snow
+ * 1 -> class 1: No snow
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09A1sk(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 15;
+    qctemp = pixel & 0x01;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09Q1a.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09Q1a.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09Q1a.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,17 @@
+/* MODLAND QA Bits 250m Unsigned Int bits[0-1]
+ * 00 -> class 0: Corrected product produced at ideal quality -- all bands
+ * 01 -> class 1: Corrected product produced at less than idel quality -- some or all bands
+ * 10 -> class 2: Corrected product NOT produced due to cloud effect -- all bands
+ * 11 -> class 3: Corrected product NOT produced due to other reasons -- some or all bands mayb be fill value (Note that a value of [11] overrides a value of [01])
+ */  
+#include "grass/gis.h"
+
+CELL mod09Q1a (CELL pixel) 
+{
+    CELL qctemp;
+    qctemp = pixel & 0x03;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09Q1b.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09Q1b.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09Q1b.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,20 @@
+/* Cloud State 250m Unsigned Int bits[2-3]
+ * 00 -> class 0: Clear -- No clouds
+ * 01 -> class 1: Cloudy
+ * 10 -> class 2: Mixed
+ * 11 -> class 3: Not Set ; Assumed Clear
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09Q1b(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 2;		/*bits [2-3] become [0-1] */
+    qctemp = pixel & 0x03;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09Q1c.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09Q1c.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09Q1c.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,26 @@
+/* Band-wise Data Quality 250m Unsigned Int bits[0-1]
+ * 0000 -> class 0: highest quality
+ * 0111 -> class 1: noisy detector
+ * 1000 -> class 2: dead detector; data interpolated in L1B
+ * 1001 -> class 3: solar zenith >= 86 degrees
+ * 1010 -> class 4: solar zenith >= 85 and < 86 degrees
+ * 1011 -> class 5: missing input
+ * 1100 -> class 6: internal constant used in place of climatological data for at least one atmospheric constant
+ * 1101 -> class 7: correction out of bounds, pixel constrained to extreme allowable value
+ * 1110 -> class 8: L1B data faulty
+ * 1111 -> class 9: not processed due to deep ocean or cloud
+ * Class 11-15: Combination of bits unused
+ */
+#include "grass/gis.h"
+  
+CELL mod09Q1c(CELL pixel, int bandno) 
+{
+    CELL qctemp;
+
+    pixel >>= 4 + (4 * (bandno - 1));	/* bitshift [4-7] or [8-11] to [0-3] */
+    qctemp = pixel & 0x0F;
+
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09Q1d.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09Q1d.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09Q1d.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,17 @@
+/* Atmospheric correction 250m Unsigned Int bit[12]
+ * 0 -> class 0: Not Corrected product
+ * 1 -> class 1: Corrected product
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09Q1d(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 12;		/* bit no 12 becomes 0 */
+    qctemp = pixel & 0x01;
+    
+    return qctemp;
+}
+

Added: grass/trunk/imagery/i.modis.qc/mod09Q1e.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09Q1e.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09Q1e.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* Adjacency correction 250m Unsigned Int bit[13]
+ * 0 -> class 0: Not Corrected product
+ * 1 -> class 1: Corrected product
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09Q1e(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 13;		/* bit no 13 becomes 0 */
+    qctemp = pixel & 0x01;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod09Q1f.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod09Q1f.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod09Q1f.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,18 @@
+/* Different orbit from 500m product, 250m Unsigned Int bit[14]
+ * 0 -> class 0: same orbit as 500m
+ * 1 -> class 1: different orbit from 500m
+ */  
+
+#include "grass/gis.h"
+
+CELL mod09Q1f(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 14;		/* bit no 14 becomes 0 */
+    qctemp = pixel & 0x01;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod11A2a.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod11A2a.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod11A2a.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,17 @@
+/* mod11A2 Mandatory QA Flags 1Km bits[0-1]
+ * 00 -> class 0: LST produced, good quality, not necessary to examine more detailed QA
+ * 01 -> class 1: LST produced, other quality, recommend examination of more detailed QA
+ * 10 -> class 2: LST not produced due to cloud effects
+ * 11 -> class 3: LST not produced primarily due to reasons other than cloud
+ */  
+#include "grass/gis.h"
+
+CELL mod11A2a (CELL pixel) 
+{
+    CELL qctemp;
+    qctemp = pixel & 0x03;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod11A2b.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod11A2b.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod11A2b.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,20 @@
+/* mod11A2 Data Quality Flag bits[2-3]
+ * 00 -> class 0: Good data quality of L1B in 7 TIR bands
+ * 01 -> class 1: Other quality data
+ * 10 -> class 2: TBD
+ * 11 -> class 3: TBD
+ */  
+
+#include "grass/gis.h"
+
+CELL mod11A2b(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 2;		/*bits [2-3] become [0-1] */
+    qctemp = pixel & 0x03;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod11A2c.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod11A2c.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod11A2c.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,20 @@
+/* mod11A2 Emis Error Flag bits[4-5]
+ * 00 -> class 0: Average emissivity error <= 0.01
+ * 01 -> class 1: Average emissivity error <= 0.02
+ * 10 -> class 2: Average emissivity error <= 0.04
+ * 11 -> class 3: Average emissivity error > 0.04
+ */  
+
+#include "grass/gis.h"
+
+CELL mod11A2c(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 4;		/*bits [4-5] become [0-1] */
+    qctemp = pixel & 0x03;
+    
+    return qctemp;
+}
+
+

Added: grass/trunk/imagery/i.modis.qc/mod11A2d.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod11A2d.c	                        (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod11A2d.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -0,0 +1,20 @@
+/* mod11A2 LST Error Flag bits[4-5]
+ * 00 -> class 0: Average LST error <= 1
+ * 01 -> class 1: Average LST error <= 2
+ * 10 -> class 2: Average LST error <= 3 
+ * 11 -> class 3: Average LST error > 3
+ */  
+
+#include "grass/gis.h"
+
+CELL mod11A2d(CELL pixel) 
+{
+    CELL qctemp;
+
+    pixel >>= 6;		/*bits [6-7] become [0-1] */
+    qctemp = pixel & 0x03;
+    
+    return qctemp;
+}
+
+

Deleted: grass/trunk/imagery/i.modis.qc/qc250a.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc250a.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc250a.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,17 +0,0 @@
-/* MODLAND QA Bits 250m Unsigned Int bits[0-1]
- * 00 -> class 0: Corrected product produced at ideal quality -- all bands
- * 01 -> class 1: Corrected product produced at less than idel quality -- some or all bands
- * 10 -> class 2: Corrected product NOT produced due to cloud effect -- all bands
- * 11 -> class 3: Corrected product NOT produced due to other reasons -- some or all bands mayb be fill value (Note that a value of [11] overrides a value of [01])
- */  
-#include "grass/gis.h"
-
-CELL qc250a (CELL pixel) 
-{
-    CELL qctemp;
-    qctemp = pixel & 0x03;
-    
-    return qctemp;
-}
-
-

Deleted: grass/trunk/imagery/i.modis.qc/qc250b.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc250b.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc250b.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,20 +0,0 @@
-/* Cloud State 250m Unsigned Int bits[2-3]
- * 00 -> class 0: Clear -- No clouds
- * 01 -> class 1: Cloudy
- * 10 -> class 2: Mixed
- * 11 -> class 3: Not Set ; Assumed Clear
- */  
-
-#include "grass/gis.h"
-
-CELL qc250b(CELL pixel) 
-{
-    CELL qctemp;
-
-    pixel >>= 2;		/*bits [2-3] become [0-1] */
-    qctemp = pixel & 0x03;
-    
-    return qctemp;
-}
-
-

Deleted: grass/trunk/imagery/i.modis.qc/qc250c.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc250c.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc250c.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,26 +0,0 @@
-/* Band-wise Data Quality 250m Unsigned Int bits[0-1]
- * 0000 -> class 0: highest quality
- * 0111 -> class 1: noisy detector
- * 1000 -> class 2: dead detector; data interpolated in L1B
- * 1001 -> class 3: solar zenith >= 86 degrees
- * 1010 -> class 4: solar zenith >= 85 and < 86 degrees
- * 1011 -> class 5: missing input
- * 1100 -> class 6: internal constant used in place of climatological data for at least one atmospheric constant
- * 1101 -> class 7: correction out of bounds, pixel constrained to extreme allowable value
- * 1110 -> class 8: L1B data faulty
- * 1111 -> class 9: not processed due to deep ocean or cloud
- * Class 11-15: Combination of bits unused
- */
-#include "grass/gis.h"
-  
-CELL qc250c(CELL pixel, int bandno) 
-{
-    CELL qctemp;
-
-    pixel >>= 4 + (4 * (bandno - 1));	/* bitshift [4-7] or [8-11] to [0-3] */
-    qctemp = pixel & 0x0F;
-
-    return qctemp;
-}
-
-

Deleted: grass/trunk/imagery/i.modis.qc/qc250d.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc250d.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc250d.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,17 +0,0 @@
-/* Atmospheric correction 250m Unsigned Int bit[12]
- * 0 -> class 0: Not Corrected product
- * 1 -> class 1: Corrected product
- */  
-
-#include "grass/gis.h"
-
-CELL qc250d(CELL pixel) 
-{
-    CELL qctemp;
-
-    pixel >>= 12;		/* bit no 12 becomes 0 */
-    qctemp = pixel & 0x01;
-    
-    return qctemp;
-}
-

Deleted: grass/trunk/imagery/i.modis.qc/qc250e.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc250e.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc250e.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,18 +0,0 @@
-/* Adjacency correction 250m Unsigned Int bit[13]
- * 0 -> class 0: Not Corrected product
- * 1 -> class 1: Corrected product
- */  
-
-#include "grass/gis.h"
-
-CELL qc250e(CELL pixel) 
-{
-    CELL qctemp;
-
-    pixel >>= 13;		/* bit no 13 becomes 0 */
-    qctemp = pixel & 0x01;
-    
-    return qctemp;
-}
-
-

Deleted: grass/trunk/imagery/i.modis.qc/qc250f.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc250f.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc250f.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,18 +0,0 @@
-/* Different orbit from 500m product, 250m Unsigned Int bit[14]
- * 0 -> class 0: same orbit as 500m
- * 1 -> class 1: different orbit from 500m
- */  
-
-#include "grass/gis.h"
-
-CELL qc250f(CELL pixel) 
-{
-    CELL qctemp;
-
-    pixel >>= 14;		/* bit no 14 becomes 0 */
-    qctemp = pixel & 0x01;
-    
-    return qctemp;
-}
-
-

Deleted: grass/trunk/imagery/i.modis.qc/qc500a.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc500a.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc500a.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,22 +0,0 @@
-/* MODLAND QA Bits 500m long int bits[0-1]
- * 00 -> class 0: Corrected product produced at ideal quality -- all bands
- * 01 -> class 1: Corrected product produced at less than idel quality -- some or all bands
- * 10 -> class 2: Corrected product NOT produced due to cloud effect -- all bands
- * 11 -> class 3: Corrected product NOT produced due to other reasons -- some or all bands mayb be fill value (Note that a value of [11] overrides a value of [01])
- */  
-
-#include "grass/gis.h"
-
-CELL qc500a(CELL pixel) 
-{
-    CELL qctemp;
-
-    /* Select bit 0 and 1 (right-side).
-     * hexadecimal "0x03" => binary "11" 
-     * this will set all other bits to null */
-    qctemp = pixel & 0x03;
-
-    return qctemp;
-}
-
-

Deleted: grass/trunk/imagery/i.modis.qc/qc500c.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc500c.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc500c.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,28 +0,0 @@
-/* Band-wise Data Quality 500m long Int 
- * bits[2-5][6-9][10-13][14-17][18-21][22-25][26-29]
- * 0000 -> class 0: highest quality
- * 0111 -> class 1: noisy detector
- * 1000 -> class 2: dead detector; data interpolated in L1B
- * 1001 -> class 3: solar zenith >= 86 degrees
- * 1010 -> class 4: solar zenith >= 85 and < 86 degrees
- * 1011 -> class 5: missing input
- * 1100 -> class 6: internal constant used in place of climatological data for at least one atmospheric constant
- * 1101 -> class 7: correction out of bounds, pixel constrained to extreme allowable value
- * 1110 -> class 8: L1B data faulty
- * 1111 -> class 9: not processed due to deep ocean or cloud
- * Class 10-15: Combination of bits unused
- */  
-
-#include "grass/gis.h"
-
-CELL qc500c(CELL pixel, int bandno) 
-{
-    CELL qctemp;
-
-    pixel >>= 2 + (4 * (bandno - 1));	/* bitshift [] to [0-3] etc. */
-    qctemp = pixel & 0x0F;    
-    
-    return qctemp;
-}
-
-

Deleted: grass/trunk/imagery/i.modis.qc/qc500d.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc500d.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc500d.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,18 +0,0 @@
-/* Atmospheric correction 500m long Int bit[30]
- * 0 -> class 0: Not Corrected product
- * 1 -> class 1: Corrected product
- */  
-
-#include "grass/gis.h"
-
-CELL qc500d(CELL pixel) 
-{
-    CELL qctemp;
-
-    pixel >>= 30;		/* bit no 30 becomes 0 */
-    qctemp = pixel & 0x01;    
-
-    return qctemp;
-}
-
-

Deleted: grass/trunk/imagery/i.modis.qc/qc500e.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/qc500e.c	2009-04-05 15:09:40 UTC (rev 36589)
+++ grass/trunk/imagery/i.modis.qc/qc500e.c	2009-04-05 15:24:42 UTC (rev 36590)
@@ -1,18 +0,0 @@
-/* Adjacency correction 500m long Int bit[31]
- * 0 -> class 0: Not Corrected product
- * 1 -> class 1: Corrected product
- */  
-
-#include "grass/gis.h"
-
-CELL qc500e(CELL pixel) 
-{
-    CELL qctemp;
-
-    pixel >>= 31;		/* bit no 31 becomes 0 */
-    qctemp = pixel & 0x01; 
-    
-    return qctemp;
-}
-
-



More information about the grass-commit mailing list