changeset 8183:baa7df019df3

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 04 Sep 2014 11:15:34 +0200
parents 0b4cd7a5f079 (current diff) 00066d3add94 (diff)
children 143b24546b26 407c9598352f
files
diffstat 14 files changed, 199 insertions(+), 212 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/minfo.xml	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/doc/conf/artifacts/minfo.xml	Thu Sep 04 11:15:34 2014 +0200
@@ -499,22 +499,22 @@
                     <facets>
                         <facet name="sedimentload.ta.coarse"/>
                         <facet name="sedimentload.ta.sand"/>
-                        <facet name="sedimentload.ta.finemiddle"/>
+                        <facet name="sedimentload.ta.fine_middle"/>
                         <facet name="sedimentload.ta.susp_sand"/>
                         <facet name="sedimentload.ta.susp_sand_bed"/>
-                        <facet name="sedimentload.ta.susp_sediment"/>
-                        <facet name="sedimentload.ta.total_load"/>
-                        <facet name="sedimentload.ta.unknown"/>
+                        <facet name="sedimentload.ta.suspended_sediment"/>
                         <facet name="sedimentload.ta.total"/>
+                        <facet name="sedimentload.ta.bed_load"/>
+                        <facet name="sedimentload.ta.bed_load_susp_sand"/>
                         <facet name="sedimentload.m3a.coarse"/>
                         <facet name="sedimentload.m3a.sand"/>
-                        <facet name="sedimentload.m3a.finemiddle"/>
+                        <facet name="sedimentload.m3a.fine_middle"/>
                         <facet name="sedimentload.m3a.susp_sand"/>
                         <facet name="sedimentload.m3a.susp_sand_bed"/>
-                        <facet name="sedimentload.m3a.susp_sediment"/>
-                        <facet name="sedimentload.m3a.total_load"/>
-                        <facet name="sedimentload.m3a.unknown"/>
+                        <facet name="sedimentload.m3a.suspended_sediment"/>
                         <facet name="sedimentload.m3a.total"/>
+                        <facet name="sedimentload.m3a.bed_load"/>
+                        <facet name="sedimentload.m3a.bed_load_susp_sand"/>
                         <facet name="sedimentload_ls.manualpoints"/>
                         <facet name="flow_velocity.totalchannel" description="A facet for total channels"/>
                         <facet name="flow_velocity.mainchannel" description="A facet for main channels"/>
--- a/artifacts/doc/conf/meta-data.xml	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/doc/conf/meta-data.xml	Thu Sep 04 11:15:34 2014 +0200
@@ -1017,7 +1017,7 @@
                     <dc:attribute name="description" value="${facet_description}"/>
                     <dc:attribute name="ids" value="${facet_num}"/>
                     <dc:attribute name="artifact-id" value="${a_gid}"/>
