[PATCH] Fixed: missing commit

Wald Commits scm-commit at wald.intevation.org
Thu Aug 2 09:59:53 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1533196788 -7200
# Node ID 0274c7444b2d76b91e4928fe2475eab081c86e88
# Parent  392745cccedefbbca58c2e488187f9e41c759523
Fixed: missing commit
Outliers in fixation calculation are now shown within the other 'B' event themes and get a separate symbol (triangle).
Removed old outliers theme.
Also consider showpoints property.
Also consider pointsize property.

diff -r 392745cccede -r 0274c7444b2d artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java	Wed Aug 01 18:40:57 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixCalculation.java	Thu Aug 02 09:59:48 2018 +0200
@@ -42,31 +42,22 @@
 
     protected static class FitResult {
 
-        protected Parameters parameters;
-        protected KMIndex<QWD[]> referenced;
-        protected KMIndex<QWD[]> outliers;
+        private final Parameters parameters;
+        private final KMIndex<QWD[]> fixings;
 
-        public FitResult() {
-        }
-
-        public FitResult(final Parameters parameters, final KMIndex<QWD[]> referenced, final KMIndex<QWD[]> outliers) {
+        public FitResult(final Parameters parameters, final KMIndex<QWD[]> fixings) {
             this.parameters = parameters;
-            this.referenced = referenced;
-            this.outliers = outliers;
+            this.fixings = fixings;
         }
 
         public Parameters getParameters() {
             return this.parameters;
         }
 
-        public KMIndex<QWD[]> getReferenced() {
-            return this.referenced;
+        public KMIndex<QWD[]> getFixings() {
+            return this.fixings;
         }
-
-        public KMIndex<QWD[]> getOutliers() {
-            return this.outliers;
-        }
-    } // class FitResult
+    }
 
     /**
      * Helper class to bundle the meta information of a column
@@ -270,13 +261,13 @@
 
         final Fitting.QWDFactory qwdFactory = new Fitting.QWDFactory() {
             @Override
-            public QWD create(final double q, final double w, boolean isOutlier) {
+            public QWD create(final double q, final double w, double deltaW, boolean isOutlier) {
                 // Check all the event columns for close match
                 // and take the description and the date from meta.
                 for (int i = 0; i < qs.length; ++i) {
                     if (Math.abs(qs[i] - q) < EPSILON && Math.abs(ws[i] - w) < EPSILON) {
                         final Column column = eventColumns.get(i);
-                        return new QWD(qs[i], ws[i], column.getDescription(), column.getDate(), interpolated[i], 0d, column.getId(), isOutlier); // Use database id here
+                        return new QWD(qs[i], ws[i], column.getDescription(), column.getDate(), interpolated[i], deltaW, column.getId(), isOutlier); // Use database id here
                     }
                 }
                 log.warn("cannot find column for (" + q + ", " + w + ")");
@@ -284,8 +275,6 @@
             }
         };
 
-        final Fitting fitting = new Fitting(func, qwdFactory, this.preprocessing);
-
         final String[] parameterNames = func.getParameterNames();
 
         final Parameters results = new Parameters(StringUtils.join(STANDARD_COLUMNS, parameterNames));
@@ -298,8 +287,7 @@
             log.debug("number of kms: " + kms.length);
         }
 
-        final KMIndex<QWD[]> outliers = new KMIndex<>();
-        final KMIndex<QWD[]> referenced = new KMIndex<>(kms.length);
+        final KMIndex<QWD[]> fixings = new KMIndex<>();
 
         final int kmIndex = results.columnIndex("km");
         final int chiSqrIndex = results.columnIndex("chi_sqr");
@@ -309,30 +297,22 @@
 
         int numFailed = 0;
 
-        for (final double km2 : kms) {
-            final double km = km2;
+        for (final double km : kms) {
 
             // Fill Qs and Ws from event columns.
-            for (int j = 0; j < ws.length; ++j) {
+            for (int j = 0; j < ws.length; ++j) 
                 interpolated[j] = !eventColumns.get(j).getQW(km, qs, ws, j);
-            }
 
-            fitting.reset();
-
-            if (!fitting.fit(qs, ws)) {
+            final Fitting fitting = Fitting.fit(func, qwdFactory, this.preprocessing, qs, ws);
+            if (fitting == null) {
                 log.debug("Fitting for km: " + km + " failed");
                 ++numFailed;
                 addProblem(km, "fix.fitting.failed");
                 continue;
             }
-
-            final QWD[] refs = fitting.referencedToArray();
-
-            referenced.add(km, refs);
-
-            if (fitting.hasOutliers()) {
-                outliers.add(km, fitting.outliersToArray());
-            }
+            
+            final QWD[] fixingsArray = fitting.getFixingsArray();
+            fixings.add(km, fixingsArray);
 
             final int row = results.newRow();
             final double[] values = fitting.getParameters();
@@ -358,10 +338,9 @@
             results.removeNaNs();
         }
 
-        outliers.sort();
-        referenced.sort();
+        fixings.sort();
 
-        return new FitResult(results, referenced, outliers);
+        return new FitResult(results, fixings);
     }
 
     public CalculationResult calculate() {
@@ -387,8 +366,8 @@
             final Object o = result.getData();
             if (o instanceof FixResult) {
                 final FixResult fr = (FixResult) o;
-                fr.makeReferenceEventsDatesUnique();
-                fr.remapReferenceIndicesToRank();
+                fr.makeEventsDatesUnique();
+                fr.remapEventIndicesToRank();
             }
         }
 
@@ -396,5 +375,4 @@
     }
 
     protected abstract CalculationResult innerCalculate(FixingsOverview overview, Function function);
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
+}
\ No newline at end of file


More information about the Dive4Elements-commits mailing list