changeset 8185:76e1e9d81ce2

Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
author Tom Gottfried <tom@intevation.de>
date Thu, 04 Sep 2014 12:03:02 +0200 (2014-09-04)
parents 143b24546b26
children a1ceacf15d3a
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java
diffstat 2 files changed, 32 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Thu Sep 04 12:00:17 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Thu Sep 04 12:03:02 2014 +0200
@@ -31,8 +31,7 @@
     public static final int GF_TOTAL              =  6;
     public static final int GF_BED_LOAD           =  7;
     public static final int GF_BED_LOAD_SUSP_SAND =  8;
-    public static final int GF_AVERAGE            =  9;
-    public static final int GF_MAX                =  9;
+    public static final int GF_MAX                =  8;
 
     public static final int [] MEASUREMENT_STATION_GF = {
         /* GF_COARSE             */ Station.BED_LOAD,
@@ -62,7 +61,6 @@
         if ("total".equals(name))              return GF_TOTAL;
         if ("bed_load".equals(name))           return GF_BED_LOAD;
         if ("bed_load_susp_sand".equals(name)) return GF_BED_LOAD_SUSP_SAND;
-        if ("average".equals(name))            return GF_AVERAGE;
         return GF_UNKNOWN;
     }
 
@@ -116,7 +114,7 @@
         }
 
         public Load(
-            int    id, 
+            int    id,
             int    kind,
             String description,
             Date   startTime,
@@ -152,7 +150,7 @@
         public boolean isEpoch() {
             return startTime != null && stopTime != null;
         }
-    } // class SedimentLoad
+    } // class Load
 
     public static class Station implements Serializable {
 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Thu Sep 04 12:00:17 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Thu Sep 04 12:03:02 2014 +0200
@@ -79,20 +79,16 @@
         SedimentLoadData.GF_SUSP_SEDIMENT
     };
 
-    public static final int [] AVERAGE = {
-        SedimentLoadData.GF_AVERAGE
-    };
-
-    public static final class GrainFraction {
+    public static final class LoadSum {
         private String description;
         private int [] grainFractions;
 
-        public GrainFraction(String description, int [] grainFractions) {
+        public LoadSum(String description, int [] grainFractions) {
             this.description = description;
             this.grainFractions = grainFractions;
         }
-        public static final GrainFraction make(String description, int [] grainFractions) {
-            return new GrainFraction(description, grainFractions);
+        public static final LoadSum make(String description, int [] grainFractions) {
+            return new LoadSum(description, grainFractions);
         }
 
         public String getDescription() {
@@ -102,20 +98,19 @@
         public int [] getGrainFractions() {
             return grainFractions;
         }
-    } // class GrainFraction
+    } // class LoadSum
 
-    public static final GrainFraction [] GRAIN_FRACTIONS = {
-        // Grain fraction names are alignt to the grain_fractions table
-        GrainFraction.make("total",              TOTAL_LOAD),
-        GrainFraction.make("bed_load",           BED_LOAD),
-        GrainFraction.make("bed_load_susp_sand", BED_LOAD_SUSP_SAND),
-        GrainFraction.make("coarse",             COARSE),
-        GrainFraction.make("fine_middle",        FINE_MIDDLE),
-        GrainFraction.make("sand",               SAND) ,
-        GrainFraction.make("susp_sand",          SUSP_SAND),
-        GrainFraction.make("susp_sand_bed",      SUSP_SAND_BED),
-        GrainFraction.make("suspended_sediment", SUSP_SEDIMENT),
-        GrainFraction.make("average",            AVERAGE),
+    public static final LoadSum [] LOAD_SUMS = {
+        // Names are alignt to the grain_fractions table
+        LoadSum.make("total",              TOTAL_LOAD),
+        LoadSum.make("bed_load",           BED_LOAD),
+        LoadSum.make("bed_load_susp_sand", BED_LOAD_SUSP_SAND),
+        LoadSum.make("coarse",             COARSE),
+        LoadSum.make("fine_middle",        FINE_MIDDLE),
+        LoadSum.make("sand",               SAND) ,
+        LoadSum.make("susp_sand",          SUSP_SAND),
+        LoadSum.make("susp_sand_bed",      SUSP_SAND_BED),
+        LoadSum.make("suspended_sediment", SUSP_SEDIMENT),
     };
 
     public static class Sum implements Value.Visitor {
@@ -245,22 +240,23 @@
                 .add(new TimeRangeIntersects(year));
             String period = Integer.toString(year);
 
-            for (GrainFraction gf: GRAIN_FRACTIONS) {
+            for (LoadSum ls: LOAD_SUMS) {
+
                 double [][] result = sum(
-                    sld, gf.getGrainFractions(), filter, sum, isKmUp,
+                    sld, ls.getGrainFractions(), filter, sum, isKmUp,
                     missingFractions);
 
                 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
                     // TODO: resolve i18n
                     addProblem("minfo.sediment.load.no.fractions",
-                        gf.getDescription());
+                        ls.getDescription());
                     continue;
                 }
 
                 transformT2M3(sd, year, result);
 
                 SedimentLoadDataResult.Fraction sldrf =
-                    new SedimentLoadDataResult.Fraction(gf.getDescription(), result, period);
+                    new SedimentLoadDataResult.Fraction(ls.getDescription(), result, period);
 
                 sldr.addFraction(sldrf);
             }
@@ -298,7 +294,7 @@
             String period = Integer.toString(epoch[0]) + " - " +
                 Integer.toString(epoch[1]);
 
-            for (GrainFraction gf: GRAIN_FRACTIONS) {
+            for (LoadSum ls: LOAD_SUMS) {
 
                 List<double [][]> results = new ArrayList<double [][]>();
 
@@ -307,13 +303,13 @@
                         .add(new TimeRangeIntersects(year));
 
                     double [][] result = sum(
-                        sld, gf.getGrainFractions(), filter, sum, isKmUp,
+                        sld, ls.getGrainFractions(), filter, sum, isKmUp,
                         missingFractions);
 
                     if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
                         // TODO: resolve i18n
                         addProblem("minfo.sediment.load.no.fractions",
-                            gf.getDescription());
+                            ls.getDescription());
                         continue;
                     }
 
@@ -324,7 +320,7 @@
                 double [][] result = average(results);
 
                 SedimentLoadDataResult.Fraction sldrf =
-                    new SedimentLoadDataResult.Fraction(gf.getDescription(),
+                    new SedimentLoadDataResult.Fraction(ls.getDescription(),
                                                         result, period);
                 sldr.addFraction(sldrf);
             }
@@ -360,20 +356,20 @@
 
             Sum sum = new Sum();
 
-            for (GrainFraction gf: GRAIN_FRACTIONS) {
+            for (LoadSum ls: LOAD_SUMS) {
                 double [][] result = sum(
-                    sld, gf.getGrainFractions(), filter, sum, isKmUp,
+                    sld, ls.getGrainFractions(), filter, sum, isKmUp,
                     missingFractions);
 
                 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
                     // TODO: resolve i18n
                     addProblem("minfo.sediment.load.no.fractions",
-                        gf.getDescription());
+                        ls.getDescription());
                     continue;
                 }
                 transformT2M3(sd, year, result);
                 SedimentLoadDataResult.Fraction sldrf =
-                    new SedimentLoadDataResult.Fraction(gf.getDescription(), result, period);
+                    new SedimentLoadDataResult.Fraction(ls.getDescription(), result, period);
                 sldr.addFraction(sldrf);
             }
         }

http://dive4elements.wald.intevation.org