[GRASS-SVN] r72126 - grass/trunk/imagery/i.atcorr

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 25 07:54:45 PST 2018


Author: mmetz
Date: 2018-01-25 07:54:45 -0800 (Thu, 25 Jan 2018)
New Revision: 72126

Modified:
   grass/trunk/imagery/i.atcorr/6s.cpp
   grass/trunk/imagery/i.atcorr/abstra.cpp
   grass/trunk/imagery/i.atcorr/aerosolconcentration.cpp
   grass/trunk/imagery/i.atcorr/aerosolmodel.cpp
   grass/trunk/imagery/i.atcorr/altitude.cpp
   grass/trunk/imagery/i.atcorr/computations.cpp
   grass/trunk/imagery/i.atcorr/create_iwave.py
   grass/trunk/imagery/i.atcorr/geomcond.cpp
   grass/trunk/imagery/i.atcorr/iwave.cpp
   grass/trunk/imagery/i.atcorr/main.cpp
   grass/trunk/imagery/i.atcorr/transform.cpp
Log:
i.atcorr: fix compiler warnings

Modified: grass/trunk/imagery/i.atcorr/6s.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/6s.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/6s.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -224,12 +224,12 @@
     {
 	Output::WriteLn(15," gaseous content at target level: ");
 
-	ostringstream s;
-	s.setf(ios::fixed, ios::floatfield);
-	s << setprecision(3);
-	s << " uh2o=" << setw(9) << atms.uw << " g/cm2      "
-	  << "  uo3=" << setw(9) << atms.uo3 << " cm-atm" << ends;
-	Output::WriteLn(15,s.str());
+	ostringstream s3;
+	s3.setf(ios::fixed, ios::floatfield);
+	s3 << setprecision(3);
+	s3 << " uh2o=" << setw(9) << atms.uw << " g/cm2      "
+	   << "  uo3=" << setw(9) << atms.uo3 << " cm-atm" << ends;
+	Output::WriteLn(15,s3.str());
     }
 
     alt.print();
@@ -578,8 +578,10 @@
     sroaer = sroaer / seb;
     srotot = srotot / seb;
     alumet = alumet / sb;
+    /*
     float pizera = 0.0f;
     if(aero.iaer != 0) pizera = ssdaer / sodaer;
+    */
     sodray = sodray / seb;
     sodaer = sodaer / seb;
     sodtot = sodtot / seb;

Modified: grass/trunk/imagery/i.atcorr/abstra.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/abstra.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/abstra.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -10418,7 +10418,6 @@
 	}
 	else
 	{
-            int k;
 	    for(k = 0; k < 33; k++)
 	    {
 		roair = air * 273.16f * alt.plane_sim.ppl[k] / (1013.25f * alt.plane_sim.tpl[k]);

Modified: grass/trunk/imagery/i.atcorr/aerosolconcentration.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/aerosolconcentration.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/aerosolconcentration.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -37,7 +37,7 @@
     else if(v > 0) oda550(v, atms);
 }
 
-void AerosolConcentration::oda550(const float v, const AtmosModel& atms)
+void AerosolConcentration::oda550(const float vis, const AtmosModel& atms)
 {
     /* aerosol optical depth at wl=550nm */
     /* vertical repartition of aerosol density for v=23km */
@@ -66,7 +66,7 @@
     };
 
     taer55 = 0;
-    if(fabs(v) <= 0) return;
+    if(fabs(vis) <= 0) return;
     if(iaer == 0) return;
 
     for(int k = 0; k < 32; k++)
@@ -78,8 +78,8 @@
 	float bz = (5.f * an5[k] / 18.f) - (23.f * an23[k] / 18.f);
 	float bz1 = (5.f * an5[k+1] / 18.f) - (23.f * an23[k+1] / 18.f);
 
-	float bnz = az / v - bz;
-	float bnz1 = az1 / v - bz1;
+	float bnz = az / vis - bz;
+	float bnz1 = az1 / vis - bz1;
 
 	float ev = (float)(dz * exp((log(bnz) + log(bnz1)) / 2));
 	taer55 += ev * sigma * 1.0e-03f;

Modified: grass/trunk/imagery/i.atcorr/aerosolmodel.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/aerosolmodel.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/aerosolmodel.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -61,7 +61,7 @@
 {
     double np[4];
     double ext[10][4];
-    double sca[10][4];
+    double sca2[10][4];
     double p1[10][4][83];
 
     const double rmul = 0.99526231496887960135245539673954; /*rlogpas = 0.030;  (10**rlogpas-1.D+00)*/
@@ -78,7 +78,7 @@
 	    ex[i][j] = 0;
 	    sc[i][j] = 0;
 	    ext[j][i] = 0;
-	    sca[j][i] = 0;
+	    sca2[j][i] = 0;
 	    for(int k = 0; k < 83; k++) p1[j][i][k] = 0;
 	}
     }
