Displaying differences for changeset |
@@ -162,6 +162,7 @@ |
JSONArray output = new JSONArray(); |
List<List<Object>> filtered = new ArrayList(); |
JSONObject statResult = new JSONObject(); |
+ JSONObject statResultLocal = new JSONObject(); |
if (!metadata_only) { |
Document datesQuery = new Document(); |
@@ -230,6 +231,23 @@ |
} |
} |
} |
+ |
+ // Add locally computed stats |
+ for (List<Object> objList: filtered) { |
+ for (int i=1; i<header.size(); i++) { |
+ double[] vals = new double[filtered.size()]; |
+ for (int j=0; j<filtered.size(); j++) { |
+ vals[j] = (double) filtered.get(j).get(i); |
+ } |
+ for (String stat : stats) { |
+ String key = header.get(i) + "_" + stat; |
+ if ("min".equals(stat)) statResultLocal.put(key, oms3.util.Statistics.min(vals)); |
+ if ("max".equals(stat)) statResultLocal.put(key, oms3.util.Statistics.max(vals)); |
+ if ("avg".equals(stat)) statResultLocal.put(key, oms3.util.Statistics.mean(vals)); |
+ if ("stdDevPop".equals(stat)) statResultLocal.put(key, oms3.util.Statistics.stddev(vals)); |
+ } |
+ } |
+ } |
} |
} |
@@ -247,6 +265,7 @@ |
if (compute_stats) { |
res.put("statistics", statResult); |
+ res.put("statistics_local", statResultLocal); |
} |
return res; |