[GRASS-SVN] r44697 - in grass/branches/develbranch_6/imagery: . i.modis.qc

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 23 19:32:06 EST 2010


Author: neteler
Date: 2010-12-23 16:32:05 -0800 (Thu, 23 Dec 2010)
New Revision: 44697

Added:
   grass/branches/develbranch_6/imagery/i.modis.qc/
   grass/branches/develbranch_6/imagery/i.modis.qc/Makefile
   grass/branches/develbranch_6/imagery/i.modis.qc/description.html
   grass/branches/develbranch_6/imagery/i.modis.qc/main.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1a.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1c.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1d.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1e.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sa.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sb.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sc.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sd.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1se.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sf.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sg.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sh.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1si.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sj.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sk.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1a.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1b.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1c.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1d.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1e.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1f.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2a.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2b.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2c.c
   grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2d.c
Modified:
   grass/branches/develbranch_6/imagery/Makefile
Log:
backported from GRASS 7

Modified: grass/branches/develbranch_6/imagery/Makefile
===================================================================
--- grass/branches/develbranch_6/imagery/Makefile	2010-12-23 22:48:05 UTC (rev 44696)
+++ grass/branches/develbranch_6/imagery/Makefile	2010-12-24 00:32:05 UTC (rev 44697)
@@ -9,6 +9,7 @@
 	i.group \
 	i.his.rgb \
 	i.maxlik \
+	i.modis.qc \
 	i.rectify \
 	i.rgb.his \
 	i.smap \