@@ -159,7 +159,7 @@
 		double p11[83];
 		exscphase(alpha, mie_in.rn[j][i], mie_in.ri[j][i], Qext, Qsca, p11);
 		ext[j][i] += xndpr2 * Qext;
-		sca[j][i] += xndpr2 * Qsca;
+		sca2[j][i] += xndpr2 * Qsca;
 
 		/* phase function for each type of particle */
 		for(int k = 0; k < 83; k++) p1[j][i][k] += p11[k]*xndpr2;
@@ -176,12 +176,12 @@
        at 0.550 micron (the extinction coefficient is normalized at 0.550 micron) */
     int j;
     for(j = 0; j < 10; j++)
-	for(int i = 0; i < mie_in.icp; i++)
+	for(i = 0; i < mie_in.icp; i++)
 	{
 	    ext[j][i] /= np[i] * 1000;
-	    sca[j][i] /= np[i] * 1000;
+	    sca2[j][i] /= np[i] * 1000;
 	    ex[0][j] += (float)(mie_in.cij[i] * ext[j][i]);
-	    sc[0][j] += (float)(mie_in.cij[i] * sca[j][i]);
+	    sc[0][j] += (float)(mie_in.cij[i] * sca2[j][i]);
 	}
 
     /* computation of the phase function and the asymetry coefficient
@@ -195,7 +195,7 @@
 	for(int k = 0; k < 83; k++)
 	{
 	    sixs_aerbas.usr_ph[j][k] = 0;
-	    for(int i = 0; i < mie_in.icp; i++)
+	    for(i = 0; i < mie_in.icp; i++)
 		sixs_aerbas.usr_ph[j][k] += (float)(mie_in.cij[i] * p1[j][i][k] / np[i] / 1000);
 		
 	    sixs_aerbas.usr_ph[j][k] += (float)sc[0][j];
@@ -383,7 +383,7 @@
 	PIn[1] = 0;
 	TAUn[1] = sixs_sos.cgaus[j];
 
-	for(int k = 1; k <= mu; k++)
+	for(k = 1; k <= mu; k++)
 	{
 	    double co_n = (2.0 * k + 1) / k / (k + 1);
 	    RS1 += co_n * (RAn[k] * PIn[k] + RBn[k] * TAUn[k]);
@@ -616,7 +616,7 @@
 	sixs_aer.gasym[i] = 0.f;
 	sixs_aer.phase[i] = 0.f;
  
-	for (int k = 1; k <= 83; ++k) sixs_sos.phasel[i][k] = 0.f;
+	for (int k = 0; k < 83; ++k) sixs_sos.phasel[i][k] = 0.f;
     }
 	
     /* return if iear = 0 */
@@ -694,7 +694,7 @@
 	case 11: mie (ex, sc, asy); break;
 	}
 
-	for (int i = 0; i < 10; i++)
+	for (i = 0; i < 10; i++)
 	{
 	    dd[0][i] = (*sixs_aerbas.ph)[i][j1] + coef * ((*sixs_aerbas.ph)[i][j1] - (*sixs_aerbas.ph)[i][j1+1]);
 	    for(int k = 0; k < 83; k++) pha[0][i][k] = (*sixs_aerbas.ph)[i][k];
@@ -850,7 +850,7 @@
     }
     case 4: 
     {
-	for(int i = 0; i < 4; i++) cin >> c[i]; 
+	for(i = 0; i < 4; i++) cin >> c[i]; 
 	cin.ignore(numeric_limits<int>::max(),'\n');
 	break;
     }
