|
@@ -15,7 +15,7 @@
|
|
|
* for details.
|
|
|
*
|
|
|
* CHANGELOG: Added support MOD11A1 (Markus, December 2010)
|
|
|
- * Added support MOD13A2 (Yann, January 2011)
|
|
|
+ * Added support MOD13A2, MCD43B2 (Yann, January 2011)
|
|
|
*
|
|
|
*****************************************************************************/
|
|
|
|
|
@@ -76,6 +76,16 @@ CELL mod13A2g (CELL pixel);
|
|
|
CELL mod13A2h (CELL pixel);
|
|
|
CELL mod13A2i (CELL pixel);
|
|
|
|
|
|
+ /* MCD43B2 Products (1Km, 8-Days)*/
|
|
|
+
|
|
|
+/* SDS: BRDF_Albedo_Ancilliary */
|
|
|
+CELL mcd43B2a(CELL pixel);
|
|
|
+CELL mcd43B2b(CELL pixel);
|
|
|
+CELL mcd43B2c(CELL pixel);
|
|
|
+
|
|
|
+/* SDS: BRDF_Albedo_Band_Quality */
|
|
|
+CELL mcd43B2qa(CELL pixel, int bandno);
|
|
|
+
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
@@ -124,7 +134,10 @@ int main(int argc, char *argv[])
|
|
|
"mod09A1s;surf. refl. 500m 8-days, State QA;"
|
|
|
"mod11A1;LST 1Km daily (Day/Night);"
|
|
|
"mod11A2;LST 1Km 8-days (Day/Night);"
|
|
|
- "mod13A2;VI 1Km 16-days;");
|
|
|
+ "mod13A2;VI 1Km 16-days;"
|
|
|
+ "mcd43B2;Brdf-Albedo Quality (Ancillary SDS) 1Km 8-days;"
|
|
|
+ "mcd43B2q;Brdf-Albedo Quality (BRDF SDS) 1Km 8-days;"
|
|
|
+ );
|
|
|
input->answer = "mod13A2";
|
|
|
|
|
|
input1 = G_define_option();
|
|
@@ -159,13 +172,18 @@ int main(int argc, char *argv[])
|
|
|
"pixel_adjacent_to_cloud;mod09A1s: StateQA Internal Snow Mask"
|
|
|
"modland_qa;mod13A2: MODIS Land General Quality Assessment"
|
|
|
"vi_usefulness;mod13A2: Quality estimation of the pixel"
|
|
|
- "aerosol_quantity:mod13A2: Quantity range of Aerosol"
|
|
|
- "pixel_adjacent_to_cloud:mod13A2: if pixel is a cloud neighbour"
|
|
|
- "brdf_correction_performed:mod13A2: if BRDF correction performed"
|
|
|
- "mixed_clouds:mod13A2: if pixel mixed with clouds"
|
|
|
- "land_water: separate land from various water objects"
|
|
|
- "possible_snow_ice:mod13A2: if snow/ice present in pixel"
|
|
|
- "possible_shadow:mod13A2: if shadow is present in pixel");
|
|
|
+ "aerosol_quantity;mod13A2: Quantity range of Aerosol"
|
|
|
+ "pixel_adjacent_to_cloud;mod13A2: if pixel is a cloud neighbour"
|
|
|
+ "brdf_correction_performed;mod13A2: if BRDF correction performed"
|
|
|
+ "mixed_clouds;mod13A2: if pixel mixed with clouds"
|
|
|
+ "land_water;mod13A2: separate land from various water objects"
|
|
|
+ "possible_snow_ice;mod13A2: if snow/ice present in pixel"
|
|
|
+ "possible_shadow;mod13A2: if shadow is present in pixel"
|
|
|
+ "platform;mcd43B2: Quality of BRDF correction performed"
|
|
|
+ "land_water;mcd43B2: Quality of BRDF correction performed"
|
|
|
+ "sun_z_angle_at_local_noon;mcd43B2: Quality of BRDF correction performed"
|
|
|
+ "brdf_correction_performed;mcd43B2q: Quality of BRDF correction performed"
|
|
|
+ );
|
|
|
input1->answer = "modland_qa";
|
|
|
|
|
|
input2 = G_define_standard_option(G_OPT_R_INPUT);
|
|
@@ -178,14 +196,14 @@ int main(int argc, char *argv[])
|
|
|
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;");
|
|
|
+ _("Band number of Modis product mod09Q1=[1,2],mod09A1=[1-7], mcd43B2q=[1-7]");
|
|
|
+ input_band->descriptions =_("1;Band 1: Red;"
|
|
|
+ "2;Band 2: NIR;"
|
|
|
+ "3;Band 3: Blue;"
|
|
|
+ "4;Band 4: Green;"
|
|
|
+ "5;Band 5: SWIR 1;"
|
|
|
+ "6;Band 6: SWIR 2;"
|
|
|
+ "7;Band 7: SWIR 3;");
|
|
|
|
|
|
output = G_define_standard_option(G_OPT_R_OUTPUT);
|
|
|
output->key = "output";
|
|
@@ -204,9 +222,10 @@ int main(int argc, char *argv[])
|
|
|
bandno = atoi(input_band->answer);
|
|
|
|
|
|
result = output->answer;
|
|
|
+
|
|
|
/*mod09Q1*/
|
|
|
- if ((!strcmp(qcflag, "cloud") && (strcmp(product, "mod09Q1"))) ||
|
|
|
- (!strcmp(qcflag, "diff_orbit_from_500m") && (strcmp(product, "mod09Q1"))))
|
|
|
+ if ((strcmp(qcflag, "cloud") && !(strcmp(product, "mod09Q1"))) ||
|
|
|
+ (strcmp(qcflag, "diff_orbit_from_500m") && !(strcmp(product, "mod09Q1"))))
|
|
|
G_fatal_error(_("This flag is only available for MOD09Q1 @ 250m products"));
|
|
|
|
|
|
if (!strcmp(qcflag, "data_quality")) {
|
|
@@ -216,37 +235,32 @@ int main(int argc, char *argv[])
|
|
|
G_fatal_error(_("mod09Q1 product only has 2 bands"));
|
|
|
}
|
|
|
|
|
|
- /*mod11A1*/
|
|
|
- if ((!strcmp(qcflag, "mandatory_qa") && (strcmp(product, "mod11A1"))) ||
|
|
|
- (!strcmp(qcflag, "data_quality_flag") && (strcmp(product, "mod11A1"))) ||
|
|
|
- (!strcmp(qcflag, "emis_error") && (strcmp(product, "mod11A1"))) ||
|
|
|
- (!strcmp(qcflag, "lst_error") && (strcmp(product, "mod11A1"))))
|
|
|
- G_fatal_error(_("This flag is only available for MOD11A1 @ 1Km products"));
|
|
|
- /*mod11A2*/
|
|
|
- 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"));
|
|
|
-
|
|
|
/*mod09A1*/
|
|
|
- if (
|
|
|
- (!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, "mod35_snow_ice") && (strcmp(product, "mod09A1s"))))
|
|
|
+ if ((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, "mod35_snow_ice") && !(strcmp(product, "mod09A1s"))))
|
|
|
G_fatal_error(_("This flag is only available for MOD09A1s @ 500m products"));
|
|
|
|
|
|
/*mod13A2*/
|
|
|
- if ((!strcmp(qcflag, "vi_usefulness") && (strcmp(product, "mod13A2"))) ||
|
|
|
- (!strcmp(qcflag, "mixed_clouds") && (strcmp(product, "mod13A2"))) ||
|
|
|
- (!strcmp(qcflag, "possible_snow_ice") && (strcmp(product, "mod13A2"))) ||
|
|
|
- (!strcmp(qcflag, "possible_shadow") && (strcmp(product, "mod13A2"))))
|
|
|
+ if ((strcmp(qcflag, "vi_usefulness") && !(strcmp(product, "mod13A2"))) ||
|
|
|
+ (strcmp(qcflag, "mixed_clouds") && !(strcmp(product, "mod13A2"))) ||
|
|
|
+ (strcmp(qcflag, "possible_snow_ice") && !(strcmp(product, "mod13A2"))) ||
|
|
|
+ (strcmp(qcflag, "possible_shadow") && !(strcmp(product, "mod13A2"))))
|
|
|
G_fatal_error(_("This flag is only available for MOD13A2 @ 1Km products"));
|
|
|
|
|
|
+ /*mcd43B2*/
|
|
|
+ if ((strcmp(qcflag, "platform") && !(strcmp(product, "mcd43B2"))) ||
|
|
|
+ (strcmp(qcflag, "land_water") && !(strcmp(product, "mcd43B2"))) ||
|
|
|
+ (strcmp(qcflag, "sun_z_angle_at_local_noon") && !(strcmp(product, "mcd43B2"))))
|
|
|
+ G_fatal_error(_("This flag is only available for MCD43B2 @ 1Km products"));
|
|
|
+
|
|
|
+ /*mcd43B2q*/
|
|
|
+ if (strcmp(product, "mcd43B2q") && (bandno < 1 || bandno > 7))
|
|
|
+ G_fatal_error(_("Band number out of allowed range [1-7]"));
|
|
|
|
|
|
infd = Rast_open_old(qcchan, "");
|
|
|
|
|
@@ -408,8 +422,30 @@ int main(int argc, char *argv[])
|
|
|
/*calculate mod13A2 possible presence of shadow flag */
|
|
|
c = mod13A2i(c);
|
|
|
}
|
|
|
+ else if (!strcmp(product, "mcd43B2"))
|
|
|
+ {
|
|
|
+ if (!strcmp(qcflag, "platform"))
|
|
|
+ /*calculate mcd43B2: SDS: BRDF_Albedo_Ancillary */
|
|
|
+ /* Satellite platform identification flag */
|
|
|
+ c = mcd43B2a(c);
|
|
|
+ if (!strcmp(qcflag, "land_water"))
|
|
|
+ /*calculate mcd43B2: SDS: BRDF_Albedo_Ancillary */
|
|
|
+ /* Land Water types in pixel flag */
|
|
|
+ c = mcd43B2b(c);
|
|
|
+ if (!strcmp(qcflag, "sun_z_angle_at_local_noon"))
|
|
|
+ /*calculate mcd43B2: SDS: BRDF_Albedo_Ancillary */
|
|
|
+ /* Sun Zenith Angle at Local Solar Noon flag */
|
|
|
+ c = mcd43B2c(c);
|
|
|
+ }
|
|
|
+ else if (!strcmp(product, "mcd43B2q"))
|
|
|
+ {
|
|
|
+ if (!strcmp(qcflag, "brdf_correction_performed"))
|
|
|
+ /*calculate mcd43B2: SDS: BRDF_Albedo_Band_Quality */
|
|
|
+ /* BRDF correction performed Quality flag */
|
|
|
+ c = mcd43B2qa(c, bandno);
|
|
|
+ }
|
|
|
else
|
|
|
- G_fatal_error(_("Unknown flag name, please check spelling"));
|
|
|
+ G_fatal_error(_("Unknown names and/or combination, please check spelling"));
|
|
|
|
|
|
outrast[col] = c;
|
|
|
}
|