[GRASS-SVN] r69794 - grass/branches/releasebranch_7_2/imagery/i.landsat.toar

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Nov 9 01:38:46 PST 2016


Author: neteler
Date: 2016-11-09 01:38:46 -0800 (Wed, 09 Nov 2016)
New Revision: 69794

Modified:
   grass/branches/releasebranch_7_2/imagery/i.landsat.toar/landsat.c
Log:
i.landsat.toar: avoid endless loop and exit if approximation of atmospheric transmittance coefficients is unstable (DOS4 method) (contributed by Dmitry Kolesov, fix #2918)

Modified: grass/branches/releasebranch_7_2/imagery/i.landsat.toar/landsat.c
===================================================================
--- grass/branches/releasebranch_7_2/imagery/i.landsat.toar/landsat.c	2016-11-09 09:34:18 UTC (rev 69793)
+++ grass/branches/releasebranch_7_2/imagery/i.landsat.toar/landsat.c	2016-11-09 09:38:46 UTC (rev 69794)
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <math.h>
 #include <grass/gis.h>
+#include <grass/glocale.h>
 
 #include "landsat.h"
 
@@ -111,6 +112,8 @@
 		    TAUv = Tv;
 		    Lp = Ro - percent * TAUv * (lsat->band[i].esun * sin_e * TAUz + PI * Lp) / pi_d2;
 		    Tz = 1. - (4. * pi_d2 * Lp) / (lsat->band[i].esun * sin_e);
+		    if (Tz <= 0)
+			G_fatal_error(_("The DOS4 method is not applicable here: approximation of atmospheric transmittance coefficients is unstable. Use another DOS method or use other sun_elevation parameter"));
 		    Tv = exp(sin_e * log(Tz) / cos_v);
 		} while (TAUv != Tv && TAUz != Tz);
 		TAUz = (Tz < 1. ? Tz : 1.);



More information about the grass-commit mailing list