Opened 12 years ago

Closed 12 years ago

#19 closed enhancement (fixed)

Support for multiple 'percentile' arguments in r.univar

Reported by: epatton Owned by: martinl
Priority: minor Milestone: 6.4.0
Component: Default Version: svn-trunk
Keywords: module, raster Cc:
CPU: Unspecified Platform: Unspecified

Description

I'd like to submit a wish for having r.univar accept multiple percentile arguments as a part of its extended statistics, eg:

r.univar -e map=rast percentile=16,33,50,66,83

Thanks,

~ Eric.

Change History (10)

comment:1 Changed 12 years ago by martinl

Milestone: 6.3.06.4.0

comment:2 Changed 12 years ago by hamish

Owner: changed from grass-dev@… to hamish
Status: newassigned

yes, it would be nice to have that.

note 1st quartile, median, 3rd quartile give 25,50,75% already.

Hamish

comment:3 Changed 12 years ago by hamish

Owner: changed from hamish to anyone
Status: assignednew

comment:4 Changed 12 years ago by martinl

Keywords: module raster added
Owner: changed from anyone to martinl
Status: newassigned

'Percentile' parameter can be now multiple (also for r3.univar).

http://trac.osgeo.org/grass/changeset/29848

E.g.

r.univar elevation.dem -e per=70,90
...
1st quartile: 1200
median (odd number of cells): 1316
3rd quartile: 1488
70th percentile: 1447
90th percentile: 1621

Martin

comment:5 Changed 12 years ago by hamish

bug in the last change? r3.univar, rows*cols*depths, not rows*cols:

@@ -111,6 +113,12 @@
 
     map_type = G3d_tileTypeMap(map);
-    stats = create_univar_stat_struct(map_type, cols * rows * depths);
-    sscanf(param.percentile->answer, "%i", &stats->perc);
+
+    i = 0;
+    while(param.percentile->answers[i])
+	i++;
+    stats = create_univar_stat_struct(map_type, cols * rows, i);
+    for(i = 0; i < stats->n_perc; i++) {
+	sscanf(param.percentile->answers[i], "%i", &stats->perc[i]);
+    }

?? Hamish

comment:6 Changed 12 years ago by hamish

and I'm not sure about this- if the user asks for 25,50,75 then give it to them, even if it is redundant info. It could be used as a verification test of sorts for those....?

stats.c

222               if (stats->perc[i] == 25 || 
223                    stats->perc[i] == 50 || 
224                    stats->perc[i] == 75) { 
225                    /* skip 1st quartile, median, 3rd quartile */ 
226                    continue; 
227               }

Hamish

comment:7 Changed 12 years ago by hamish

if the user asks for 25,50,75 then give it to them

(my earlier post was meaning you might be able to re-use those values to save calculation time. the danger of adding complexity probably negates that savings though)

Also, any ideas about how to do FP percentiles? see http://article.gmane.org/gmane.comp.gis.grass.user/20744

In particular I am not sure how to solve problem 2.

thanks, Hamish

comment:8 in reply to:  5 Changed 12 years ago by martinl

Replying to hamish:

bug in the last change? r3.univar, rows*cols*depths, not rows*cols:

@@ -111,6 +113,12 @@
 
     map_type = G3d_tileTypeMap(map);
-    stats = create_univar_stat_struct(map_type, cols * rows * depths);
-    sscanf(param.percentile->answer, "%i", &stats->perc);
+
+    i = 0;
+    while(param.percentile->answers[i])
+	i++;
+    stats = create_univar_stat_struct(map_type, cols * rows, i);
+    for(i = 0; i < stats->n_perc; i++) {
+	sscanf(param.percentile->answers[i], "%i", &stats->perc[i]);
+    }

sure, sorry, I fixed in trunk now.

Martin

comment:9 Changed 12 years ago by hamish

ok to close this bug?

see changesets r29848, r29891, r29904

Hamish

comment:10 Changed 12 years ago by martinl

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.