[GRASS-SVN] r68388 - grass/trunk/imagery/i.modis.qc
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri May 6 13:59:16 PDT 2016
Author: ychemin
Date: 2016-05-06 13:59:16 -0700 (Fri, 06 May 2016)
New Revision: 68388
Added:
grass/trunk/imagery/i.modis.qc/mod13Q1a.c
grass/trunk/imagery/i.modis.qc/mod13Q1b.c
grass/trunk/imagery/i.modis.qc/mod13Q1c.c
grass/trunk/imagery/i.modis.qc/mod13Q1d.c
grass/trunk/imagery/i.modis.qc/mod13Q1e.c
grass/trunk/imagery/i.modis.qc/mod13Q1f.c
grass/trunk/imagery/i.modis.qc/mod13Q1g.c
grass/trunk/imagery/i.modis.qc/mod13Q1h.c
grass/trunk/imagery/i.modis.qc/mod13Q1i.c
Modified:
grass/trunk/imagery/i.modis.qc/main.c
Log:
Added mod13Q1 support
Modified: grass/trunk/imagery/i.modis.qc/main.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/main.c 2016-05-06 20:21:58 UTC (rev 68387)
+++ grass/trunk/imagery/i.modis.qc/main.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -96,6 +96,17 @@
CELL mod13A2h (CELL pixel);
CELL mod13A2i (CELL pixel);
+ /* MOD13Q1 Products (250m, 16-Days) */
+CELL mod13Q1a (CELL pixel);
+CELL mod13Q1b (CELL pixel);
+CELL mod13Q1c (CELL pixel);
+CELL mod13Q1d (CELL pixel);
+CELL mod13Q1e (CELL pixel);
+CELL mod13Q1f (CELL pixel);
+CELL mod13Q1g (CELL pixel);
+CELL mod13Q1h (CELL pixel);
+CELL mod13Q1i (CELL pixel);
+
/* MCD43B2 Products (1km, 8-Days)*/
/* SDS: BRDF_Albedo_Ancilliary */
@@ -171,7 +182,8 @@
"mod11A2;%s;"
"mod13A2;%s;"
"mcd43B2;%s;"
- "mcd43B2q;%s",
+ "mcd43B2q;%s"
+ "mod13Q1;%s;",
_("surf. refl. 250m 8-days"),
_("surf. refl. 500m 8-days"),
_("surf. refl. 500m 8-days, State QA"),
@@ -182,9 +194,10 @@
_("LST 1km 8-days (Day/Night)"),
_("VI 1km 16-days"),
_("Brdf-Albedo Quality (Ancillary SDS) 1km 8-days"),
- _("Brdf-Albedo Quality (BRDF SDS) 1km 8-days"));
+ _("Brdf-Albedo Quality (BRDF SDS) 1km 8-days"),
+ _("VI 250m 16-days"));
productname->descriptions = desc_productname;
- productname->options = "mod09Q1,mod09A1,mod09A1s,mod09CMG,mod09CMGs,mod09CMGi,mod11A1,mod11A2,mod13A2,mcd43B2,mcd43B2q";
+ productname->options = "mod09Q1,mod09A1,mod09A1s,mod09CMG,mod09CMGs,mod09CMGi,mod11A1,mod11A2,mod13A2,mcd43B2,mcd43B2q,mod13Q1";
productname->answer = "mod13A2";
qcname = G_define_option();
@@ -245,7 +258,16 @@
"platform;%s;"
"land_water;%s;"
"sun_z_angle_at_local_noon;%s;"
- "brdf_correction_performed;%s",
+ "brdf_correction_performed;%s"
+ "modland_qa;%s;"
+ "vi_usefulness;%s;"
+ "aerosol_quantity;%s;"
+ "pixel_adjacent_to_cloud;%s;"
+ "brdf_correction_performed;%s;"
+ "mixed_clouds;%s;"
+ "land_water;%s;"
+ "possible_snow_ice;%s;"
+ "possible_shadow;%s;",
_("mod09: Adjacency Correction"),
_("mod09: Atmospheric Correction"),
_("mod09: Cloud State"),
@@ -297,9 +319,18 @@
_("mcd43B2: Quality of BRDF correction performed"),
_("mcd43B2: Quality of BRDF correction performed"),
_("mcd43B2: Quality of BRDF correction performed"),
- _("mcd43B2q: Quality of BRDF correction performed"));
+ _("mcd43B2q: Quality of BRDF correction performed"),
+ _("mod13Q1: MODIS Land General Quality Assessment"),
+ _("mod13Q1: Quality estimation of the pixel"),
+ _("mod13Q1: Quantity range of Aerosol"),
+ _("mod13Q1: if pixel is a cloud neighbour"),
+ _("mod13Q1: if BRDF correction performed"),
+ _("mod13Q1: if pixel mixed with clouds"),
+ _("mod13Q1: separate land from various water objects"),
+ _("mod13Q1: if snow/ice present in pixel"),
+ _("mod13Q1: if shadow is present in pixel"));
qcname->descriptions = desc_qcname;
- qcname->options = "adjcorr,atcorr,cloud,data_quality,diff_orbit_from_500m,modland_qa,mandatory_qa_11A1,data_quality_flag_11A1,emis_error_11A1,lst_error_11A1,data_quality_flag_11A2,emis_error_11A2,mandatory_qa_11A2,lst_error_11A2,aerosol_quantity,brdf_correction_performed,cirrus_detected,cloud_shadow,cloud_state,internal_cloud_algorithm,internal_fire_algorithm,internal_snow_mask,land_water,mod35_snow_ice,pixel_adjacent_to_cloud,icm_cloudy,icm_clear,icm_high_clouds,icm_low_clouds,icm_snow,icm_fire,icm_sun_glint,icm_dust,icm_cloud_shadow,icm_pixel_is_adjacent_to_cloud,icm_cirrus,icm_pan_flag,icm_criteria_for_aerosol_retrieval,icm_aot_has_clim_val,modland_qa,vi_usefulness,aerosol_quantity,pixel_adjacent_to_cloud,brdf_correction_performed,mixed_clouds,land_water,possible_snow_ice,possible_shadow,platform,land_water,sun_z_angle_at_local_noon,brdf_correction_performed";
+ qcname->options = "adjcorr,atcorr,cloud,data_quality,diff_orbit_from_500m,modland_qa,mandatory_qa_11A1,data_quality_flag_11A1,emis_error_11A1,lst_error_11A1,data_quality_flag_11A2,emis_error_11A2,mandatory_qa_11A2,lst_error_11A2,aerosol_quantity,brdf_correction_performed,cirrus_detected,cloud_shadow,cloud_state,internal_cloud_algorithm,internal_fire_algorithm,internal_snow_mask,land_water,mod35_snow_ice,pixel_adjacent_to_cloud,icm_cloudy,icm_clear,icm_high_clouds,icm_low_clouds,icm_snow,icm_fire,icm_sun_glint,icm_dust,icm_cloud_shadow,icm_pixel_is_adjacent_to_cloud,icm_cirrus,icm_pan_flag,icm_criteria_for_aerosol_retrieval,icm_aot_has_clim_val,modland_qa,vi_usefulness,aerosol_quantity,pixel_adjacent_to_cloud,brdf_correction_performed,mixed_clouds,land_water,possible_snow_ice,possible_shadow,platform,land_water,sun_z_angle_at_local_noon,brdf_correction_performed,modland_qa,vi_usefulness,aerosol_quantity,pixel_adjacent_to_cloud,brdf_correction_performed,mixed_clouds,land_water,pos
sible_snow_ice,possible_shadow";
qcname->answer = "modland_qa";
input_band = G_define_option();
@@ -409,6 +440,13 @@
if (!strcmp(product, "mcd43B2q") && (bandno < 1 || bandno > 7))
G_fatal_error(_("Band number out of allowed range [1-7]"));
+ /*mod13Q1*/
+ if ((!strcmp(qcflag, "vi_usefulness") && strcmp(product, "mod13Q1")) ||
+ (!strcmp(qcflag, "mixed_clouds") && strcmp(product, "mod13Q1")) ||
+ (!strcmp(qcflag, "possible_snow_ice") && strcmp(product, "mod13Q1")) ||
+ (!strcmp(qcflag, "possible_shadow") && strcmp(product, "mod13Q1")))
+ G_fatal_error(_("This bit flag is only available for MOD13Q1 @ 250m products"));
+
infd = Rast_open_old(qcchan, "");
Rast_get_cellhd(qcchan, "", &cellhd);
@@ -690,6 +728,36 @@
/* BRDF correction performed Quality flag */
c = mcd43B2qa(c, bandno);
}
+ else if (!strcmp(product, "mod13Q1"))
+ {
+ if (!strcmp(qcflag, "modland_qa"))
+ /*calculate mod11A2 MODIS Land Quality flags */
+ c = mod13Q1a(c);
+ if (!strcmp(qcflag, "vi_usefulness"))
+ /*calculate mod13A2 estimate of vi usefulness flag */
+ c = mod13Q1b(c);
+ if (!strcmp(qcflag, "aerosol_quantity"))
+ /*calculate mod13A2 aerosol quantity range flag */
+ c = mod13Q1c(c);
+ if (!strcmp(qcflag, "pixel_adjacent_to_cloud"))
+ /*calculate mod13A2 adjacent cloud detected flag */
+ c = mod13Q1d(c);
+ if (!strcmp(qcflag, "brdf_correction_performed"))
+ /*calculate mod13A2 BRDF correction performed flag */
+ c = mod13Q1e(c);
+ if (!strcmp(qcflag, "mixed_clouds"))
+ /*calculate mod13A2 pixel has clouds flag */
+ c = mod13Q1f(c);
+ if (!strcmp(qcflag, "land_water"))
+ /*calculate mod13A2 land and water types screening flag */
+ c = mod13Q1g(c);
+ if (!strcmp(qcflag, "possible_snow_ice"))
+ /*calculate mod13A2 possible presence of snow or ice flag */
+ c = mod13Q1h(c);
+ if (!strcmp(qcflag, "possible_shadow"))
+ /*calculate mod13A2 possible presence of shadow flag */
+ c = mod13Q1i(c);
+ }
else
G_fatal_error(_("Unknown names and/or combination, please check spelling"));
Added: grass/trunk/imagery/i.modis.qc/mod13Q1a.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13Q1a.c (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13Q1a.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -0,0 +1,18 @@
+/* mod13Q1 Mandatory QA Flags 250m bits[0-1]
+ * 00 -> class 0: VI produced, good quality
+ * 01 -> class 1: VI produced, but check other QA
+ * 10 -> class 2: Pixel produced, but most probably cloud
+ * 11 -> class 3: Pixel not produced due to other reasons than clouds
+ */
+
+#include <grass/raster.h>
+
+CELL mod13Q1a (CELL pixel)
+{
+ CELL qctemp;
+ qctemp = pixel & 0x03;
+
+ return qctemp;
+}
+
+
Added: grass/trunk/imagery/i.modis.qc/mod13Q1b.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13Q1b.c (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13Q1b.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -0,0 +1,27 @@
+/* mod13Q1 VI Usefulness Flag bits[2-5]
+ * 0000 -> class 0: Highest quality
+ * 0001 -> class 1: Lower quality
+ * 0010 -> class 2: Decreasing quality
+ * 0100 -> class 3: Decreasing quality
+ * 1000 -> class 4: Decreasing quality
+ * 1001 -> class 5: Decreasing quality
+ * 1010 -> class 6: Decreasing quality
+ * 1100 -> class 7: Lowest quality
+ * 1101 -> class 8: Quality so low that it is not useful
+ * 1110 -> class 9: L1B data faulty
+ * 1111 -> class 10: Not useful for any other reason/not processed
+ */
+
+#include <grass/raster.h>
+
+CELL mod13Q1b(CELL pixel)
+{
+ CELL qctemp;
+
+ pixel >>= 2; /*bits [2-5] become [0-4] */
+ qctemp = pixel & 0x0F;
+
+ return qctemp;
+}
+
+
Added: grass/trunk/imagery/i.modis.qc/mod13Q1c.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13Q1c.c (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13Q1c.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -0,0 +1,20 @@
+/* mod13Q1 Aerosol quantity Flags 250m bits[6-7]
+ * 00 -> class 0: Climatology
+ * 01 -> class 1: Low
+ * 10 -> class 2: Average
+ * 11 -> class 3: High
+ */
+
+#include <grass/raster.h>
+
+CELL mod13Q1c (CELL pixel)
+{
+ CELL qctemp;
+
+ pixel >>= 6; /*bits [6-7] become [0-1] */
+ qctemp = pixel & 0x03;
+
+ return qctemp;
+}
+
+
Added: grass/trunk/imagery/i.modis.qc/mod13Q1d.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13Q1d.c (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13Q1d.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -0,0 +1,18 @@
+/* mod13Q1 Adjacent cloud detected 250m bit[8]
+ * 00 -> class 0: No
+ * 01 -> class 1: Yes
+ */
+
+#include <grass/raster.h>
+
+CELL mod13Q1d (CELL pixel)
+{
+ CELL qctemp;
+
+ pixel >>= 8; /*bit [8] becomes [0] */
+ qctemp = pixel & 0x01;
+
+ return qctemp;
+}
+
+
Added: grass/trunk/imagery/i.modis.qc/mod13Q1e.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13Q1e.c (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13Q1e.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -0,0 +1,18 @@
+/* mod13Q1 Atmosphere BRDF correction performed 250m bit[9]
+ * 00 -> class 0: No
+ * 01 -> class 1: Yes
+ */
+
+#include <grass/raster.h>
+
+CELL mod13Q1e (CELL pixel)
+{
+ CELL qctemp;
+
+ pixel >>= 9; /*bit [9] becomes [0] */
+ qctemp = pixel & 0x01;
+
+ return qctemp;
+}
+
+
Added: grass/trunk/imagery/i.modis.qc/mod13Q1f.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13Q1f.c (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13Q1f.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -0,0 +1,18 @@
+/* mod13Q1 Mixed clouds 250m bit[10]
+ * 00 -> class 0: No
+ * 01 -> class 1: Yes
+ */
+
+#include <grass/raster.h>
+
+CELL mod13Q1f (CELL pixel)
+{
+ CELL qctemp;
+
+ pixel >>= 10; /*bit [10] becomes [0] */
+ qctemp = pixel & 0x01;
+
+ return qctemp;
+}
+
+
Added: grass/trunk/imagery/i.modis.qc/mod13Q1g.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13Q1g.c (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13Q1g.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -0,0 +1,24 @@
+/* mod13Q1 Land/Water Flags 250m bits[11-13]
+ * 000 -> class 0: Shallow Ocean
+ * 001 -> class 1: Land (Nothing else but land)
+ * 010 -> class 2: Ocean Coastlines and lake shorelines
+ * 011 -> class 3: Shallow inland water
+ * 100 -> class 4: Ephemeral water
+ * 101 -> class 5: Deep inland water
+ * 110 -> class 6: Moderate or continental ocean
+ * 111 -> class 7: Deep ocean
+ */
+
+#include <grass/raster.h>
+
+CELL mod13Q1g (CELL pixel)
+{
+ CELL qctemp;
+
+ pixel >>= 11; /*bits [11-13] become [0-2] */
+ qctemp = pixel & 0x07;
+
+ return qctemp;
+}
+
+
Added: grass/trunk/imagery/i.modis.qc/mod13Q1h.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13Q1h.c (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13Q1h.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -0,0 +1,18 @@
+/* mod13Q1 Possible Snow/Ice 250m bits[14]
+ * 0 -> class 0: No
+ * 1 -> class 1: Yes
+ */
+
+#include <grass/raster.h>
+
+CELL mod13Q1h(CELL pixel)
+{
+ CELL qctemp;
+
+ pixel >>= 14; /*bit [14] becomes [0] */
+ qctemp = pixel & 0x01;
+
+ return qctemp;
+}
+
+
Added: grass/trunk/imagery/i.modis.qc/mod13Q1i.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/mod13Q1i.c (rev 0)
+++ grass/trunk/imagery/i.modis.qc/mod13Q1i.c 2016-05-06 20:59:16 UTC (rev 68388)
@@ -0,0 +1,18 @@
+/* mod13Q1 Possible Shadow 250m bits[15]
+ * 0 -> class 0: No
+ * 1 -> class 1: Yes
+ */
+
+#include <grass/raster.h>
+
+CELL mod13Q1i (CELL pixel)
+{
+ CELL qctemp;
+
+ pixel >>= 15; /*bit [15] becomes [0] */
+ qctemp = pixel & 0x01;
+
+ return qctemp;
+}
+
+
More information about the grass-commit
mailing list