[GRASS-SVN] r56908 - grass/branches/develbranch_6/imagery/i.landsat.toar

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jun 24 08:55:02 PDT 2013


Author: mmetz
Date: 2013-06-24 08:55:02 -0700 (Mon, 24 Jun 2013)
New Revision: 56908

Modified:
   grass/branches/develbranch_6/imagery/i.landsat.toar/landsat.c
   grass/branches/develbranch_6/imagery/i.landsat.toar/landsat.h
   grass/branches/develbranch_6/imagery/i.landsat.toar/landsat_met.c
   grass/branches/develbranch_6/imagery/i.landsat.toar/landsat_set.c
   grass/branches/develbranch_6/imagery/i.landsat.toar/local_proto.h
   grass/branches/develbranch_6/imagery/i.landsat.toar/main.c
Log:
i.landsat.toar: sync to trunk

Modified: grass/branches/develbranch_6/imagery/i.landsat.toar/landsat.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.landsat.toar/landsat.c	2013-06-24 15:51:50 UTC (rev 56907)
+++ grass/branches/develbranch_6/imagery/i.landsat.toar/landsat.c	2013-06-24 15:55:02 UTC (rev 56908)
@@ -63,7 +63,8 @@
     cos_v = (double)(cos(D2R * (lsat->number < 4 ? 9.2 : 8.2)));
 
     /** Global irradiance on the sensor.
-        Radiance to reflectance coefficient, only NO thermal bands.
+	Radiance to reflectance coefficient, only NO thermal bands.
+	K1 and K2 variables are also utilized as thermal constants
     */
     if (lsat->band[i].thermal == 0) {
 	switch (method) {

Modified: grass/branches/develbranch_6/imagery/i.landsat.toar/landsat.h
===================================================================
--- grass/branches/develbranch_6/imagery/i.landsat.toar/landsat.h	2013-06-24 15:51:50 UTC (rev 56907)
+++ grass/branches/develbranch_6/imagery/i.landsat.toar/landsat.h	2013-06-24 15:55:02 UTC (rev 56908)
@@ -37,7 +37,7 @@
     char thermal;		/* Flag to thermal band          */
     double gain, bias;		/* Gain and Bias of sensor       */
     double K1, K2;		/* Thermal calibration or
-				   Rad2Ref constants */
+				   Rad2Ref constants             */
 
 } band_data;
 
@@ -51,6 +51,8 @@
 
     double dist_es;		/* Distance Earth-Sun            */
     double sun_elev;		/* Sun elevation                 */
+    double sun_az;		/* Sun Azimuth                   */
+    double time;		/* Image Acquisition Time        */
 
     char sensor[10];		/* Type of sensor: MSS, TM, ETM+, OLI/TIRS */
     int bands;			/* Total number of bands         */

Modified: grass/branches/develbranch_6/imagery/i.landsat.toar/landsat_met.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.landsat.toar/landsat_met.c	2013-06-24 15:51:50 UTC (rev 56907)
+++ grass/branches/develbranch_6/imagery/i.landsat.toar/landsat_met.c	2013-06-24 15:55:02 UTC (rev 56908)
@@ -1,6 +1,6 @@
-#include<stdio.h>
-#include<stdlib.h>
-#include<string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <math.h>
 
 #include <grass/gis.h>
@@ -29,10 +29,11 @@
 void get_metformat(const char metadata[], char *key, char value[])
 {
     int i = 0;
-    char *ptr = strstr(metadata, key);
+    char *ptrmet = strstr(metadata, key);
+    char *ptr;
 
-    if (ptr != NULL) {
-	ptr = strstr(ptr, " VALUE ");
+    if (ptrmet != NULL) {
+	ptr = strstr(ptrmet, " VALUE ");
 	if (ptr != NULL) {
 	    while (*ptr++ != '=') ;
 	    while (*ptr <= ' ')
@@ -128,6 +129,11 @@
 	G_warning
 	    ("Using production date from the command line 'product_date'");
 
+    get_mtldata(mtldata, "SUN_AZIMUTH", value);
+    lsat->sun_az = atof(value);
+    if (lsat->sun_az == 0.)
+        G_warning("Sun azimuth is %f", lsat->sun_az);
+
     get_mtldata(mtldata, "SUN_ELEVATION", value);
     if (value[0] == '\0') {
 	get_mtldata(mtldata, "SolarElevation", value);
@@ -136,6 +142,17 @@
     if (lsat->sun_elev == 0.)
 	G_warning("Sun elevation is %f", lsat->sun_elev);
 
+    get_mtldata(mtldata, "SCENE_CENTER_TIME", value);
+    if (value[0] == '\0') {
+        get_mtldata(mtldata, "SCENE_CENTER_SCAN_TIME", value);
+    }
+    /* Remove trailing 'z'*/
+    value[strlen(value) - 1]='\0';
+    /* Cast from hh:mm:ss into hh.hhh*/
+    G_llres_scan(value, &lsat->time);
+    if (lsat->time == 0.)
+        G_warning("Time is %f", lsat->time);
+
     /* Fill the data with the basic/default sensor parameters */
     switch (lsat->number) {
     case 1:
@@ -321,8 +338,8 @@
 	    get_mtldata(mtldata, "EARTH_SUN_DISTANCE", value);
 	    if (value[0] != '\0') {
 		lsat->dist_es = atof(value);
-		G_verbose_message(1,
-				  "ESUN evaluate from REFLECTANCE_ADDITIVE_FACTOR_BAND of the metadata file");
+		G_verbose_message
+		    ("ESUN evaluate from REFLECTANCE_ADDITIVE_FACTOR_BAND of the metadata file");
 	    }
 	}
     }

Modified: grass/branches/develbranch_6/imagery/i.landsat.toar/landsat_set.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.landsat.toar/landsat_set.c	2013-06-24 15:51:50 UTC (rev 56907)
+++ grass/branches/develbranch_6/imagery/i.landsat.toar/landsat_set.c	2013-06-24 15:55:02 UTC (rev 56908)
@@ -1,6 +1,6 @@
-#include<stdio.h>
-#include<stdlib.h>
-#include<string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <math.h>
 
 #include <grass/gis.h>
@@ -15,7 +15,7 @@
 
     /* green, red, near infrared, near infrared */
     int band[] = { 1, 2, 3, 4 };
-    int code[] = { 4, 5, 6, 7 };	/* corrected for MSS4 y MSS5 to 1,2,3,4 */
+    int code[] = { 4, 5, 6, 7 };	/* corrected for MSS4 and MSS5 to 1,2,3,4 */
     double wmin[] = { 0.5, 0.6, 0.7, 0.8 };
     double wmax[] = { 0.6, 0.7, 0.8, 1.1 };
     /* original: 79x57, now all 60 m */
@@ -65,11 +65,11 @@
 {
     int i;
 
-    /* blue, green red, near infrared, shortwave IR, thermal IR, shortwave IR, panchromatic */
+    /* blue, green, red, near infrared, shortwave IR, thermal IR, shortwave IR, panchromatic */
     int band[] = { 1, 2, 3, 4, 5, 6, 6, 7, 8 };
     int code[] = { 1, 2, 3, 4, 5, 61, 62, 7, 8 };
-    double wmin[] = { 0.450, 0.525, 0.630, 0.75, 1.55, 10.40, 2.09, 0.52 };
-    double wmax[] = { 0.515, 0.605, 0.690, 0.90, 1.75, 12.50, 2.35, 0.90 };
+    double wmin[] = { 0.450, 0.525, 0.630, 0.75, 1.55, 10.40, 10.40, 2.09, 0.52 };
+    double wmax[] = { 0.515, 0.605, 0.690, 0.90, 1.75, 12.50, 12.50, 2.35, 0.90 };
     /* 30, 30, 30, 30, 30, 60 (after Feb. 25, 2010: 30), 30, 15 */
 
     strcpy(lsat->sensor, "ETM+");
@@ -95,12 +95,8 @@
      * cirrus, thermal infrared (TIR) 1, TIR 2 */
     int band[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
     int code[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
-    double wmin[] =
-	{ 0.433, 0.450, 0.525, 0.630, 0.845, 1.560, 2.100, 0.500, 1.360, 10.3,
-11.5 };
-    double wmax[] =
-	{ 0.453, 0.515, 0.600, 0.680, 0.885, 1.660, 2.300, 0.680, 1.390, 11.3,
-12.5 };
+    double wmin[] = { 0.433, 0.450, 0.525, 0.630, 0.845, 1.560, 2.100, 0.500, 1.360, 10.3, 11.5 };
+    double wmax[] = { 0.453, 0.515, 0.600, 0.680, 0.885, 1.660, 2.300, 0.680, 1.390, 11.3, 12.5 };
     /* 30, 30, 30, 30, 30, 30, 30, 15, 30, 100, 100 */
 
     strcpy(lsat->sensor, "OLI/TIRS");
@@ -559,17 +555,20 @@
 void set_LDCM(lsat_data * lsat)
 {
     int i, j;
-    double julian, *lmax, *lmin;
+    double *lmax, *lmin;
 
     /* Spectral radiances at detector */
+    
+    /* uncorrected values */ 
     double Lmax[][11] = {
-	{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}	// <<<<<<<<<<<<<< valores incorrectos
+	{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}
     };
     double Lmin[][11] = {
-	{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}	// <<<<<<<<<<<<<< valores incorrectos
+	{0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.}
     };
     /* Solar exoatmospheric spectral irradiances */
-    double esun[] = { 2062., 21931., 1990., 1688., 1037., 268.6, 94.6, 1892., 399.0, 0., 0. };	// <<<<<<<<<<<<<< estimados
+    /* estimates */
+    double esun[] = { 2062., 21931., 1990., 1688., 1037., 268.6, 94.6, 1892., 399.0, 0., 0. };
 
     lmax = Lmax[0];
     lmin = Lmin[0];

Modified: grass/branches/develbranch_6/imagery/i.landsat.toar/local_proto.h
===================================================================
--- grass/branches/develbranch_6/imagery/i.landsat.toar/local_proto.h	2013-06-24 15:51:50 UTC (rev 56907)
+++ grass/branches/develbranch_6/imagery/i.landsat.toar/local_proto.h	2013-06-24 15:55:02 UTC (rev 56908)
@@ -19,5 +19,4 @@
 
 void set_LDCM(lsat_data *);
 
-
 #endif

Modified: grass/branches/develbranch_6/imagery/i.landsat.toar/main.c
===================================================================
--- grass/branches/develbranch_6/imagery/i.landsat.toar/main.c	2013-06-24 15:51:50 UTC (rev 56907)
+++ grass/branches/develbranch_6/imagery/i.landsat.toar/main.c	2013-06-24 15:55:02 UTC (rev 56908)
@@ -174,7 +174,7 @@
     atmo->key = "rayleigh";
     atmo->type = TYPE_DOUBLE;
     atmo->required = NO;
-    atmo->description = _("Rayleigh atmosphere (diffuse sky irradiance)");	/* scattering coefficient? */
+    atmo->label = _("Rayleigh atmosphere (diffuse sky irradiance)");	/* scattering coefficient? */
     atmo->description = _("Required only if 'method' is DOS3");
     atmo->answer = "0.0";
     atmo->guisection = _("Settings");
@@ -183,7 +183,7 @@
     frad = G_define_flag();
     frad->key = 'r';
     frad->description =
-	_("Output at-sensor radiance instead reflectance for all bands");
+	_("Output at-sensor radiance instead of reflectance for all bands");
 
     named = G_define_flag();
     named->key = 'n';
@@ -229,7 +229,7 @@
     rayleigh = atof(atmo->answer);
 
     /* Data from metadata file */
-    /* Unnecessary because G_zero filled, but by sanity */
+    /* Unnecessary because G_zero filled, but for sanity */
     lsat.flag = NOMETADATAFILE;
     if (met != NULL) {
 	lsat.flag = METADATAFILE;
@@ -367,7 +367,7 @@
 	    }
 	    /* Mode of DN */
 	    h_max = 0L;
-	    for (j = lsat.band[i].qcalmin; j < 241; j++) {	/* Exclude ptentially saturated < 240 */
+	    for (j = lsat.band[i].qcalmin; j < 241; j++) {	/* Exclude potentially saturated < 240 */
 		/* G_debug(5, "%d-%ld", j, hist[j]); */
 		if (hist[j] > h_max) {
 		    h_max = hist[j];



More information about the grass-commit mailing list