[GRASS-SVN] r29968 - grass-addons/i.landsat.toar

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 6 02:55:11 EST 2008


Author: neteler
Date: 2008-02-06 02:55:10 -0500 (Wed, 06 Feb 2008)
New Revision: 29968

Modified:
   grass-addons/i.landsat.toar/description.html
   grass-addons/i.landsat.toar/landsat_met.c
   grass-addons/i.landsat.toar/landsat_set.c
   grass-addons/i.landsat.toar/main.c
Log:
E. Jorge Tizado: bugfix when reading met files of Landsat 5 TM

Modified: grass-addons/i.landsat.toar/description.html
===================================================================
--- grass-addons/i.landsat.toar/description.html	2008-02-06 05:29:06 UTC (rev 29967)
+++ grass-addons/i.landsat.toar/description.html	2008-02-06 07:55:10 UTC (rev 29968)
@@ -62,7 +62,7 @@
 <em>TAUv</em> is the atmospheric transmittance along the path from the ground surface to the sensor.
 </p>
 
-<p>For this calculus the values are from DOS2 method (Chavez, 1996): TAUz = sin(e) [for the bands with maximum wave length less than 1., i.e. bands 4/5/6 MSS, 1-4 TM, and 1-4 ETM+] otherwise TAUz = 1.07, TAUv = 1.0, and Esky = 0.</p>
+<p>For this calculus, the values are TAUv = 1.0, Esky = 0. and TAUz = 1.0. When the method is simplified TAUz = sin(e) for all bands with maximum wave length less than 1., i.e. bands 4-6 MSS, 1-4 TM, and 1-4 ETM+.</p>
 
 
 <H2>NOTES</H2>

Modified: grass-addons/i.landsat.toar/landsat_met.c
===================================================================
--- grass-addons/i.landsat.toar/landsat_met.c	2008-02-06 05:29:06 UTC (rev 29967)
+++ grass-addons/i.landsat.toar/landsat_met.c	2008-02-06 07:55:10 UTC (rev 29968)
@@ -108,6 +108,7 @@
 void get_value_met(const char mettext[], char *text, char value[])
 {
     char *ptr;
+    int i;
     value[0] = 0;
 
     ptr = strstr(mettext, text);
@@ -116,10 +117,10 @@
     ptr = strstr(ptr, " VALUE ");
     if (ptr == NULL) return;
 
+    i = 0;
     while (*ptr++ != '\"') ;
-    sscanf(ptr, "%s", value);
-    ptr = value;
-    do { if (*ptr == '\"') *ptr = '\0'; } while (*ptr++);
+    while( *ptr != '\"' && i < MAX_STR) value[i++]=*ptr++;
+    value[i] = '\0';
 
     return;
 }
@@ -164,11 +165,11 @@
             break;
         case '4':
             get_value_met(mettext, "SENSORSHORTNAME", value);
-            if (value[0] = 'M') set_MSS4(lsat); else set_TM4(lsat);
+            if (value[0] == 'M') set_MSS4(lsat); else set_TM4(lsat);
             break;
         case '5':
             get_value_met(mettext, "SENSORSHORTNAME", value);
-            if (value[0] = 'M') set_MSS5(lsat); else set_TM5(lsat);
+            if (value[0] == 'M') set_MSS5(lsat); else set_TM5(lsat);
             break;
     }
 

