[GRASS-SVN] r67507 - grass-addons/grass7/imagery/i.spec.sam

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jan 6 12:38:16 PST 2016


Author: ychemin
Date: 2016-01-06 12:38:16 -0800 (Wed, 06 Jan 2016)
New Revision: 67507

Modified:
   grass-addons/grass7/imagery/i.spec.sam/main.c
   grass-addons/grass7/imagery/i.spec.sam/open.c
Log:
send to verbose mode as much as possible, and beautify information sent to user

Modified: grass-addons/grass7/imagery/i.spec.sam/main.c
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/main.c	2016-01-06 20:22:40 UTC (rev 67506)
+++ grass-addons/grass7/imagery/i.spec.sam/main.c	2016-01-06 20:38:16 UTC (rev 67507)
@@ -105,39 +105,37 @@
 
     result_prefix = parm.output->answer;
 
-    G_message("%s",result_prefix);
-
     /*Creating A, the spectral signature matrix here*/
     A = open_files(parm.matrixfile->answer, parm.group->answer);
     /* Spectral Matrix is stored in A now */
-    G_message("Your incoming spectral signature matrix");
+    G_verbose_message("Your incoming spectral signature matrix");
     for (i=0; i<A->cols; i++)
     {
         for (j=0; j<A->rows; j++)
         {
-            G_message("%f ", A->vals[i*A->rows+j]);
+            G_verbose_message("%f ", A->vals[i*A->rows+j]);
         }
-        G_message("\n");
+        G_verbose_message("\n");
     }
   /* Check matrix orthogonality 
    * Ref: Youngsinn Sohn, Roger M. McCoy 1997: Mapping desert shrub rangeland
    *          using spectral unmixing and modeling spectral mixtrues with 
    *          TM data. Photogrammetric Engineering & Remote Sensing, Vol.63, No6.
    */
-    G_message("/* Check matrix orthogonality*/"); 
+    G_verbose_message("/* Check matrix orthogonality*/"); 
     for (i = 0; i < A->cols; i++) /* Number of spectral signatures in matrix input file*/
     {
      Avector = G_matvect_get_column(A, i);  /* go columnwise through matrix*/
-     G_message("Avector rows:%d cols:%d, vals %f %f %f %f",Avector->rows,Avector->cols, Avector->vals[0], Avector->vals[1],Avector->vals[2],Avector->vals[3]);
+     G_verbose_message("Avector rows:%d cols:%d, vals %f %f %f %f",Avector->rows,Avector->cols, Avector->vals[0], Avector->vals[1],Avector->vals[2],Avector->vals[3]);
      for (j = 0; j < A->cols ; j++)/* Number of spectral signatures in matrix input file*/
      {
      if (j !=i)
       {
 	     b = G_matvect_get_column(A, j);      /* compare with next col in A */
-             G_message("b rows:%d cols:%d, vals %f %f %f %f",b->rows,b->cols,b->vals[0],b->vals[1],b->vals[2],b->vals[3]);
-             G_message("process spectangle %d %d %d",i,j, Ref.nfiles);
+             G_verbose_message("b rows:%d cols:%d, vals %f %f %f %f",b->rows,b->cols,b->vals[0],b->vals[1],b->vals[2],b->vals[3]);
+             G_verbose_message("process spectangle %d %d %d",i,j, Ref.nfiles);
 	     spectangle = spectral_angle(Avector, b, RVEC);
-             G_message("processed spectangle");
+             G_verbose_message("processed spectangle");
 	     anglefield[i][j]= spectangle;
 	     G_vector_free(b);
       }

Modified: grass-addons/grass7/imagery/i.spec.sam/open.c
===================================================================
--- grass-addons/grass7/imagery/i.spec.sam/open.c	2016-01-06 20:22:40 UTC (rev 67506)
+++ grass-addons/grass7/imagery/i.spec.sam/open.c	2016-01-06 20:38:16 UTC (rev 67507)
@@ -30,33 +30,30 @@
 	G_fatal_error(_("Unable to read matrix file %s."), matrixfile);
     fclose(fp);
 
-    G_message("matrixfile read");
-
     A = G_matrix_init(A_input.cols, A_input.rows, A_input.cols);/*changed r/c*/
     if (A == NULL)
         G_fatal_error(_("Unable to allocate memory for matrix"));
     A = G_matrix_transpose(&A_input);/*transposed for spec angle process*/
     
-    /*A = G_matrix_copy(&A_input);*//*for matrix orthogonality check*/
-   
     /*if(A->rows < A->cols)
 	G_fatal_error("Need m (rows) >= n (cols) to obtain least squares fit\n");*/
-    G_message("Your spectral matrix has %i rows and %i cols",A->rows,A->cols);
+    /*Display a message confirming what came from the matrix text file, not as stored!*/
+    G_message("Your input spectral matrix has %i spectral signatures",A->cols);
     int j;
     /*For each spectral signature*/
     for (i=0; i<A->cols; i++)
     {
-        G_message("Col #%i",i);
+        G_verbose_message("Col #%i",i);
         /*Display each value*/
         for (j=0; j<A->rows; j++)
         {
-            G_message("Col #%i Row #%i %f",i,j,A->vals[i*A->cols+j]);
+            G_verbose_message("Col #%i Row #%i %f",i,j,A->vals[i*A->cols+j]);
         }
-        G_message("\n");
+        G_verbose_message("\n");
     }
     matrixsize=A->rows;
 
-    G_message("/* open input files from group */");
+    G_verbose_message("/* open input files from group */");
     /* open input files from group */
     if (!I_find_group(img_grp))
     {
@@ -79,7 +76,7 @@
  	G_fatal_error("       does not match matrix size (%i cols).\n", A->cols);
     }
 
-    G_message("/* get memory for input files */");
+    G_verbose_message("/* get memory for input files */");
     /* get memory for input files */
     cell = (DCELL **) G_malloc (Ref.nfiles * sizeof (DCELL *));
     cellfd = (int *) G_malloc (Ref.nfiles * sizeof (int));
@@ -93,7 +90,7 @@
 	    G_fatal_error("Unable to proceed\n");
     }
 
-    G_message("/* open files for results*/");
+    G_verbose_message("/* open files for results*/");
     /* open files for results*/
     result_cell = (DCELL **) G_malloc (Ref.nfiles * sizeof (DCELL *));
     resultfd = (int *) G_malloc (Ref.nfiles * sizeof (int));
@@ -105,7 +102,7 @@
 	resultfd[i] = Rast_open_new (result_name, DCELL_TYPE);
     }
 
-    G_message("open.c: Returning A");
+    G_verbose_message("open.c: Returning A");
  return A; /* give back number of output files (= Ref.nfiles) */
 }
 
@@ -130,9 +127,9 @@
 	return -1;
     }
 
-    G_message("Set Matrix rows:%d by cols:%d",rows,cols);
+    G_verbose_message("Set Matrix rows:%d by cols:%d",rows,cols);
     err = G_matrix_set(out, rows, cols, rows);
-    G_message("Set Matrix rows:%d by cols:%d is done (err:%d)",rows,cols,err);
+    G_verbose_message("Set Matrix rows:%d by cols:%d is done (err:%d)",rows,cols,err);
 
 
     for (i = 0; i < rows; i++) {



More information about the grass-commit mailing list