changeset 3065:ee653971fa84

FixA: Figure out max Q during fitting. flys-artifacts/trunk@4649 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 13 Jun 2012 10:19:44 +0000
parents 478e8d9d88ba
children 4c22194b733a
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/AnalysisPeriod.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java
diffstat 4 files changed, 67 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jun 13 09:28:39 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jun 13 10:19:44 2012 +0000
@@ -1,3 +1,20 @@
+2012-06-11	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/AnalysisPeriod.java:
+	  Max Q is store in column "max_q" in Parameters now. So function can be plotted
+	  bewtween calculated kms, too.
+	  For function sampling use something like this.:
+
+	    double [] maxQ = parameters.interpolate("km", 42.3", new String [] { "max_q" });
+	    double maxSampleQ = 10000d;
+
+	    if (maxQ != null) {
+	        maxSampleQ = Math.min(2000d, Math.abs(maxQ[0]));
+	        maxSampleQ += 0.05*maxSampleQ;
+	   }
+
 2012-06-13	Christian Lins	<christian.lins@intevation.de>
 
 	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/AnalysisPeriod.java	Wed Jun 13 09:28:39 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/AnalysisPeriod.java	Wed Jun 13 10:19:44 2012 +0000
@@ -57,5 +57,24 @@
     public QWD getQSectorAverage(int i) {
         return qSectorAverages[i];
     }
+
+    public double getMaxQ() {
+        double maxQ = -Double.MAX_VALUE;
+        if (qwds != null) {
+            for (QWD qwd: qwds) {
+                if (qwd.getQ() > maxQ) {
+                    maxQ = qwd.getQ();
+                }
+            }
+        }
+        if (qSectorAverages != null) {
+            for (QWD qwd: qSectorAverages) {
+                if (qwd != null && qwd.getQ() > maxQ) {
+                    maxQ = qwd.getQ();
+                }
+            }
+        }
+        return maxQ;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java	Wed Jun 13 09:28:39 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java	Wed Jun 13 10:19:44 2012 +0000
@@ -113,6 +113,18 @@
         return referenced != null ? (QW [])referenced.clone() : null;
     }
 
+    public double getMaxQ() {
+        double maxQ = -Double.MAX_VALUE;
+        if (referenced != null) {
+            for (QW qw: referenced) {
+                if (qw.getQ() > maxQ) {
+                    maxQ = qw.getQ();
+                }
+            }
+        }
+        return maxQ;
+    }
+
     public double [] getParameters() {
         return parameters;
     }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Wed Jun 13 09:28:39 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Wed Jun 13 10:19:44 2012 +0000
@@ -207,6 +207,7 @@
 
         int kmIndex             = results.columnIndex("km");
         int chiSqrIndex         = results.columnIndex("chi_sqr");
+        int maxQIndex           = results.columnIndex("max_q");
         int [] parameterIndices = results.columnIndices(parameterNames);
 
         int numFailed = 0;
@@ -240,6 +241,7 @@
 
             results.set(row, kmIndex, km);
             results.set(row, chiSqrIndex, fitting.getChiSquare());
+            results.set(row, maxQIndex, fitting.getMaxQ());
             invalid |= results.set(
                 row, parameterIndices, fitting.getParameters());
         }
@@ -309,6 +311,7 @@
         Range range = new Range(from, to);
 
         int kmIndex = parameters.columnIndex("km");
+        int maxQIndex = parameters.columnIndex("max_q");
 
         ColumnCache cc = new ColumnCache();
 
@@ -427,6 +430,19 @@
                 periodResults.add(periodResult);
             }
 
+            double maxQ = -Double.MAX_VALUE;
+            for (AnalysisPeriod ap: periodResults) {
+                double q = ap.getMaxQ();
+                if (q > maxQ) {
+                    maxQ = q;
+                }
+            }
+
+            double oldMaxQ = parameters.get(row, maxQIndex);
+            if (oldMaxQ < maxQ) {
+                parameters.set(row, maxQIndex, maxQ);
+            }
+
             results.add(km, periodResults.toArray(
                 new AnalysisPeriod[periodResults.size()]));
         }
@@ -559,10 +575,11 @@
     }
 
     protected static String [] createColumnNames(String [] parameters) {
-        String [] result = new String[parameters.length + 2];
+        String [] result = new String[parameters.length + 3];
         result[0] = "km";
         result[1] = "chi_sqr";
-        System.arraycopy(parameters, 0, result, 2, parameters.length);
+        result[2] = "max_q";
+        System.arraycopy(parameters, 0, result, 3, parameters.length);
         return result;
     }
 }

http://dive4elements.wald.intevation.org