changeset 4813:bf2fd9c58ac4

Fixed MINFO SQ calculation. * Fixed calculation of sieve 8. * Fixed calculation of 'Geschiebetransport'. * Fixed calculation of fractions (Sand, gravel, coarse).
author Raimund Renkert <rrenkert@intevation.de>
date Sun, 20 Jan 2013 15:02:19 +0100
parents a7d080347ac3
children 47c529e2be26
files flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SieveArray.java
diffstat 3 files changed, 24 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java	Fri Jan 11 13:57:38 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java	Sun Jan 20 15:02:19 2013 +0100
@@ -11,11 +11,11 @@
     private static final Log log =
         LogFactory.getLog(Measurement.class);
 
-    public static final double ADD_8 = Math.log(10) - Math.log(8)/Math.log(6.3);
-    public static final double SCALE_8 = Math.log(6.3);
+    public static final double LOG_10_8 = Math.log(10) - Math.log(8);
+    public static final double SCALE_8 = Math.log(10) - Math.log(6.3);
 
-    public static final double ADD_4 = Math.log(8) - Math.log(6.3)/Math.log(10);
-    public static final double SCALE_4 = Math.log(6.3);
+    public static final double LOG_8_6 = Math.log(8) - Math.log(6.3);
+    public static final double SCALE_4 = Math.log(10) - Math.log(6.3);
 
     protected Map<String, Object> data;
 
@@ -123,6 +123,7 @@
         if (sieveArray == null) {
             sieveArray = calculateSieveArray();
         }
+        adjustSieves();
         return sieveArray;
     }
 
@@ -171,11 +172,15 @@
 
         deleteSieve(6.3);
 
-        double eightValue   = ADD_8 - SCALE_8*sixValue + tenValue;
-        double newFourValue = ADD_4 - SCALE_4*sixValue + fourValue;
+        double eightValue = ((LOG_10_8 / SCALE_8*sixValue) + tenValue);
+        double newFourValue = ((LOG_8_6 / SCALE_4*sixValue) + fourValue);
 
+        deleteSieve(4.0);
         sieves.add(new Sieve(8d, eightValue));
         sieves.add(new Sieve(4d, newFourValue));
+        sieveArray.adjust(
+            eightValue/sieveArray.totalLoad(),
+            newFourValue/sieveArray.totalLoad());
     }
 
     protected SieveArray calculateSieveArray() {
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java	Fri Jan 11 13:57:38 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java	Sun Jan 20 15:02:19 2013 +0100
@@ -1,6 +1,7 @@
 package de.intevation.flys.artifacts.model.sq;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collections;
 import java.util.Date;
@@ -52,7 +53,7 @@
             "g.UFERABLINKS  AS UFERABLINKS," +
             "m.TSCHWEB      AS TSCHWEB," +
             "m.TSAND        AS TSAND," +
-            "gp.GTRIEB      AS GTRIEB," +
+            "gp.GTRIEB_F      AS GTRIEB," +
             "m.TGESCHIEBE   AS TGESCHIEBE," +
             "si.SIEB01 AS SIEB01, si.SIEB02 AS SIEB02," +
             "si.SIEB03 AS SIEB03, si.SIEB04 AS SIEB04," +
@@ -328,10 +329,6 @@
             accumulated.add(accumulate(same));
         }
 
-        for (Measurement m: accumulated) {
-            m.adjustSieves();
-        }
-
         if (debug) {
             log.debug("Before date separation: " + accumulated.size());
         }
@@ -459,10 +456,10 @@
         if (N == 1) {
             return measuments.get(0);
         }
-
         TreeMap<Double, double []> diameters =
             new TreeMap<Double, double []>(Sieve.DIAMETER_CMP);
 
+        double sumGTrieb = 0d;
         for (Measurement m: measuments) {
             for (Sieve s: m.getSieves()) {
                 Double key = s.getDiameter();
@@ -473,6 +470,8 @@
                 }
                 sum[0] += s.getLoad();
             }
+            // calculate 'Geschiebetrieb'
+            sumGTrieb += m.get("GTRIEB");
         }
         List<Sieve> accumulatedSieves = new ArrayList<Sieve>(diameters.size());
         for (Map.Entry<Double, double []> entry: diameters.entrySet()) {
@@ -480,10 +479,10 @@
                 new Sieve(entry.getKey(),
                     entry.getValue()[0]/N));
         }
-
         Map<String, Object> data =
             new HashMap<String, Object>(measuments.get(0).getData());
 
+        data.put("GTRIEB", sumGTrieb/N);
         return new Measurement(data, accumulatedSieves);
     }
 }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SieveArray.java	Fri Jan 11 13:57:38 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SieveArray.java	Sun Jan 20 15:02:19 2013 +0100
@@ -51,6 +51,11 @@
         }
     }
 
+    public void adjust(double eight, double four) {
+        this.normLoads[4] = eight;
+        this.normLoads[5] = four;
+    }
+
     /**
      * Gets the loads for this instance.
      *
@@ -91,7 +96,7 @@
 
     public double sandNormFraction() {
         double sum = 0d;
-        for (int i = 8; i < normLoads.length; ++i) {
+        for (int i = 7; i < normLoads.length; ++i) {
             sum += normLoads[i];
         }
         return sum;
@@ -107,7 +112,7 @@
 
     public double gravelNormFraction() {
         double sum = 0d;
-        for (int i = 4; i < 8; ++i) {
+        for (int i = 4; i < 7; ++i) {
             sum += normLoads[i];
         }
         return sum;

http://dive4elements.wald.intevation.org