-                    <dc:attribute name="out" value="sedimentload_ls"/>
+                    <dc:attribute name="out" value="${out_name}"/>
                   </dc:element>
                 </dc:for-each>
               </load>
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Thu Sep 04 11:15:34 2014 +0200
@@ -21,29 +21,29 @@
 
 public class SedimentLoadData implements Serializable
 {
-    public static final int GF_UNKNOWN        = -1;
-    public static final int GF_COARSE         =  0;
-    public static final int GF_FINE_MIDDLE    =  1;
-    public static final int GF_SAND           =  2;
-    public static final int GF_SUSP_SAND      =  3;
-    public static final int GF_SUSP_SAND_BED  =  4;
-    public static final int GF_SUSP_SEDIMENT  =  5;
-    public static final int GF_TOTAL          =  6;
-    public static final int GF_BED_LOAD       =  7;
-    public static final int GF_SUSPENDED_LOAD =  8;
-    public static final int GF_AVERAGE        =  9;
-    public static final int GF_MAX            =  9;
+    public static final int GF_UNKNOWN            = -1;
+    public static final int GF_COARSE             =  0;
+    public static final int GF_FINE_MIDDLE        =  1;
+    public static final int GF_SAND               =  2;
+    public static final int GF_SUSP_SAND          =  3;
+    public static final int GF_SUSP_SAND_BED      =  4;
+    public static final int GF_SUSP_SEDIMENT      =  5;
+    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 [] MEASUREMENT_STATION_GF = {
-        /* GF_COARSE         */ Station.BED_LOAD,
-        /* GF_FINE_MIDDLE    */ Station.BED_LOAD,
-        /* GF_SAND           */ Station.BED_LOAD,
-        /* GF_SUSP_SAND      */ Station.BED_LOAD,
-        /* GF_SUSP_SAND_BED  */ Station.BED_LOAD,
-        /* GF_SUSP_SEDIMENT  */ Station.SUSPENDED,
-        /* GF_TOTAL          */ Station.BED_LOAD|Station.SUSPENDED,
-        /* GF_BED_LOAD       */ Station.BED_LOAD,
-        /* GF_SUSPENDED_LOAD */ Station.BED_LOAD
+        /* GF_COARSE             */ Station.BED_LOAD,
+        /* GF_FINE_MIDDLE        */ Station.BED_LOAD,
+        /* GF_SAND               */ Station.BED_LOAD,
+        /* GF_SUSP_SAND          */ Station.BED_LOAD,
+        /* GF_SUSP_SAND_BED      */ Station.BED_LOAD,
+        /* GF_SUSP_SEDIMENT      */ Station.SUSPENDED,
+        /* GF_TOTAL              */ Station.BED_LOAD|Station.SUSPENDED,
+        /* GF_BED_LOAD           */ Station.BED_LOAD,
+        /* GF_BED_LOAD_SUSP_SAND */ Station.BED_LOAD
     };
 
     public static final int measurementStationType(int grainFraction) {
@@ -61,7 +61,7 @@
         if ("suspended_sediment".equals(name)) return GF_SUSP_SEDIMENT;
         if ("total".equals(name))              return GF_TOTAL;
         if ("bed_load".equals(name))           return GF_BED_LOAD;
-        if ("suspended_load".equals(name))     return GF_SUSPENDED_LOAD;
+        if ("bed_load_susp_sand".equals(name)) return GF_BED_LOAD_SUSP_SAND;
         if ("average".equals(name))            return GF_AVERAGE;
         return GF_UNKNOWN;
     }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Thu Sep 04 11:15:34 2014 +0200
@@ -35,63 +35,51 @@
     private static final Logger log = Logger
         .getLogger(SedimentLoadDataCalculation.class);
 
-    public static final int [] TOTAL_LOAD_FLYS = {
+    public static final int [] TOTAL_LOAD = {
         SedimentLoadData.GF_COARSE,
         SedimentLoadData.GF_FINE_MIDDLE,
         SedimentLoadData.GF_SAND,
         SedimentLoadData.GF_SUSP_SEDIMENT
     };
 
-    public static final int [] BED_LOAD_FLYS = {
+    public static final int [] BED_LOAD = {
         SedimentLoadData.GF_COARSE,
         SedimentLoadData.GF_FINE_MIDDLE,
         SedimentLoadData.GF_SAND
     };
 
-    public static final int [] BED_LOAD_SUSP_SAND_FLYS = {
+    public static final int [] BED_LOAD_SUSP_SAND = {
         SedimentLoadData.GF_COARSE,
         SedimentLoadData.GF_FINE_MIDDLE,
         SedimentLoadData.GF_SAND,
         SedimentLoadData.GF_SUSP_SAND
     };
 
-    public static final int [] TOTAL_LOAD_BFG = {
-        SedimentLoadData.GF_TOTAL
-    };
-
-    public static final int [] BED_LOAD_BFG = {
-        SedimentLoadData.GF_BED_LOAD
-    };
-
-    public static final int [] SUSPENDED_LOAD_BFG = {
-        SedimentLoadData.GF_SUSPENDED_LOAD
-    };
-
-    public static final int [] COARSE_FLYS = {
+    public static final int [] COARSE = {
         SedimentLoadData.GF_COARSE
     };
 
-    public static final int [] FINE_MIDDLE_FLYS = {
+    public static final int [] FINE_MIDDLE = {
         SedimentLoadData.GF_FINE_MIDDLE
     };
 
-    public static final int [] SAND_FLYS = {
+    public static final int [] SAND = {
         SedimentLoadData.GF_SAND
     };
 
-    public static final int [] SUSP_SAND_FLYS = {
+    public static final int [] SUSP_SAND = {
         SedimentLoadData.GF_SUSP_SAND
     };
 
-    public static final int [] SUSP_SAND_BED_FLYS = {
+    public static final int [] SUSP_SAND_BED = {
         SedimentLoadData.GF_SUSP_SAND_BED
     };
 
-    public static final int [] SUSP_SEDIMENT_FLYS = {
+    public static final int [] SUSP_SEDIMENT = {
         SedimentLoadData.GF_SUSP_SEDIMENT
     };
 
-    public static final int [] AVERAGE_FLYS = {
+    public static final int [] AVERAGE = {
         SedimentLoadData.GF_AVERAGE
     };
 
@@ -117,21 +105,17 @@
     } // class GrainFraction
 
     public static final GrainFraction [] GRAIN_FRACTIONS = {
-        // TODO: i18n for bfg parts
         // Grain fraction names are alignt to the grain_fractions table
-        GrainFraction.make("total",              TOTAL_LOAD_FLYS),
-        GrainFraction.make("bed_load",           BED_LOAD_FLYS),
-        GrainFraction.make("susp_sand_bed",      BED_LOAD_SUSP_SAND_FLYS),
-        GrainFraction.make("total.bfg",          TOTAL_LOAD_BFG),
-        GrainFraction.make("bed_load.bfg",       BED_LOAD_BFG),
-        GrainFraction.make("suspended_load.bfg", SUSPENDED_LOAD_BFG),
-        GrainFraction.make("coarse",             COARSE_FLYS),
-        GrainFraction.make("fine_middle",        FINE_MIDDLE_FLYS),
-        GrainFraction.make("sand",               SAND_FLYS) ,
-        GrainFraction.make("susp_sand",          SUSP_SAND_FLYS),
-        GrainFraction.make("susp_sand_bed",      SUSP_SAND_BED_FLYS),
-        GrainFraction.make("suspended_sediment", SUSP_SEDIMENT_FLYS),
-        GrainFraction.make("average",            AVERAGE_FLYS),
+        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 class Sum implements Value.Visitor {
@@ -300,26 +284,28 @@
         boolean isKmUp = isKmUp();
         Set<Integer> missingFractions = new TreeSet<Integer>();
 
+        Sum sum = new Sum();
+
         SedimentDensity sd = getSedimentDensity();
 
         // They are not epochs, they are single years!
         Not notEpochs = new Not(IsEpoch.INSTANCE);
 
         for (int [] epoch: epochs) {
-            List<double [][]> results = new ArrayList<double [][]>();
-
             int min = Math.min(epoch[0], epoch[1]);
             int max = Math.max(epoch[0], epoch[1]);
 
             String period = Integer.toString(epoch[0]) + " - " +
                 Integer.toString(epoch[1]);
-            for (int year = min; year <= max; ++year) {
-                Value.Filter filter = new And(notEpochs)
-                    .add(new TimeRangeIntersects(year));
 
-                Sum sum = new Sum();
+            for (GrainFraction gf: GRAIN_FRACTIONS) {
 
-                for (GrainFraction gf: GRAIN_FRACTIONS) {
+                List<double [][]> results = new ArrayList<double [][]>();
+
+                for (int year = min; year <= max; ++year) {
+                    Value.Filter filter = new And(notEpochs)
+                        .add(new TimeRangeIntersects(year));
+
                     double [][] result = sum(
                         sld, gf.getGrainFractions(), filter, sum, isKmUp,
                         missingFractions);
@@ -334,13 +320,15 @@
                     transformT2M3(sd, year, result);
                     results.add(result);
                 }
+
+                double [][] result = average(results);
+
+                SedimentLoadDataResult.Fraction sldrf =
+                    new SedimentLoadDataResult.Fraction(gf.getDescription(),
+                                                        result, period);
+                sldr.addFraction(sldrf);
             }
 
-            double [][] result = average(results);
-            // TODO: Optionally transform units.
-            SedimentLoadDataResult.Fraction sldrf =
-                new SedimentLoadDataResult.Fraction("TODO: nice description", result, period);
-            sldr.addFraction(sldrf);
         }
         // TODO: Generate messages for missing fractions.
         return new CalculationResult(sldr, this);
@@ -499,7 +487,7 @@
             for (int i = 0; i < kms.length; ++i) {
                 double km = kms[i];
                 double v = vs[i];
-                if (Double.isNaN(km) || Double.isNaN(v)) {
+                if (Double.isNaN(km)) {
                     continue;
                 }
                 XSum xsum = map.get(km);
@@ -513,12 +501,12 @@
         double [][] result = new double[2][map.size()];
         int i = 0;
         for (Map.Entry<Double, XSum> entry: map.entrySet()) {
-            result[i][0] = entry.getKey();
-            result[i][1] = entry.getValue().avg();
+            result[0][i] = entry.getKey();
+            result[1][i] = entry.getValue().avg();
             ++i;
         }
 
-        return null;
+        return result;
     }
 
 }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFacet.java	Thu Sep 04 11:15:34 2014 +0200
@@ -79,11 +79,10 @@
            from simple fractions from the database */
         String isCalculated = fraction_name.equals("total") ||
             fraction_name.equals("bed_load") ||
-            fraction_name.equals("suspended_load") ? "calc." : "";
+            fraction_name.equals("bed_load_susp_sand") ? "calc." : "";
         description = Resources.getMsg(
                 meta,
                 "facet.sedimentload." + isCalculated + fraction_name,
-                "Error: please add l10n for facet.sedimentload." + fraction_name,
                 new Object[] { periodString, i18nUnit });
 
         /* Is this necessary? */
@@ -93,7 +92,6 @@
 
     @Override
     public Object getData(Artifact artifact, CallContext context) {
-        logger.debug("Get data for sediment load with fraction: " + fraction);
 
         D4EArtifact flys = (D4EArtifact) artifact;
 
@@ -106,21 +104,15 @@
 
         SedimentLoadDataResult sdResult = (SedimentLoadDataResult) payload;
 
-        List<Fraction> fractions = sdResult.getFractionsByNameAndPeriod(
-            fraction, period
-        );
-        if (fractions == null) {
-            logger.warn("No result for fraction '" + fraction +
+        List<Fraction> fractions = sdResult.getFractions();
+
+        if (fractions.size() < index + 1) {
+            logger.error("No result for fraction '" + fraction +
                         "' and period '" + period + "'");
             return null;
         }
 
-        if (fractions.size() > 1) {
-            logger.error("Multiple results for fraction '" + fraction +
-                        "' and period '" + period + "'");
-        }
-
-        return fractions.get(0).getData();
+        return fractions.get(index).getData();
 
         /* Are gaps neccessary now?
         for (int x = 0; x < values[0].length-1; x++) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataResult.java	Thu Sep 04 11:15:34 2014 +0200
@@ -83,18 +83,5 @@
         return result.isEmpty() ? null : result;
     }
 
-    public List<Fraction> getFractionsByNameAndPeriod(
-            String name,
-            String period
-        ) {
-        List<Fraction> result = new ArrayList<Fraction>();
-        for (Fraction fraction: fractions) {
-            if (fraction.getName().equals(name) &&
-                fraction.getPeriod().equals(period)) {
-                result.add(fraction);
-            }
-        }
-        return result.isEmpty() ? null : result;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataValueFilter.java	Thu Sep 04 11:15:34 2014 +0200
@@ -12,6 +12,8 @@
 import java.util.Date;
 import java.util.List;
 
+import org.dive4elements.river.utils.DateUtil;
+
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Value;
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Value.Filter;
 
@@ -131,20 +133,8 @@
         }
 
         public TimeRangeIntersects(int startYear, int endYear) {
-            this(firstJan(Math.min(startYear, endYear)),
-                lastDec(Math.max(startYear, endYear)));
-        }
-
-        private static Date firstJan(int year) {
-            Calendar cal = Calendar.getInstance();
-            cal.set(year, 1, 1, 0, 0, 0);
-            return cal.getTime();
-        }
-
-        private static Date lastDec(int year) {
-            Calendar cal = Calendar.getInstance();
-            cal.set(year, 12, 31, 23, 59, 59);
-            return cal.getTime();
+            this(DateUtil.getStartDateFromYear(Math.min(startYear, endYear)),
+                 DateUtil.getEndDateFromYear(Math.max(startYear, endYear)));
         }
 
         public TimeRangeIntersects(Date a, Date b) {
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDataCalculate.java	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadDataCalculate.java	Thu Sep 04 11:15:34 2014 +0200
@@ -59,7 +59,12 @@
                     Facet    facet,
                     String   output
                 ) {
-                    return null;
+                    String name = facet.getName();
+                    if (name.endsWith("total") || name.endsWith("bed_load")
+                        || name.endsWith("bed_load_susp_sand")) {
+                        return Boolean.TRUE;
+                    }
+                    return Boolean.FALSE;
                 }
             });
     }
@@ -114,9 +119,10 @@
         for (Fraction fract: sdRes.getFractions()) {
             logger.debug("Adding facet for fraction '" + fract.getName() +
                          "' and period '" + fract.getPeriod() + "'");
-            facets.add(new SedimentLoadDataFacet(i++, fract.getName(),
+            facets.add(new SedimentLoadDataFacet(i, fract.getName(),
                           unit, fract.getPeriod(),
                           ComputeType.ADVANCE, id, hash, context));
+            i++;
         }
 
         facets.add(
--- a/artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/AbstractExporter.java	Thu Sep 04 11:15:34 2014 +0200
@@ -292,6 +292,10 @@
         return Resources.getMsg(context.getMeta(), key, def);
     }
 
+    protected String msg(String key, Object[] args) {
+        return Resources.getMsg(context.getMeta(), key, key, args);
+    }
+
     protected String msg(String key, String def, Object[] args) {
         return Resources.getMsg(context.getMeta(), key, def, args);
     }
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadExporter.java	Thu Sep 04 11:15:34 2014 +0200
@@ -44,34 +44,38 @@
 
     // i18n keys.
     public static final String CSV_KM =
-        "export.sedimentload_ls.csv.header.km";
+        "export.csv.header.km";
 
     public static final String CSV_YEAR =
-        "export.sedimentload_ls.csv.header.year";
+        "export.csv.header.year";
 
     public static final String CSV_COARSE =
-        "export.sedimentload_ls.csv.header.coarse";
+        "export.sedimentload.csv.header.coarse";
 
     public static final String CSV_FINEMIDDLE =
-        "export.sedimentload_ls.csv.header.finemiddle";
+        "export.sedimentload.csv.header.fine_middle";
 
     public static final String CSV_SAND =
-        "export.sedimentload_ls.csv.header.sand";
+        "export.sedimentload.csv.header.sand";
 
     public static final String CSV_SUSP_SAND =
-        "export.sedimentload_ls.csv.header.suspsand";
+        "export.sedimentload.csv.header.susp_sand";
 
     public static final String CSV_SUSP_SAND_BB =
-        "export.sedimentload_ls.csv.header.suspsandbb";
+        "export.sedimentload.csv.header.susp_sand_bed";
 
     public static final String CSV_SUSP_SEDIMENT =
-        "export.sedimentload_ls.csv.header.suspsediment";
+        "export.sedimentload.csv.header.suspended_sediment";
+
+    public static final String CSV_BED_LOAD =
+        "export.sedimentload.csv.header.bed_load";
+
+    public static final String CSV_BED_LOAD_SUSP_SAND =
+        "export.sedimentload.csv.header.bed_load_susp_sand";
 
     public static final String CSV_TOTAL =
-        "export.sedimentload_ls.csv.header.total";
+        "export.sedimentload.csv.header.total";
 
-    /* Header is: suspended_sediment, susp_sand, susp_sand_bed, sand,
-     * fine_middle, coarse, total */
     private static final String[] FRACTION_ORDER = {
         "suspended_sediment",
         "susp_sand",
@@ -79,6 +83,8 @@
         "sand",
         "fine_middle",
         "coarse",
+        "bed_load",
+        "bed_load_susp_sand",
         "total"
     };
 
@@ -153,14 +159,6 @@
         return valf.format(val);
     }
 
-    /** Return space when val is NaN or zero, apply NumberFormat otherwise. */
-    private String nonZeroToString(NumberFormat valf, double val) {
-        if (Double.isNaN(val) || val == 0d) {
-            return " ";
-        }
-        return valf.format(val);
-    }
-
     /** Write a line. */
     private void writeRecord(
         CSVWriter writer,
@@ -168,20 +166,17 @@
         String years,
         Double[] fractions
     ) {
-        // year, total, susp sed, susp sandbed suspsand, sand, finemiddle, coarse
         NumberFormat kmf = Formatter.getCalculationKm(context.getMeta());
         NumberFormat valf = Formatter.getFormatter(context.getMeta(), 0, 2);
-        writer.writeNext(new String[] {
-            kmf.format(km),
-            years,
-            numberToString(valf,  fractions[0]),
-            numberToString(valf,  fractions[1]),
-            numberToString(valf,  fractions[2]),
-            numberToString(valf,  fractions[3]),
-            numberToString(valf,  fractions[4]),
-            numberToString(valf,  fractions[5]),
-            nonZeroToString(valf, fractions[6])
-        });
+
+        String[] record = new String[fractions.length+2];
+        record[0] = kmf.format(km);
+        record[1] = years;
+        for (int i = 0; i < fractions.length; ++i) {
+            record[i+2] = numberToString(valf,  fractions[i]);
+        }
+
+        writer.writeNext(record);
     }
 
     /** Writes i18ned header for csv file/stream. */
@@ -192,18 +187,23 @@
         SedimentLoadAccess access =
             new SedimentLoadAccess((D4EArtifact) master);
 
-        String unit = " [" + msg("state.minfo." +
-                access.getUnit(), "translation missing") + "]";
+        String unit = msg("state.minfo." + access.getUnit());
 
-        header.add(msg(CSV_KM,          "km"));
-        header.add(msg(CSV_YEAR,        "Jahr"));
-        header.add(msg(CSV_SUSP_SEDIMENT, "Schwebst.") + unit);
-        header.add(msg(CSV_SUSP_SAND,   "Susp.Sand") + unit);
-        header.add(msg(CSV_SUSP_SAND_BB, "Susp.Sand(BB)") + unit);
-        header.add(msg(CSV_SAND,        "Sand") + unit);
-        header.add(msg(CSV_FINEMIDDLE,  "Kies(f+m)") + unit);
-        header.add(msg(CSV_COARSE,      "Kies(g)") + unit);
-        header.add(msg(CSV_TOTAL,       "Gesamt") + unit);
+        header.add(msg(CSV_KM));
+        header.add(msg(CSV_YEAR));
+        for (String head: new String[] {
+                CSV_SUSP_SEDIMENT,
+                CSV_SUSP_SAND,
+                CSV_SUSP_SAND_BB,
+                CSV_SAND,
+                CSV_FINEMIDDLE,
+                CSV_COARSE,
+                CSV_BED_LOAD,
+                CSV_BED_LOAD_SUSP_SAND,
+                CSV_TOTAL
+            }) {
+            header.add(msg(head, new Object[] { unit }));
+        }
         writer.writeNext(header.toArray(new String[header.size()]));
     }
 
--- a/artifacts/src/main/resources/messages.properties	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/resources/messages.properties	Thu Sep 04 11:15:34 2014 +0200
@@ -271,9 +271,9 @@
 facet.sedimentload.total = Total load (from database) - {0} [{1}]
 facet.sedimentload.bed_load = Bed load (from database) - {0} [{1}]
 facet.sedimentload.suspended_load = Suspended load (from database) - {0} [{1}]
-facet.sedimentload.calc.total = Gesamtfracht (calculated) - {0} [{1}]
-facet.sedimentload.calc.bed_load = Geschiebefracht (calculated) - {0} [{1}]
-facet.sedimentload.calc.suspended_load = Suspensionsfracht (calculated) - {0} [{1}]
+facet.sedimentload.calc.total = Total load (calculated) - {0} [{1}]
+facet.sedimentload.calc.bed_load = Bed load (calculated) - {0} [{1}]
+facet.sedimentload.calc.bed_load_susp_sand = bed building load (calculated) - {0} [{1}]
 
 missing.fraction.coarse = Year {0}: Missing coarse fraction
 missing.fraction.fine_middle = Year {0}: Missing fine/middle fraction
@@ -356,6 +356,9 @@
 chart.beddifference.yaxis.label.heights = Absolute Height [{0}]
 chart.subtitle.radius = Width of sample window for moving average: {0} km
 
+export.csv.header.km = km
+export.csv.header.year = year
+
 export.waterlevel.csv.header.km = River-Km
 export.waterlevel.csv.header.w = W [{0}]
 export.waterlevel.csv.header.q = Q [m\u00b3/s]
@@ -433,15 +436,17 @@
 export.bedheight_middle.csv.header.location.system = Location system
 export.bedheight_middle.csv.header.evalby = Evaluated by
 export.bedheight_middle.csv.header.river.elevation = River elevation model
-export.sedimentload_ls.csv.header.km = km
-export.sedimentload_ls.csv.header.year = year
-export.sedimentload_ls.csv.header.coarse = coarse
-export.sedimentload_ls.csv.header.finemiddle = finemiddle
-export.sedimentload_ls.csv.header.sand = sand
-export.sedimentload_ls.csv.header.suspsand = susp. sand
-export.sedimentload_ls.csv.header.suspsediment = susp. sediment
-export.sedimentload_ls.csv.header.suspsandbb = susp. sand (BB)
-export.sedimentload_ls.csv.header.total = total
+
+export.sedimentload.csv.header.coarse = Coarse gravel [{0}]
+export.sedimentload.csv.header.fine_middle = Fine/Mid. gravel [{0}]
+export.sedimentload.csv.header.sand = Sand [{0}]
+export.sedimentload.csv.header.susp_sand = Suspended sand [{0}]
+export.sedimentload.csv.header.susp_sand_bed = Bed. part suspended sand [{0}]
+export.sedimentload.csv.header.suspended_sediment = Suspended sediment [{0}]
+export.sedimentload.csv.header.total = Total load [{0}]
+export.sedimentload.csv.header.bed_load = Bed load [{0}]
+export.sedimentload.csv.header.suspended_load = Suspended load [{0}]
+
 export.sqrelation.csv.info.coeff.a = a: coefficient of transport curve
 export.sqrelation.csv.info.coeff.b = b: exponent of transport curve
 export.sqrelation.csv.info.qmax = Q max, measured: maximum measured discharge [m\u00b3/s]
--- a/artifacts/src/main/resources/messages_de.properties	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Thu Sep 04 11:15:34 2014 +0200
@@ -274,7 +274,7 @@
 facet.sedimentload.suspended_load = Suspensionsfracht (Berechnung BfG) - {0} [{1}]
 facet.sedimentload.calc.total = Gesamtfracht (Berechnung FLYS) - {0} [{1}]
 facet.sedimentload.calc.bed_load = Geschiebefracht (Berechnung FLYS) - {0} [{1}]
-facet.sedimentload.calc.suspended_load = Suspensionsfracht (Berechnung FLYS) - {0} [{1}]
+facet.sedimentload.calc.bed_load_susp_sand = bettbildende Fracht (Berechnung FLYS) - {0} [{1}]
 
 missing.fraction.coarse = Jahr {0}: Fehlende Fraktion: grober Kies
 missing.fraction.fine_middle = Jahr {0}: Fehlende Fraktion: fein/mittlerer Kies
@@ -357,6 +357,9 @@
 chart.beddifference.yaxis.label.heights = Absolute H\u00f6he [m]
 chart.subtitle.radius = Fensterbreite f\u00fcr gleitenden Mittelwert: {0} km
 
+export.csv.header.km = km
+export.csv.header.year = Jahr
+
 export.waterlevel.csv.header.km = Fluss-Km
 export.waterlevel.csv.header.w = W [{0}]
 export.waterlevel.csv.header.q = Q [m\u00b3/s]
@@ -435,15 +438,17 @@
 export.bedheight_middle.csv.header.range = Strecke
 export.bedheight_middle.csv.header.location.system = Lagesystem
 export.bedheight_middle.csv.header.evalby = Auswerter
-export.sedimentload_ls.csv.header.km = km
-export.sedimentload_ls.csv.header.year = Jahr
-export.sedimentload_ls.csv.header.coarse = Kies(g)
-export.sedimentload_ls.csv.header.finemiddle = Kies(f+m)
-export.sedimentload_ls.csv.header.sand = Sand
-export.sedimentload_ls.csv.header.suspsand = susp.Sand
-export.sedimentload_ls.csv.header.suspsandbb = susp.Sand(BB)
-export.sedimentload_ls.csv.header.suspsediment = Schwebst.
-export.sedimentload_ls.csv.header.total = Gesamt
+
+export.sedimentload.csv.header.coarse = Grober Kies/Steine [{0}]
+export.sedimentload.csv.header.fine_middle = Fein/Mittlerer Kies [{0}]
+export.sedimentload.csv.header.sand = Sand [{0}]
+export.sedimentload.csv.header.susp_sand = suspendierter Sand [{0}]
+export.sedimentload.csv.header.susp_sand_bed = bettbildender Anteil suspendierter Sand [{0}]
+export.sedimentload.csv.header.suspended_sediment = Schwebstoff [{0}]
+export.sedimentload.csv.header.total = Gesamtfracht [{0}]
+export.sedimentload.csv.header.bed_load = Geschiebefracht [{0}]
+export.sedimentload.csv.header.bed_load_susp_sand = bettbildende Fracht [{0}]
+
 export.sqrelation.csv.info.coeff.a = a: Transportkurvenkoeffizient
 export.sqrelation.csv.info.coeff.b = b: Transportkurvenexponent
 export.sqrelation.csv.info.qmax = Q max, gemessen: maximal gemessener Abfluss [m\u00b3/s]
--- a/artifacts/src/main/resources/messages_de_DE.properties	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/resources/messages_de_DE.properties	Thu Sep 04 11:15:34 2014 +0200
@@ -271,7 +271,7 @@
 facet.sedimentload.suspended_load = Suspensionsfracht (Berechnung BfG) - {0} [{1}]
 facet.sedimentload.calc.total = Gesamtfracht (Berechnung FLYS) - {0} [{1}]
 facet.sedimentload.calc.bed_load = Geschiebefracht (Berechnung FLYS) - {0} [{1}]
-facet.sedimentload.calc.suspended_load = Suspensionsfracht (Berechnung FLYS) - {0} [{1}]
+facet.sedimentload.calc.bed_load_susp_sand = bettbildende Fracht (Berechnung FLYS) - {0} [{1}]
 
 missing.fraction.coarse = Jahr {0}: Fehlende Fraktion: grober Kies
 missing.fraction.fine_middle = Jahr {0}: Fehlende Fraktion: fein/mittlerer Kies
@@ -354,6 +354,9 @@
 chart.beddifference.yaxis.label.heights = Absolute H\u00f6he [{0}]
 chart.subtitle.radius = Fensterbreite f\u00fcr gleitenden Mittelwert: {0} km
 
+export.csv.header.km = km
+export.csv.header.year = Jahr
+
 export.waterlevel.csv.header.km = Fluss-Km
 export.waterlevel.csv.header.w = W [{0}]
 export.waterlevel.csv.header.q = Q [m\u00b3/s]
@@ -431,15 +434,17 @@
 export.bedheight_middle.csv.header.location.system = Lagesystem
 export.bedheight_middle.csv.header.evalby = Auswerter
 export.bedheight_middle.csv.header.river.elevation = H\u00f6hensystem des Flusses
-export.sedimentload_ls.csv.header.km = km
-export.sedimentload_ls.csv.header.year = Jahr
-export.sedimentload_ls.csv.header.coarse = Kies(g)
-export.sedimentload_ls.csv.header.finemiddle = Kies(f+m)
-export.sedimentload_ls.csv.header.sand = Sand
-export.sedimentload_ls.csv.header.suspsand = susp.Sand
-export.sedimentload_ls.csv.header.suspsandbb = susp.Sand(BB)
-export.sedimentload_ls.csv.header.suspsediment = Schwebst.
-export.sedimentload_ls.csv.header.total = Gesamt
+
+export.sedimentload.csv.header.coarse = Grober Kies/Steine [{0}]
+export.sedimentload.csv.header.fine_middle = Fein/Mittlerer Kies [{0}]
+export.sedimentload.csv.header.sand = Sand [{0}]
+export.sedimentload.csv.header.susp_sand = suspendierter Sand [{0}]
+export.sedimentload.csv.header.susp_sand_bed = bettbildender Anteil suspendierter Sand [{0}]
+export.sedimentload.csv.header.suspended_sediment = Schwebstoff [{0}]
+export.sedimentload.csv.header.total = Gesamtfracht [{0}]
+export.sedimentload.csv.header.bed_load = Geschiebefracht [{0}]
+export.sedimentload.csv.header.bed_load_susp_sand = bettbildende Fracht [{0}]
+
 export.sqrelation.csv.info.coeff.a = a: Transportkurvenkoeffizient
 export.sqrelation.csv.info.coeff.b = b: Transportkurvenexponent
 export.sqrelation.csv.info.qmax = Q max, gemessen: maximal gemessener Abfluss [m\u00b3/s]
--- a/artifacts/src/main/resources/messages_en.properties	Thu Sep 04 11:14:24 2014 +0200
+++ b/artifacts/src/main/resources/messages_en.properties	Thu Sep 04 11:15:34 2014 +0200
@@ -273,9 +273,9 @@
 facet.sedimentload.total = Total load (from database) - {0} [{1}]
 facet.sedimentload.bed_load = Bed load (from database) - {0} [{1}]
 facet.sedimentload.suspended_load = Suspended load (from database) - {0} [{1}]
-facet.sedimentload.calc.total = Gesamtfracht (calculated) - {0} [{1}]
-facet.sedimentload.calc.bed_load = Geschiebefracht (calculated) - {0} [{1}]
-facet.sedimentload.calc.suspended_load = Suspensionsfracht (calculated) - {0} [{1}]
+facet.sedimentload.calc.total = Total load (calculated) - {0} [{1}]
+facet.sedimentload.calc.bed_load = Bed load (calculated) - {0} [{1}]
+facet.sedimentload.calc.bed_load_susp_sand = bed building load (calculated) - {0} [{1}]
 
 missing.fraction.coarse = Year {0}: Missing coarse fraction
 missing.fraction.fine_middle = Year {0}: Missing fine/middle fraction
@@ -359,6 +359,9 @@
 chart.beddifference.yaxis.label.heights = Absolute Height [m]
 chart.subtitle.radius = Radius for weighted Average: {0} km
 
+export.csv.header.km = km
+export.csv.header.year = year
+
 export.waterlevel.csv.header.km = River-Km
 export.waterlevel.csv.header.w = W [{0}]
 export.waterlevel.csv.header.q = Q [m\u00b3/s]
@@ -436,15 +439,17 @@
 export.bedheight_middle.csv.header.location.system = Location system
 export.bedheight_middle.csv.header.evalby = Evaluated by
 export.bedheight_middle.csv.header.river.elevation = River elevation model
-export.sedimentload_ls.csv.header.km = km
-export.sedimentload_ls.csv.header.year = year
-export.sedimentload_ls.csv.header.coarse = coarse
-export.sedimentload_ls.csv.header.finemiddle = finemiddle
-export.sedimentload_ls.csv.header.sand = sand
-export.sedimentload_ls.csv.header.suspsandbb = susp. sand (BB)
-export.sedimentload_ls.csv.header.suspsand = susp. sand
-export.sedimentload_ls.csv.header.suspsediment = susp. sediment
-export.sedimentload_ls.csv.header.total = total
+
+export.sedimentload.csv.header.coarse = Coarse gravel [{0}]
+export.sedimentload.csv.header.fine_middle = Fine/Mid. gravel [{0}]
+export.sedimentload.csv.header.sand = Sand [{0}]
+export.sedimentload.csv.header.susp_sand = Suspended sand [{0}]
+export.sedimentload.csv.header.susp_sand_bed = Bed. part suspended sand [{0}]
+export.sedimentload.csv.header.suspended_sediment = Suspended sediment [{0}]
+export.sedimentload.csv.header.total = Total load [{0}]
+export.sedimentload.csv.header.bed_load = Bed load [{0}]
+export.sedimentload.csv.header.suspended_load = Suspended load [{0}]
+
 export.sqrelation.csv.info.coeff.a = a: coefficient of transport curve
 export.sqrelation.csv.info.coeff.b = b: exponent of transport curve
 export.sqrelation.csv.info.qmax = Q max, measured: maximum measured discharge [m\u00b3/s]

http://dive4elements.wald.intevation.org