changeset 3737:976be312a84c

Simplified code for extreme curves. flys-artifacts/trunk@5412 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 09 Sep 2012 17:19:50 +0000 (2012-09-09)
parents da1969b05292
children 34da25796c21
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java
diffstat 2 files changed, 25 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Sun Sep 09 15:29:06 2012 +0000
+++ b/flys-artifacts/ChangeLog	Sun Sep 09 17:19:50 2012 +0000
@@ -1,3 +1,10 @@
+2012-09-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java:
+	  Store Ws and Qs in double arrays instead of WQ objects (as
+	  they are return from WstValueTable.interpolateTabular()).
+	  This simplifies the code and should be more memory effective.
+
 2012-09-09	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/math/Linear.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java	Sun Sep 09 15:29:06 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java	Sun Sep 09 17:19:50 2012 +0000
@@ -6,8 +6,6 @@
 
 import de.intevation.flys.artifacts.math.fitting.FunctionFactory;
 
-import de.intevation.flys.artifacts.model.QW;
-
 import java.io.Serializable;
 
 import java.lang.ref.SoftReference;
@@ -23,7 +21,8 @@
 {
     private static Logger log = Logger.getLogger(Curve.class);
 
-    protected QW []     qws;
+    protected double [] qs;
+    protected double [] ws;
     protected String    function;
     protected double [] coeffs;
 
@@ -34,14 +33,24 @@
     public Curve() {
     }
 
-    public Curve(QW [] qws, String function, double [] coeffs) {
-        this.qws      = qws;
+    public Curve(
+        double [] qs,
+        double [] ws,
+        String    function,
+        double [] coeffs
+    ) {
+        this.qs       = qs;
+        this.ws       = ws;
         this.function = function;
         this.coeffs   = coeffs;
     }
 
-    public QW [] getQWs() {
-        return qws;
+    public double [] getQs() {
+        return qs;
+    }
+
+    public double [] getWs() {
+        return ws;
     }
 
     public String getFunction() {
@@ -54,8 +63,8 @@
 
     @Override
     public double value(double x) {
-        if (x < qws[0].getQ()) return Double.NaN;
-        return (x <= qws[qws.length-1].getQ()
+        if (x < qs[0]) return Double.NaN;
+        return (x <= qs[qs.length-1]
             ? getSpline()
             : getExtrapolation()).value(x);
     }
@@ -85,13 +94,6 @@
 
     protected Function createSpline() {
         SplineInterpolator interpolator = new SplineInterpolator();
-        double [] qs = new double[qws.length];
-        double [] ws = new double[qws.length];
-        for (int i = 0; i < qws.length; ++i) {
-            QW qw = qws[i];
-            qs[i] = qw.getQ();
-            ws[i] = qw.getW();
-        }
         try {
             return new UnivariateRealFunctionFunction(
                 interpolator.interpolate(qs, ws));

http://dive4elements.wald.intevation.org