[GRASS-SVN] r36541 - grass/branches/releasebranch_6_4/imagery/i.pca

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 30 20:46:39 EDT 2009


Author: hamish
Date: 2009-03-30 20:46:38 -0400 (Mon, 30 Mar 2009)
New Revision: 36541

Modified:
   grass/branches/releasebranch_6_4/imagery/i.pca/main.c
   grass/branches/releasebranch_6_4/imagery/i.pca/support.c
Log:
verbose messages and minor eigen table cosmetics

Modified: grass/branches/releasebranch_6_4/imagery/i.pca/main.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.pca/main.c	2009-03-31 00:38:07 UTC (rev 36540)
+++ grass/branches/releasebranch_6_4/imagery/i.pca/main.c	2009-03-31 00:46:38 UTC (rev 36541)
@@ -248,11 +248,12 @@
 	if ((rowbuf = G_allocate_raster_buf(maptype)) == NULL)
 	    G_fatal_error(_("Unable allocate memory for row buffer"));
 
-	G_message(_("Computing Means for band %d..."), i + 1);
+	G_verbose_message(_("Computing means for band %d..."), i + 1);
 	for (row = 0; row < rows; row++) {
 	    void *ptr = rowbuf;
 
-	    G_percent(row, rows - 1, 2);
+	    if(G_verbose() > G_verbose_std())
+		G_percent(row, rows - 1, 2);
 
 	    if (G_get_raster_row(fds[i], rowbuf, row, maptype) < 0)
 		G_fatal_error(_("Unable to read raster map row %d"), row);
@@ -297,11 +298,13 @@
 	if ((rowbuf1 = G_allocate_raster_buf(maptype)) == NULL)
 	    G_fatal_error(_("Unable allocate memory for row buffer"));
 
-	G_message(_("Computing row %d of covariance matrix..."), j + 1);
+	G_verbose_message(_("Computing row %d of covariance matrix..."),
+			  j + 1);
 	for (row = 0; row < rows; row++) {
 	    void *ptr1, *ptr2;
 
-	    G_percent(row, rows - 1, 2);
+	    if(G_verbose() > G_verbose_std())
+		G_percent(row, rows - 1, 2);
 
 	    if (G_get_raster_row(fds[j], rowbuf1, row, maptype) < 0)
 		G_fatal_error(_("Unable to read raster map row %d"), row);
@@ -333,8 +336,7 @@
 		    covar[j][k] +=
 			((double)G_get_raster_value_d(ptr1, maptype) -
 			 mu[j]) * ((double)G_get_raster_value_d(ptr2,
-								maptype2) -
-				   mu[k]);
+						   maptype2) - mu[k]);
 
 		    ptr1 = G_incr_void_ptr(ptr1, G_raster_size(maptype));
 		    ptr2 = G_incr_void_ptr(ptr2, G_raster_size(maptype2));
@@ -385,7 +387,7 @@
 
 	sprintf(name, "%s.%d", out_basename, i + 1);
 
-	G_message("Transforming <%s>...", name);
+	G_verbose_message("Transforming <%s>...", name);
 
 	/* open a new file for output */
 	if (scale)
@@ -404,7 +406,7 @@
 	    int row, col;
 
 	    if (scale && (pass == PASSES)) {
-		G_message(_("Rescaling the data <%s> to range %d,%d..."),
+		G_verbose_message(_("Rescaling <%s> to range %d,%d..."),
 			  name, scale_min, scale_max);
 
 		old_range = max - min;
@@ -414,7 +416,8 @@
 	    for (row = 0; row < rows; row++) {
 		void *rowptr;
 
-		G_percent(row, rows, 2);
+		if(G_verbose() > G_verbose_std())
+		    G_percent(row, rows, 2);
 
 		/* reset d_buf */
 		for (col = 0; col < cols; col++)
@@ -516,7 +519,8 @@
 		}
 	    }
 
-	    G_percent(row, rows, 2);
+	    if(G_verbose() > G_verbose_std())
+		G_percent(row, rows, 2);
 
 	    /* close output file */
 	    if (pass == PASSES)

Modified: grass/branches/releasebranch_6_4/imagery/i.pca/support.c
===================================================================
--- grass/branches/releasebranch_6_4/imagery/i.pca/support.c	2009-03-31 00:38:07 UTC (rev 36540)
+++ grass/branches/releasebranch_6_4/imagery/i.pca/support.c	2009-03-31 00:46:38 UTC (rev 36541)
@@ -58,9 +58,9 @@
 		G_strcat(tmpeigen, tmpa);
 	    }
 	}
-	G_strcat(tmpeigen, ")");
-	
-	sprintf(tmpa, "[%.2f%%]", eigval[i] * 100/eigval_total);
+	G_strcat(tmpeigen, ") ");
+
+	sprintf(tmpa, "[%5.2f%%]", eigval[i] * 100/eigval_total);
 	G_strcat(tmpeigen, tmpa);
 
 	sprintf(hist.edhist[i + 1], tmpeigen);



More information about the grass-commit mailing list