[GRASS-SVN] r54710 - grass-addons/grass7/raster/r.hants

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jan 19 07:14:31 PST 2013


Author: mmetz
Date: 2013-01-19 07:14:30 -0800 (Sat, 19 Jan 2013)
New Revision: 54710

Modified:
   grass-addons/grass7/raster/r.hants/main.c
   grass-addons/grass7/raster/r.hants/r.hants.html
Log:
r.hants update manual, prepare for amplitude and phase

Modified: grass-addons/grass7/raster/r.hants/main.c
===================================================================
--- grass-addons/grass7/raster/r.hants/main.c	2013-01-19 13:40:03 UTC (rev 54709)
+++ grass-addons/grass7/raster/r.hants/main.c	2013-01-19 15:14:30 UTC (rev 54710)
@@ -135,14 +135,15 @@
     struct output *outputs = NULL;
     char *suffix;
     struct History history;
-    DCELL *values = NULL, *rc = NULL;
+    DCELL *values = NULL, *rc = NULL, *amp = NULL, *phase = NULL;
     int nrows, ncols;
     int row, col;
     double lo, hi, fet, *cs, *sn, *ts, delta;
     int bl;
     double **mat, **mat_t, **A, *za, *zr, maxerrlo, maxerrhi;
     int dod, nf, nr, nout, noutmax;
-    int rejlo, rejhi, *useval, dumped;
+    int rejlo, rejhi, *useval;
+    int do_amp_phase, dumped;
 
     G_gisinit(argv[0]);
 
@@ -375,6 +376,12 @@
     rc = G_malloc(num_inputs * sizeof(DCELL));
     useval = G_malloc(num_inputs * sizeof(int));
 
+    do_amp_phase = 0;
+    if (do_amp_phase) {
+	amp = G_malloc((nf + 1) * sizeof(DCELL));
+	phase = G_malloc((nf + 1) * sizeof(DCELL));
+    }
+
     if (parm.ts->answer) {
     	for (i = 0; parm.ts->answers[i]; i++);
 	if (i != num_inputs)
@@ -394,8 +401,17 @@
 	nr = num_inputs;
 
     noutmax = num_inputs - nr - dod;
+    
+    if (noutmax < 0)
+	G_fatal_error(_("For %d input maps and %d frequencies, "
+	                "the degree of overdetermination can not be larger than %d"),
+			num_inputs, nf, dod + noutmax);
 
-    /* are the dimensions correct ? */
+    if (noutmax == 0)
+	G_warning(_("Missing values can not be reconstructed, "
+	            "please reduce either '%s' or '%s'"),
+		    parm.nf->key, parm.dod->key);
+
     mat = G_alloc_matrix(nr, num_inputs);
     mat_t = G_alloc_matrix(num_inputs, nr);
     A = G_alloc_matrix(nr, nr);
@@ -579,7 +595,7 @@
 		 * dump original and approximated values for one cell to stdout */
 		if (non_null >= 20 && done == 1 && !dumped &&
 		    row > nrows / 3 && col > ncols / 2 ) {
-#if 0
+#if 1
 		    for (i = 0; i < num_inputs; i++) {
 			fprintf(stdout, "%g;%g\n", values[i], rc[i]);
 		    }
@@ -587,20 +603,20 @@
 		    dumped = 1;
 		}
 
-#if 0
-		/* amplitude and phase */
-		amp[0] = zr[0];
-		phase[0] = 0;
-		for (i = 1; i < nr; i += 2) {
-		    int ifr = (i + 1) / 2;
-		    double angle = atan2(zr[i + 1], zr[i]) * 180 / M_PI;
+		if (do_amp_phase) {
+		    /* amplitude and phase */
+		    amp[0] = zr[0];
+		    phase[0] = 0;
+		    for (i = 1; i < nr; i += 2) {
+			int ifr = (i + 1) / 2;
+			double angle = atan2(zr[i + 1], zr[i]) * 180 / M_PI;
 
-		    if (angle < 0)
-			angle += 360;
-		    phase[ifr] = angle;
-		    amp[ifr] = sqrt(zr[i] * zr[i] + zr[i + 1] * zr[i + 1]);
+			if (angle < 0)
+			    angle += 360;
+			phase[ifr] = angle;
+			amp[ifr] = sqrt(zr[i] * zr[i] + zr[i + 1] * zr[i + 1]);
+		    }
 		}
-#endif
 	    }
 	    else {
 		for (i = 0; i < num_outputs; i++) {

Modified: grass-addons/grass7/raster/r.hants/r.hants.html
===================================================================
--- grass-addons/grass7/raster/r.hants/r.hants.html	2013-01-19 13:40:03 UTC (rev 54709)
+++ grass-addons/grass7/raster/r.hants/r.hants.html	2013-01-19 15:14:30 UTC (rev 54710)
@@ -2,8 +2,9 @@
 
 <em>r.hants</em> performs a harmonic analysis of time series in order to 
 estimate missing values and identify outliers. For each input map, an 
-output map with the suffix <em>_hants</em> is created.
+output map with the suffix <em>suffix</em> (default: _hants) is created.
 
+<p>
 The option <b>nf</b>, number of frequencies, should be carefully chosen. 
 Different numbers of frequencies should be tested first on a small test 
 region before running the module on the full region. As a rule of thumb, 
@@ -13,7 +14,13 @@
 analysing one year. If two peaks are assumed per year, the number of 
 frequencies should be at least 5 when analysing one year.
 
+<p>The number of frequencies should also not be too large. With a large 
+number of frequencies, outliers can not longer be identified because the 
+fit is "too good", outliers can be represented by the estimate. 
+The number of frequencies should also be smaller than <em>n input maps / 2</em>
+if missing values should be reconstructed.
 
+
 <h2>NOTES</h2>
 
 <p>



More information about the grass-commit mailing list