Added: grass/branches/develbranch_6/imagery/i.modis.qc/Makefile
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/Makefile	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/Makefile	2010-12-24 00:32:05 UTC (rev 44697)
@@ -0,0 +1,11 @@
+MODULE_TOPDIR = ../..
+
+PGM = i.modis.qc
+
+LIBES = $(RASTERLIB) $(GISLIB)
+DEPENDENCIES = $(RASTERDEP) $(GISDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+
+default: cmd


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/Makefile
___________________________________________________________________
Added: svn:mime-type
   + text/x-makefile
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/description.html
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/description.html	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/description.html	2010-12-24 00:32:05 UTC (rev 44697)
@@ -0,0 +1,236 @@
+<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).
+
+<pre>
+<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>
+ <li>[01]= class 1: Corrected product produced at less than ideal quality -- some or all bands</li>
+ <li>[10]= class 2: Corrected product NOT produced due to cloud effect -- all bands</li>
+ <li>[11]= class 3: Corrected product NOT produced due to other reasons -- some or all bands maybe be fill value (Note that a value of [11] overrides a value of [01])</li>
+</ul>
+
+<pre>
+<EM>MOD09Q1: Cloud State. bits=[2-3] </EM>
+</pre>
+<ul>
+ <li>[00]= class 0: Clear -- No clouds</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>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>
+ <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>[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>
+ <li>[1110]= class 8: L1B data faulty</li>
+ <li>[1111]= class 9: not processed due to deep ocean or cloud</li>
+ <li>Class 10-15: Combination of bits unused</li>
+</ul>
+
+<pre>
+<EM>MOD09A1/Q1: Atmospheric correction bit=[12]/[30]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: Not Corrected product</li>
+ <li>[1]= class 1: Corrected product</li>
+</ul>
+
+<pre>
+<EM>MOD09A1/Q1: Adjacency correction bit=[13]/[31]</EM>
+</pre>
+<ul>
+ <li>[0]= class 0: Not Corrected product</li>
+ <li>[1]= class 1: Corrected product</li>
+</ul>
+
+<pre>
+<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>
+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>
+Add one Day products.<br>
+
+<H2>SEE ALSO</H2>
+<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>
+<A HREF="i.vi.html">i.vi</A><br>
+</EM>
+
+
+<H2>AUTHORS</H2>
+Yann Chemin<BR>
+
+
+<p>
+<i>Last changed: $Date$</i>


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/description.html
___________________________________________________________________
Added: svn:mime-type
   + text/html
Added: svn:keywords
   + Author Date Id
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/main.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/main.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/main.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -0,0 +1,342 @@
+
+/****************************************************************************
+ *
+ * MODULE:       i.modis.qc
+ * 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)
+ *
+ * COPYRIGHT:    (C) 2008 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.
+ * 
+ *****************************************************************************/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
+
+    /* 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);
+
+    /* 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[]) 
+{
+    struct Cell_head cellhd;	/*region+header info */
+    int nrows, ncols;
+    int row, col;
+    char *qcflag;		/*Switch for particular index */
+    struct GModule *module;
+    struct Option *input, *input1, *input2, *input_band, *output;
+    struct History history;	/*metadata */
+    struct Colors colors;	/*Color rules */
+
+    char *result;		/*output raster name */
+
+    /*File Descriptors */ 
+    int infd;
+    int outfd;
+    char *product;
+    char *qcchan, *mapset;
+    int bandno;
+    CELL *inrast;
+    CELL *outrast;
+    RASTER_MAP_TYPE data_type_output = CELL_TYPE;
+    CELL val1, val2;
+    
+    /************************************/ 
+    G_gisinit(argv[0]);
+    module = G_define_module();
+    module->keywords = _("QC, Quality Control, surface reflectance, Modis");
+    module->description =
+	_("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->description = _("Name of MODIS product type");
+    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 = G_define_option();
+    input1->key = "qcname";
+    input1->type = TYPE_STRING;
+    input1->required = YES;
+    input1->description = _("Name of QC type to extract: "
+                            "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);
+    input2->description =
+	_("Name of the surface reflectance QC layer [bit array]");
+
+    input_band = G_define_option();
+    input_band->key = "band";
+    input_band->type = TYPE_INTEGER;
+    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;");
+
+    output = G_define_standard_option(G_OPT_R_OUTPUT);
+    output->key = "output";
+    output->description =
+	_("Name of the output QC type classification layer");
+    output->answer = "qc";
+
+    /********************/ 
+    if (G_parser(argc, argv))
+	exit(EXIT_FAILURE);
+
+    product = input->answer;
+    qcflag = input1->answer;
+    qcchan = input2->answer;
+    if (input_band->answer)
+	bandno = atoi(input_band->answer);
+
+    result = output->answer;
+
+    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 (!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"));
+
+    mapset = G_find_cell2(qcchan, "");
+    if (mapset == NULL) {
+        G_fatal_error(_("Raster map <%s> not found"), qcchan);
+    }
+    infd = G_open_cell_old(qcchan, "");
+    if (infd < 0)
+        G_fatal_error(_("Unable to open raster map <%s>"), qcchan);
+
+    G_get_cellhd(qcchan, "", &cellhd);
+
+    inrast = G_allocate_raster_buf(CELL_TYPE);
+
+    G_debug(3, "number of rows %d", cellhd.rows);
+    nrows = G_window_rows();
+    ncols = G_window_cols();
+    outrast = G_allocate_raster_buf(data_type_output);
+
+    /* Create New raster files */ 
+    outfd = G_open_cell_new(result);
+
+    /* Process pixels */ 
+    for (row = 0; row < nrows; row++)
+    {
+	CELL c;
+	G_percent(row, nrows, 2);
+	G_get_raster_row(infd, inrast, row, CELL_TYPE);
+
+	/*process the data */ 
+	for (col = 0; col < ncols; col++)
+	{
+	    c = inrast[col];
+	    if (G_is_c_null_value(&c))
+		G_set_c_null_value(&outrast[col], 1);
+            else if (!strcmp(product, "mod09A1"))
+            {
+	        if (!strcmp(qcflag, "modland_qa_bits")) 
+		/*calculate modland QA bits extraction  */ 
+		    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(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 = mod09Q1b(c);
+	        if (!strcmp(qcflag, "data_quality"))
+		/*calculate modland QA bits extraction  */ 
+		    c = mod09Q1c(c, bandno);
+	        if (!strcmp(qcflag, "atcorr")) 
+		/*calculate atmospheric correction flag  */ 
+		    c = mod09Q1d(c);
+	        if (!strcmp(qcflag, "adjcorr")) 
+		/*calculate adjacency correction flag  */ 
+		    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"));
+
+	    outrast[col] = c;
+	}
+
+	G_put_raster_row(outfd, outrast, CELL_TYPE);
+    }
+
+    G_free(inrast);
+    G_close_cell(infd);
+    G_free(outrast);
+    G_close_cell(outfd);
+
+    /* Color from 0 to 10 in grey */ 
+    G_init_colors(&colors);
+    val1 = 0;
+    val2 = 10;
+    G_add_color_rule(&val1, 0, 0, 0, &val2, 255, 255, 255, &colors);
+    G_short_history(result, "raster", &history);
+    G_command_history(&history);
+    G_write_history(result, &history);
+    exit(EXIT_SUCCESS);
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/main.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1a.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1a.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1a.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1a.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1c.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1c.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1c.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1c.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1d.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1d.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1d.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1d.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1e.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1e.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1e.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1e.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sa.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sa.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sa.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sa.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sb.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sb.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sb.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sb.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sc.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sc.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sc.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sc.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sd.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sd.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sd.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sd.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1se.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1se.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1se.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1se.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sf.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sf.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sf.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sf.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sg.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sg.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sg.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sg.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sh.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sh.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sh.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sh.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1si.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1si.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1si.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1si.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sj.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sj.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sj.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sj.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sk.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sk.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sk.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09A1sk.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1a.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1a.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1a.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -0,0 +1,18 @@
+/* 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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1a.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1b.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1b.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1b.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1b.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1c.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1c.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1c.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -0,0 +1,27 @@
+/* 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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1c.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1d.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1d.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1d.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1d.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1e.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1e.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1e.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1e.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1f.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1f.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1f.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod09Q1f.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2a.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2a.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2a.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -0,0 +1,18 @@
+/* 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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2a.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2b.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2b.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2b.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2b.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2c.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2c.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2c.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2c.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2d.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2d.c	                        (rev 0)
+++ grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2d.c	2010-12-24 00:32:05 UTC (rev 44697)
@@ -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;
+}
+
+


Property changes on: grass/branches/develbranch_6/imagery/i.modis.qc/mod11A2d.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native



More information about the grass-commit mailing list