On 04/12/13 23:46, Nikos Alexandris wrote:
Nikos Alexandris:
Here, immediate effect when percent=99.68.  I guess it gets rounded to
99.7 ?

Moritz Lennert:
Actually, the man page says "percent=integer". The input is treated with
atoi(). I don't know if that rounds or floors..

Heck, overlooked that :-(.  In my very humble and ever-wannabe-scientist
opinnion, though, we need those extra digits to make it easy rejecting last
Principal Component(s) prior to the backward PCA. Might be one, two or
numerous (?) depending on the dimensions.

Try the attached diff to imagery/i.pca/main.c.

Moritz
Index: main.c
===================================================================
--- main.c	(révision 58388)
+++ main.c	(copie de travail)
@@ -50,7 +50,7 @@
     int i;			/* Loop control variables */
     int bands;			/* Number of image bands */
     int pcbands;		/* Number of pc scores to use for filtering */
-    int pcperc;			/* cumulative percent to use for filtering */
+    double pcperc;		/* cumulative percent to use for filtering */
     double *mu;			/* Mean vector for image bands */
     double *stddev;		/* Stddev vector for image bands */
     double **covar;		/* Covariance Matrix */
@@ -103,10 +103,10 @@
     
     opt_filt = G_define_option();
     opt_filt->key = "percent";
-    opt_filt->type = TYPE_INTEGER;
+    opt_filt->type = TYPE_DOUBLE;
     opt_filt->required = NO;
-    opt_filt->options = "50-99";
-    opt_filt->answer = "99";
+    opt_filt->options = "50.0-99.99";
+    opt_filt->answer = "99.0";
     opt_filt->label =
 	_("Cumulative percent importance for filtering");
     opt_filt->guisection = _("Filter");
@@ -167,10 +167,10 @@
     /* filter threshold */
     pcperc = -1;
     if (flag_filt->answer) {
-	pcperc = atoi(opt_filt->answer);
+	pcperc = atof(opt_filt->answer);
 	if (pcperc < 0)
 	    G_fatal_error(_("'%s' must be positive"), opt_filt->key);
-	if (pcperc > 99)
+	if (pcperc > 99.99)
 	    G_fatal_error(_("'%s' must be < 100"), opt_filt->key);
     }
 
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to