Modified: grass-addons/i.landsat.toar/landsat_set.c
===================================================================
--- grass-addons/i.landsat.toar/landsat_set.c	2008-02-06 05:29:06 UTC (rev 29967)
+++ grass-addons/i.landsat.toar/landsat_set.c	2008-02-06 07:55:10 UTC (rev 29968)
@@ -13,8 +13,8 @@
 {
     int i;
 
-    int band[]    = { 4, 5, 6, 7 };
-    int code[]    = { 1, 2, 3, 4 };
+    int band[]    = { 1, 2, 3, 4 };
+    int code[]    = { 4, 5, 6, 7 };
     double wmax[] = { 0.6, 0.7, 0.8, 1.1 };
     double wmin[] = { 0.5, 0.6, 0.7, 0.8 };
 
@@ -46,7 +46,7 @@
     lsat->bands = 7;
     for (i = 0; i < lsat->bands; i++) {
         lsat->band[i].number = *(band + i);
-        lsat->band[i].code = lsat->band[i].number;
+        lsat->band[i].code = *(band + i);
         lsat->band[i].wavemax = *(wmax + i);
         lsat->band[i].wavemin = *(wmin + i);
         lsat->band[i].qcalmax = 255.;
@@ -337,9 +337,9 @@
     /** Gyanesh Chander and Brian Markham.
         IEEE Transactions On Geoscience And Remote Sensing, Vol. 41, No. 11, November 2003 */
     /* Spectral radiances at detector */
-    double Lmax[][7] = { { 152.10, 296.81, 204.30, 206.20, 27.19, 15.303,  14.38 },    /* before      May 4, 2003 */
-                         { 193.00, 365.00, 264.00, 221.00, 30.20, 15.303,  16.50 },    /* on or after May 4, 2003 */
-                         { 169.00, 333.00, 264.00, 221.00, 30.20, 15.303,  16.50 } };  /* on or after April 2, 2007 */
+    double Lmax[][7] = { { 152.10, 296.81, 204.30, 206.20, 27.19, 15.303,  14.38 },    /* on or before May 4, 2003 */
+                         { 193.00, 365.00, 264.00, 221.00, 30.20, 15.303,  16.50 },    /* after May 4, 2003 */
+                         { 169.00, 333.00, 264.00, 221.00, 30.20, 15.303,  16.50 } };  /* after April 2, 2007 */
     double Lmin[][7] = { {  -1.52,  -2.84,  -1.17,  -1.51, -0.37,  1.2378, -0.15 },
                          {  -1.52,  -2.84,  -1.17,  -1.51, -0.37,  1.2378, -0.15 },
                          {  -1.52,  -2.84,  -1.17,  -1.51, -0.37,  1.2378, -0.15 } };

Modified: grass-addons/i.landsat.toar/main.c
===================================================================
--- grass-addons/i.landsat.toar/main.c	2008-02-06 05:29:06 UTC (rev 29967)
+++ grass-addons/i.landsat.toar/main.c	2008-02-06 07:55:10 UTC (rev 29968)
@@ -11,8 +11,8 @@
  * COPYRIGHT:    (C) 2002, 2005 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.
+ *               License (>=v2). Read the file COPYING that comes with GRASS
+ *               for details.
  *
  *****************************************************************************/
 
@@ -81,8 +81,8 @@
     adate->key = _("date");
     adate->type = TYPE_STRING;
     adate->required = NO;
-    adate->gisprompt = _("image acquisition adate");
-    adate->description = _("Image acquisition adate (yyyy-mm-dd)");
+    adate->gisprompt = _("image acquisition date");
+    adate->description = _("Image acquisition date (yyyy-mm-dd)");
 
     elev = G_define_option();
     elev->key = _("solar");
@@ -102,8 +102,8 @@
     pdate->key = _("product_date");
     pdate->type = TYPE_STRING;
     pdate->required = NO;
-    pdate->gisprompt = _("image production adate");
-    pdate->description = _("Image creation adate (yyyy-mm-dd)");
+    pdate->gisprompt = _("image production date");
+    pdate->description = _("Image creation date (yyyy-mm-dd)");
 
     metho = G_define_option();
     metho->key = _("method");
@@ -212,9 +212,9 @@
         if (elev->answer != NULL)
            lsat.sun_elev = atof(elev->answer);         /* Overwrite sun elevation of met file */
     }
-    /* Data from adate and solar elevation */
+    /* Data from date and solar elevation */
     else if (adate->answer == NULL || elev->answer == NULL) {
-	G_fatal_error(_("Lacking adate and solar elevation for this satellite"));
+	G_fatal_error(_("Lacking date or solar elevation for this satellite"));
     }
     else {
 	if (sat7->answer) { /* Need gain */
@@ -256,20 +256,21 @@
 	}
     }
 
-    /* Now calculate band constants */
-    for (i = 0; i < lsat.bands; i++) {
-        switch(atcor[0])
-        {
-            case 'c':
-                method = CORRECTED;
-                break;
-            case 's':
-                method = SIMPLIFIED;
-                break;
-            default:
-                method = UNCORRECTED;
-                break;
-        }
+    /* Set method and calculate band constants */
+    switch(atcor[0])
+    {
+        case 'c':
+            method = CORRECTED;
+            break;
+        case 's':
+            method = SIMPLIFIED;
+            break;
+        default:
+            method = UNCORRECTED;
+            break;
+    }
+    for (i = 0; i < lsat.bands; i++)
+    {
         lsat_bandctes(&lsat, i, method, 0.0, percent);
     }
 
@@ -281,6 +282,8 @@
 	fprintf(stdout, " ACQUISITION DATE %s [production date %s]\n", lsat.date, lsat.creation);
 	fprintf(stdout, "   earth-sun distance    = %.8lf\n", lsat.dist_es);
         fprintf(stdout, "   solar elevation angle = %.8lf\n", lsat.sun_elev);
+        fprintf(stdout, "   Method for at sensor values = %s\n",
+            (atcor[0]=='c' ? "corrected" : (atcor[0]=='s' ? "simplified" : "uncorrected")));
         if (atcor[0] == 's')
         {
             fprintf(stdout, "   percent of solar irradiance in path radiance = %.4lf\n", percent);



More information about the grass-commit mailing list