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