diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java @ 2992:0abdede5a0b8

FixA: Added facet to return delta w/t as CSV flys-artifacts/trunk@4543 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 28 May 2012 18:35:01 +0000
parents 063b784b60b4
children 70469e3d34b9
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Sun May 27 18:11:31 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java	Mon May 28 18:35:01 2012 +0000
@@ -125,6 +125,8 @@
 
     public CalculationResult calculate() {
 
+        boolean debug = log.isDebugEnabled();
+
         FixingsOverview overview =
             FixingsOverviewFactory.getOverview(river);
 
@@ -173,7 +175,7 @@
             return new CalculationResult(this);
         }
 
-        double [] kms = DoubleUtil.explode(from, to, step);
+        double [] kms = DoubleUtil.explode(from, to, step / 1000.0);
 
         double [] ws = new double[dataColumns.size()];
         double [] qs = new double[ws.length];
@@ -185,6 +187,12 @@
 
         boolean invalid = false;
 
+        if (debug) {
+            log.debug("number of kms: " + kms.length);
+        }
+
+        int numFailed = 0;
+
         for (int i = 0; i < kms.length; ++i) {
             double km = kms[i];
 
@@ -198,6 +206,7 @@
             // TODO: Do preprocessing here!
             double [] parameters = fit(func, km, ws, qs);
             if (parameters == null) { // Problems are reported already.
+                ++numFailed;
                 continue;
             }
 
@@ -215,6 +224,11 @@
             // TODO: Calculate statistics, too!
         }
 
+        if (debug) {
+            log.debug("success: " + (kms.length - numFailed));
+            log.debug("failed: " + numFailed);
+        }
+
         if (invalid) {
             // TODO: i18n
             addProblem("fix.invalid.values");
@@ -408,6 +422,7 @@
             return cf.fit(function, function.getInitialGuess());
         }
         catch (MathException me) {
+            log.warn(me, me);
             addProblem(km, "fix.fitting.failed");
         }
 

http://dive4elements.wald.intevation.org