@@ -865,7 +865,7 @@
 	    G_fatal_error(_("mie_in.icp: %ld > 4, will cause internal buffer overflow"), mie_in.icp);
 	}
 
-	for(int i = 0; i < mie_in.icp; i++)
+	for(i = 0; i < mie_in.icp; i++)
 	{
 	    cin >> mie_in.x1[i];
 	    cin >> mie_in.x2[i];
@@ -929,7 +929,6 @@
 	    G_fatal_error(_("mie_in.irsunph: %ld > 50, will cause internal buffer overflow"), mie_in.irsunph);
 	}
 
-	int i;
 	for(i = 0; i < mie_in.irsunph; i++)
 	{
 	    cin >> mie_in.rsunph[i];

Modified: grass/trunk/imagery/i.atcorr/altitude.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/altitude.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/altitude.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -75,18 +75,22 @@
     float rmwh[34];
     float rmo3[34];
     int k;
-    for (k = 0; k < 33; ++k)
+    float roair, ds;
+
+    k = 0;
+    roair = air * 273.16f * atms.p[k] / (atms.t[k] * 1013.25f);
+    rmwh[k] = atms.wh[k] / (roair * 1e3f);
+    rmo3[k] = atms.wo[k] / (roair * 1e3f);
+
+    for (k = 1; k < 33; ++k)
     {
-	float roair = air * 273.16f * atms.p[k] / (atms.t[k] * 1013.25f);
+	roair = air * 273.16f * atms.p[k] / (atms.t[k] * 1013.25f);
 	rmwh[k] = atms.wh[k] / (roair * 1e3f);
 	rmo3[k] = atms.wo[k] / (roair * 1e3f);
-    }
 
-    for (k = 1; k < 33; ++k)
-    {
-	float ds = (atms.p[k - 1] - atms.p[k]) / atms.p[0];
-	uw += (rmwh[k] + rmwh[k - 1]) * ds / 2.f;
-	uo3 += (rmo3[k] + rmo3[k - 1]) * ds / 2.f;
+	ds = (atms.p[k - 1] - atms.p[k]) / (atms.p[0] * 2);
+	uw += (rmwh[k] + rmwh[k - 1]) * ds;
+	uo3 += (rmo3[k] + rmo3[k - 1]) * ds;
     }
     uw = uw * atms.p[0] * 100.f / g;
     uo3 = uo3 * atms.p[0] * 100.f / g;

Modified: grass/trunk/imagery/i.atcorr/computations.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/computations.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/computations.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -36,7 +36,7 @@
 {
     /* air refraction index edlen 1966 / metrologia,2,71-80  putting pw=0 */
     float ak=1/wl;
-    double awl= wl*wl*wl*wl;
+    double awl= wl*wl*wl*wl * 0.0254743;
     double a1 = 130 - ak * ak;
     double a2 = 38.9 - ak * ak;
     double a3 = 2406030 / a1;
@@ -49,7 +49,7 @@
     for(int k = 0; k < 33; k++)
     {
 	double dppt = (288.15 / 1013.25) * (atms.p[k] / atms.t[k] + atms.p[k+1] / atms.t[k+1]) / 2;
-	double sr = a * dppt / awl / 0.0254743;
+	double sr = a * dppt / awl;
 	tray += (float)((atms.z[k+1] - atms.z[k]) * sr);
     }
 
@@ -143,7 +143,7 @@
 	pl[IPL(-1)] = 0;
 	pl[IPL(0)] = 1;
 
-	for(int k = 0; k <= 80; k++)
+	for(k = 0; k <= 80; k++)
 	{
 	    pl[IPL(k+1)] = ((2 * k + 1) * rm * pl[IPL(k)] - k * pl[IPL(k-1)]) / (k + 1);
 	    sixs_trunc.betal[k] += x * pl[IPL(k)];
@@ -169,7 +169,7 @@
 */
 
 float discre(const float ta, const float ha, const float tr, const float hr,
-	     const int it, const int nt, const float yy, const float dd,
+	     const int it, const int ntd, const float yy, const float dd,
 	     const float ppp2, const float ppp1)
 {
     if( ha >= 7 ) 
@@ -180,7 +180,7 @@
 
     double dt;
     if( it == 0 ) dt = 1e-17;
-    else dt = 2 * (ta + tr - yy) / (nt - it + 1);
+    else dt = 2 * (ta + tr - yy) / (ntd - it + 1);
 	
     float zx; /* return value */
     float ecart = 0;
@@ -207,8 +207,8 @@
 	}
 
 	zx = y2;
-	float delta = (float)(1. / (1 + ta * hr / tr / ha * exp((zx - ppp1) * (1. / hr - 1. / ha))));
-	if(dd != 0) ecart = (float)fabs((dd - delta) / dd);
+	float cdelta = (float)(1. / (1 + ta * hr / tr / ha * exp((zx - ppp1) * (1. / hr - 1. / ha))));
+	if(dd != 0) ecart = (float)fabs((dd - cdelta) / dd);
     } while((ecart > 0.75) && (it != 0));
     return zx;
 
@@ -304,7 +304,7 @@
 	
     for(j = 0; j <= mu; j++)
     {
-	for(int k = -mu; k <= mu; k++)
+	for(k = -mu; k <= mu; k++)
 	{
 	    double sbp = 0;
 	    if(is <= 80) 
@@ -496,7 +496,7 @@
 
 	
     float phi = (float)geom.phirad;
-    int i;
+    int i, k;
     for(i = 0; i < np; i++) for(int m = -mu; m <= mu; m++) xl[STDI(m)][i] = 0;
 
     /* ************ incident angle mus ******* */
@@ -562,7 +562,7 @@
 	    }
 	    /* primary scattering source function at every level within the layer */
 
-	    for(int k = 0; k <= snt; k++)
+	    for(k = 0; k <= snt; k++)
 	    {
 		float c = ch[k];
 		double a = ydel[k];
@@ -570,15 +570,14 @@
 		i2[k][STDI(j)] = (float)(c * (sa2 * b + sa1 * a));
 	    }
 	}
-	  
-	int k;
+
 	/* vertical integration, primary upward radiation */
 	for(k = 1; k <= mu; k++)
 	{
 	    i1[snt][STDI(k)] = 0;
 	    float zi1 = i1[snt][STDI(k)];
 
-	    for(int i = snt - 1; i >= 0; i--)
+	    for(i = snt - 1; i >= 0; i--)
 	    {
 		float f = h[i + 1] - h[i];
 		double a = (i2[i + 1][STDI(k)] - i2[i][STDI(k)]) / f;
@@ -597,7 +596,7 @@
 	    i1[0][STDI(k)] = 0;
 	    float zi1 = i1[0][STDI(k)];
       
-	    for(int i = 1; i <= snt; i++)
+	    for(i = 1; i <= snt; i++)
 	    {
 		float f = h[i] - h[i - 1];
 		float c = (float)exp(f / gauss.rm[STDI(k)]);
@@ -641,14 +640,14 @@
 
 	    if(is - 2 <= 0)
 	    {
-		for(int k = 1; k <= mu; k++)
+		for(k = 1; k <= mu; k++)
 		{     
-		    for(int i = 0; i <= snt; i++)
+		    for(i = 0; i <= snt; i++)
 		    {
 			double ii1 = 0;
 			double ii2 = 0;
 
-			for(int j = 1; j <= mu; j++)
+			for(j = 1; j <= mu; j++)
 			{
 			    double bpjk = bp[j][STDI(k)] * xdel[i] + ydel[i] * (beta0 + beta2 * xpl[STDI(j)] * xpl[STDI(k)]);
 			    double bpjmk = bp[j][STDI(-k)] * xdel[i] + ydel[i] * (beta0 + beta2 * xpl[STDI(j)] * xpl[STDI(-k)]);
@@ -667,17 +666,17 @@
 	    } 
 	    else
 	    {
-		for(int k = 1; k <= mu; k++)
+		for(k = 1; k <= mu; k++)
 		{
 		    double ii1;
 		    double ii2;
 
-		    for(int i = 0; i <= snt; i++)
+		    for(i = 0; i <= snt; i++)
 		    {
 			ii1 = 0;
 			ii2 = 0;
 
-			for(int j = 1; j <= mu; j++)
+			for(j = 1; j <= mu; j++)
 			{
 			    double bpjk = bp[j][STDI(k)] * xdel[i];
 			    double bpjmk = bp[j][STDI(-k)] * xdel[i];
@@ -697,13 +696,12 @@
 
 			
 	    /* vertical integration, upward radiation */
-	    int k;
 	    for(k = 1; k <= mu; k++)
 	    {
 		i1[snt][STDI(k)] = 0;
 		float zi1 = i1[snt][STDI(k)];
 
-		for(int i = snt-1; i >= 0; i--)
+		for(i = snt-1; i >= 0; i--)
 		{
 		    float f = h[i + 1] - h[i];
 		    double a = (i2[i + 1][STDI(k)] - i2[i][STDI(k)]) / f;
@@ -722,7 +720,7 @@
 		i1[0][STDI(k)] = 0;
 		float zi1 = i1[0][STDI(k)];
 
-		for(int i = 1; i <= snt; i++)
+		for(i = 1; i <= snt; i++)
 		{
 		    float f = h[i] - h[i - 1];
 		    float c = (float)exp(f / gauss.rm[STDI(k)]);
@@ -812,7 +810,7 @@
 		}
 
 		/* inm2 is the (n-2)ieme scattering order */
-		for(int k = -mu; k <= mu; k++) inm2[STDI(k)] = inm1[STDI(k)];
+		for(k = -mu; k <= mu; k++) inm2[STDI(k)] = inm1[STDI(k)];
 		roavion2 = roavion1;
 	    }
 
@@ -857,7 +855,7 @@
 	}
 
 	if(is == 0)
-	    for(int k = 1; k <= mum1; k++) xl[STDI(0)][0] += gauss.rm[STDI(k)] * gauss.gb[STDI(k)] * i3[STDI(-k)];
+	    for(k = 1; k <= mum1; k++) xl[STDI(0)][0] += gauss.rm[STDI(k)] * gauss.gb[STDI(k)] * i3[STDI(-k)];
     
 	xl[STDI(mu)][0] += (float)(delta0s * i3[STDI(mu)] * cos(is * (geom.phirad + M_PI)));
 	xl[STDI(-mu)][0] += (float)(delta0s * roavion * cos(is * (geom.phirad + M_PI)));
@@ -1116,7 +1114,7 @@
 		float x = xdel[i];
 		float y = ydel[i];
       
-		for(int j = 1; j <= mu; j++)
+		for(j = 1; j <= mu; j++)
 		{
 		    float bpjk = bp[j][STDI(k)] * x + y * (beta0 + beta2 * xpl[STDI(j)] * xpl[STDI(k)]);
 		    float bpjmk= bp[j][STDI(-k)] * x + y * (beta0 + beta2 * xpl[STDI(j)] * xpl[STDI(-k)]);
@@ -1602,7 +1600,9 @@
     memset(&oap, 0, sizeof(oap));
 
     Gauss gauss;
+
     gauss.init();   /* discom is the only function that uses the gauss data */
+
     memset(&sixs_trunc, 0, sizeof(sixs_trunc));  /* clear this to keep preconditions the same and output consistent */
 
 /*    computation of all scattering parameters at wavelength 
@@ -1690,8 +1690,11 @@
 {
 
     int linf = 0;
-    for(int i = 0; i < 9; i++) 
-	if(wl >= sixs_disc.wldis[i] && wl <= sixs_disc.wldis[i+1]) linf = i;
+    int i = 8;
+    while (i >= 0 && linf == 0) {
+	if (wl >= sixs_disc.wldis[i] && wl <= sixs_disc.wldis[i+1]) linf = i;
+	i--;
+    }
     if(wl > sixs_disc.wldis[9]) linf = 8;
 
     int lsup = linf + 1;

Modified: grass/trunk/imagery/i.atcorr/create_iwave.py
===================================================================
--- grass/trunk/imagery/i.atcorr/create_iwave.py	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/create_iwave.py	2018-01-25 15:54:45 UTC (rev 72126)
@@ -218,7 +218,7 @@
  	while c < len(fi) - 1 and fi[c + 1] > rthresh:
 	    c = c + 1
  	max_wavelength = np.floor(li[0] * 1000 + (2.5 * c))
- 	print "   %s (%i nm - %i nm)" % (bands[b], min_wavelength, max_wavelength)
+ 	print "   %s (%inm - %inm)" % (bands[b], min_wavelength, max_wavelength)
 
     else:
         filter_f = []
@@ -240,7 +240,7 @@
 	    while c < len(fi) - 1 and fi[c + 1] > rthresh:
 		c = c + 1
 	    max_wavelength = np.floor(li[0] * 1000 + (2.5 * c))
-	    print "   %s (%i nm - %i nm)" % (bands[b], min_wavelength, max_wavelength)
+	    print "   %s (%inm - %inm)" % (bands[b], min_wavelength, max_wavelength)
     
     # writing...
     outfile = open(os.path.join(folder, sensor+"_cpp_template.txt"), 'w')
@@ -346,7 +346,7 @@
 	    hiwl = values[i,0]
 	    i += 1
 	
-	print "   %s (%i nm - %i nm)" % (bands[b - 1], lowl, hiwl)
+	print "   %s (%inm - %inm)" % (bands[b - 1], lowl, hiwl)
 
     # writing file in same folder of input file
     write_cpp(bands, values, sensor, os.path.dirname(inputfile))

Modified: grass/trunk/imagery/i.atcorr/geomcond.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/geomcond.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/geomcond.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -110,7 +110,7 @@
 void GeomCond::pos_fft (long int j, float tu)
 {
     /* Local variables */
-    double ah, et, az, caz, xla, tet, tsm, tsv, elev, azim, delta, amuzero;
+    double ah, et, az, caz, xla, tet, tsm, tsv, elev, azim, gdelta, amuzero;
 
     /*     solar position (zenithal angle asol,azimuthal angle phi0 */
     /*                     in degrees) */
@@ -135,18 +135,18 @@
     ah = tsv * 15.f * M_PI / 180.f;
 
     /* solar declination   (in radian) */
-    delta = 0.006918f - 0.399912f * cos (tet) + 0.070257f * sin (tet) - 
+    gdelta = 0.006918f - 0.399912f * cos (tet) + 0.070257f * sin (tet) - 
 	0.006758f * cos (tet * 2.f) + 9.07e-4f * sin (tet * 2.f) - 
 	0.002697f * cos (tet * 3.f) + 0.00148f * sin (tet * 3.f);
 
     /* elevation,azimuth */
-    amuzero = sin (xla) * sin (delta) + cos (xla) * cos (delta) * cos (ah);
+    amuzero = sin (xla) * sin (gdelta) + cos (xla) * cos (gdelta) * cos (ah);
     elev = asin (amuzero);
-    az = cos (delta) * sin (ah) / cos (elev);
+    az = cos (gdelta) * sin (ah) / cos (elev);
   
     if (fabs (az) - 1.f > 0.f) az = SIGN(az);
 
-    caz = (-cos (xla) * sin (delta) + sin (xla) * cos (delta) * cos (ah)) / cos (elev);
+    caz = (-cos (xla) * sin (gdelta) + sin (xla) * cos (gdelta) * cos (ah)) / cos (elev);
     azim = asin (az);
     if (caz <= 0.f) azim = M_PI - azim;
 
@@ -346,8 +346,8 @@
 	posobs(tu, nc, nl);
 	break;
     }
-    case 4: campm = 1.0f;
-    case 5: 
+    case 4: campm = 1.0f; /* avhrr PM */
+    case 5:  		  /* avhrr PM and avhrr AM */
     {
 	cin >> month;
 	cin >> jday;

Modified: grass/trunk/imagery/i.atcorr/iwave.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/iwave.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/iwave.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -1461,7 +1461,7 @@
     }
 }
 
-float IWave::solirr(const float wl) const
+float IWave::solirr(const float fwl) const
 {
 /*    si (in w/m2/micron) contains the values of the solar
       irradiance between 0.25 and 4.0 microns, by step of 0.0025 m.
@@ -1687,7 +1687,7 @@
     };
 
     float pas = 0.0025;
-    int   iwl = (int)((wl - 0.250) / pas + 1.5);
+    int   iwl = (int)((fwl - 0.250) / pas + 1.5);
 	  
     if(iwl >= 0) return si[iwl-1];
 
@@ -7796,11 +7796,11 @@
     {
 	float sbor = ffu.s[i];
 	if(i == iinf || i == isup) sbor *= 0.5;
-	float wl = (float)(0.25 + i * step);
-	float swl = solirr(wl);
+	float fwl = (float)(0.25 + i * step);
+	float swl = solirr(fwl);
 	float coef = sbor * step * swl;
 	seb += coef;
-	wlwave += wl * coef;
+	wlwave += fwl * coef;
     }
 
     return wlwave/seb;
@@ -7891,20 +7891,20 @@
 	    
 	    /* set wlinf, wlsup */
 	    iinf = imax;
-	    ffu.wlinf = imax * 0.0025 + 0.25;
 	    while (iinf > 0 && ffu.s[iinf - 1] > sthreshold) {
 		iinf--;
-		ffu.wlinf -= 0.0025;
 	    }
+	    ffu.wlinf = iinf * 0.0025 + 0.25;
+
 	    isup = imax;
-	    ffu.wlsup = imax * 0.0025 + 0.25;
 	    while (isup < 1500 && ffu.s[isup + 1] > sthreshold) {
 		isup++;
-		ffu.wlsup += 0.0025;
 	    }
+	    ffu.wlsup = isup * 0.0025 + 0.25;
 	}
     }
 
+    /* assuming that wlinf and wlsup are exact multiples of 2.5 nm */
     iinf = (int)((ffu.wlinf - 0.25f) / 0.0025f + 1.5f) - 1;	/* remember indexing */
     isup = (int)((ffu.wlsup - 0.25f) / 0.0025f + 1.5f) - 1;	/*		   "         */
 

Modified: grass/trunk/imagery/i.atcorr/main.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/main.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/main.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -469,7 +469,7 @@
     opts.iscl->type = TYPE_INTEGER;
     opts.iscl->key_desc = "min,max";
     opts.iscl->required = NO;
-    opts.iscl->answer = "0,255";
+    opts.iscl->answer = G_store("0,255");
     opts.iscl->description = _("Input range");
     opts.iscl->guisection = _("Input");
 
@@ -495,7 +495,7 @@
     opts.oscl->key = "rescale";
     opts.oscl->type = TYPE_INTEGER;
     opts.oscl->key_desc = "min,max";
-    opts.oscl->answer = "0,255";
+    opts.oscl->answer = G_store("0,255");
     opts.oscl->required = NO;
     opts.oscl->description = _("Rescale output raster map");
     opts.oscl->guisection = _("Output");

Modified: grass/trunk/imagery/i.atcorr/transform.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/transform.cpp	2018-01-25 15:37:52 UTC (rev 72125)
+++ grass/trunk/imagery/i.atcorr/transform.cpp	2018-01-25 15:54:45 UTC (rev 72126)
@@ -150,9 +150,11 @@
           
     float rapp = idn;
     float ainrpix = ti.ainr[0][0];
+    /*
     float xa = 0.0f;
     float xb = 0.0f;
     float xc = 0.0f;
+    */
     float rog = rapp / ti.tgasm;
     /* The if below was added to avoid ground reflectances lower than
        zero when ainr(1,1) greater than rapp/tgasm
@@ -176,9 +178,11 @@
 
     rog = (rog - ainrpix / ti.tgasm) / ti.sutott / ti.sdtott;
     rog = rog / (1.f + rog * ti.sast);
+    /*
     xa = (float)M_PI * ti.sb / ti.xmus / ti.seb / ti.tgasm / ti.sutott / ti.sdtott;
     xb = ti.srotot / ti.sutott / ti.sdtott / ti.tgasm;
     xc = ti.sast;
+    */
 
     if (rog > 1) rog = 1;
     if (rog < 0) rog = 0;



More information about the grass-commit mailing list