[GRASS-SVN] r53550 - grass-addons/grass6/imagery/i.landsat.toar
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 25 04:56:43 PDT 2012
Author: ejtizado
Date: 2012-10-25 04:56:43 -0700 (Thu, 25 Oct 2012)
New Revision: 53550
Modified:
grass-addons/grass6/imagery/i.landsat.toar/landsat.h
grass-addons/grass6/imagery/i.landsat.toar/landsat_met.c
grass-addons/grass6/imagery/i.landsat.toar/landsat_set.c
grass-addons/grass6/imagery/i.landsat.toar/main.c
Log:
Update to read metadata MTL.txt to all Landsats
Modified: grass-addons/grass6/imagery/i.landsat.toar/landsat.h
===================================================================
--- grass-addons/grass6/imagery/i.landsat.toar/landsat.h 2012-10-25 10:04:01 UTC (rev 53549)
+++ grass-addons/grass6/imagery/i.landsat.toar/landsat.h 2012-10-25 11:56:43 UTC (rev 53550)
@@ -3,13 +3,16 @@
#define UNCORRECTED 0
#define CORRECTED 1
+
#define DOS 10
#define DOS1 12
#define DOS2 14
-#define DOS2b 15
+#define DOS2b 15
#define DOS3 16
#define DOS4 18
+#define NOMETADATAFILE 0
+#define METADATAFILE 1
/*****************************************************
* Landsat Structures
@@ -40,6 +43,7 @@
typedef struct
{
+ int flag;
unsigned char number; /* Landsat number */
char creation[11]; /* Image production date */
Modified: grass-addons/grass6/imagery/i.landsat.toar/landsat_met.c
===================================================================
--- grass-addons/grass6/imagery/i.landsat.toar/landsat_met.c 2012-10-25 10:04:01 UTC (rev 53549)
+++ grass-addons/grass6/imagery/i.landsat.toar/landsat_met.c 2012-10-25 11:56:43 UTC (rev 53550)
@@ -96,7 +96,7 @@
lsat->sun_elev = atof(value);
}
- /* Fill data with the sensor_XXX functions */
+ // Fill data with the sensor_XXX functions
switch(lsat->number)
{
case 1:
@@ -184,7 +184,7 @@
get_mtldata(mtldata, "SUN_ELEVATION", value);
lsat->sun_elev = atof(value);
- /* Fill data with the sensor_XXX functions */
+ // Fill data with the sensor_XXX functions
switch(lsat->number)
{
case 1:
@@ -226,7 +226,7 @@
break;
}
- /* Update the information from metadata file */
+ // Update the information from metadata file
for (i = 0; i < lsat->bands; i++) {
snprintf(name, MAX_STR, "LMAX_BAND%d", lsat->band[i].code);
get_mtldata(mtldata, name, value);
@@ -247,3 +247,5 @@
return;
}
+
+
Modified: grass-addons/grass6/imagery/i.landsat.toar/landsat_set.c
===================================================================
--- grass-addons/grass6/imagery/i.landsat.toar/landsat_set.c 2012-10-25 10:04:01 UTC (rev 53549)
+++ grass-addons/grass6/imagery/i.landsat.toar/landsat_set.c 2012-10-25 11:56:43 UTC (rev 53550)
@@ -421,10 +421,9 @@
}
jbuf = julian_char("2004-04-04");
- if (julian >= jbuf) {
- G_warning
- ("Using QCalMin=1.0 as a NLAPS product processed after 4/4/2004");
- G_warning("Discard this message if using the metfile option");
+ if (julian >= jbuf && !(lsat->flag & METADATAFILE) )
+ {
+ G_warning("Using QCalMin=1.0 as a NLAPS product processed after 04/04/2004");
}
lsat->number = 5;
sensor_TM(lsat);
Modified: grass-addons/grass6/imagery/i.landsat.toar/main.c
===================================================================
--- grass-addons/grass6/imagery/i.landsat.toar/main.c 2012-10-25 10:04:01 UTC (rev 53549)
+++ grass-addons/grass6/imagery/i.landsat.toar/main.c 2012-10-25 11:56:43 UTC (rev 53550)
@@ -10,7 +10,7 @@
* PURPOSE: Calculate TOA Radiance or Reflectance and Kinetic Temperature
* for Landsat 1/2/3/4/5 MS, 4/5 TM or 7 ETM+
*
- * COPYRIGHT: (C) 2002-2012 by the GRASS Development Team
+ * COPYRIGHT: (C) 2012 by the GRASS Development Team
*
* This program is free software under the GNU General
* Public License (>=v2). Read the file COPYING that
@@ -85,6 +85,16 @@
metfn->description = _("Name of Landsat metadata file (.met or MTL.txt)");
metfn->guisection = _("Metadata");
+ metho = G_define_option();
+ metho->key = "method";
+ metho->type = TYPE_STRING;
+ metho->required = NO;
+ metho->options = "uncorrected,corrected,dos1,dos2,dos2b,dos3,dos4";
+ metho->label = _("Atmospheric correction method");
+ metho->description = _("Atmospheric correction method");
+ metho->answer = "uncorrected";
+ metho->guisection = _("Metadata");
+
sensor = G_define_option();
sensor->key = "sensor";
sensor->type = TYPE_STRING;
@@ -103,16 +113,6 @@
sensor->required = NO;
sensor->guisection = _("Metadata");
- metho = G_define_option();
- metho->key = "method";
- metho->type = TYPE_STRING;
- metho->required = NO;
- metho->options = "uncorrected,corrected,dos1,dos2,dos2b,dos3,dos4";
- metho->label = _("Atmospheric correction method");
- metho->description = _("Atmospheric correction method");
- metho->answer = "uncorrected";
- metho->guisection = _("Metadata");
-
adate = G_define_option();
adate->key = "date";
adate->type = TYPE_STRING;
@@ -172,6 +172,7 @@
atmo->answer = "0.0";
atmo->guisection = _("Settings");
+
/* define the different flags */
frad = G_define_flag();
frad->key = 'r';
@@ -200,8 +201,10 @@
G_fatal_error(_("Illegal date format: [%s] (yyyy-mm-dd)"),
lsat.date);
}
+ /* Unnecessary because G_zero filled
else
lsat.date[0] = '\0';
+ */
if (pdate->answer != NULL) {
strncpy(lsat.creation, pdate->answer, 11);
@@ -210,17 +213,23 @@
G_fatal_error(_("Illegal date format: [%s] (yyyy-mm-dd)"),
lsat.creation);
}
+ /* Unnecessary because G_zero filled
else
lsat.creation[0] = '\0';
+ */
lsat.sun_elev = elev->answer == NULL ? 0. : atof(elev->answer);
percent = atof(perc->answer);
pixel = atoi(dark->answer);
rayleigh = atof(atmo->answer);
+ /* Unnecessary because G_zero filled
+ lsat.flag = NOMETADATAFILE;
+ */
/* Data from metadata file */
if (met != NULL)
{
+ lsat.flag = METADATAFILE;
i = strlen(met);
if (strcmp(met + i - 7, "MTL.txt") == 0)
{
@@ -229,7 +238,7 @@
else if (strcmp(met + i - 4, ".met") == 0)
{
if (strcmp(sensorname, "tm7") == 0)
- lsat_mtldata(met, &lsat); /* .met of Landsat-7 = new MTL file */
+ lsat_mtldata(met, &lsat); /* old .met of Landsat-7 = new MTL file */
else
lsat_metdata(met, &lsat);
}
@@ -281,17 +290,17 @@
/*****************************************
* ------------ PREPARATION --------------
*****************************************/
- if (G_strcasecmp(metho->answer, "corrected") == 0)
+ if (strcasecmp(metho->answer, "corrected") == 0)
method = CORRECTED;
- else if (G_strcasecmp(metho->answer, "dos1") == 0)
+ else if (strcasecmp(metho->answer, "dos1") == 0)
method = DOS1;
- else if (G_strcasecmp(metho->answer, "dos2") == 0)
+ else if (strcasecmp(metho->answer, "dos2") == 0)
method = DOS2;
- else if (G_strcasecmp(metho->answer, "dos2b") == 0)
+ else if (strcasecmp(metho->answer, "dos2b") == 0)
method = DOS2b;
- else if (G_strcasecmp(metho->answer, "dos3") == 0)
+ else if (strcasecmp(metho->answer, "dos3") == 0)
method = DOS3;
- else if (G_strcasecmp(metho->answer, "dos4") == 0)
+ else if (strcasecmp(metho->answer, "dos4") == 0)
method = DOS4;
else
method = UNCORRECTED;
@@ -387,7 +396,7 @@
G_fatal_error(_("Unknown production date (defined by '%s')"), pdate->key);
if (G_verbose() > G_verbose_std()) {
- fprintf(stderr, " LANDSAT: %d SENSOR: %s\n", lsat.number, lsat.sensor);
+ fprintf(stderr, " LANSAT: %d SENSOR: %s\n", lsat.number, lsat.sensor);
fprintf(stderr, " ACQUISITION DATE %s [production date %s]\n",
lsat.date, lsat.creation);
fprintf(stderr, " earth-sun distance = %.8lf\n", lsat.dist_es);
More information about the grass-commit
mailing list