Mercurial > dive4elements > river
changeset 8176:7b0b3b1a2ee8
Let epochs be averages over their years.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 02 Sep 2014 17:47:03 +0200 |
parents | d2673ca68e70 |
children | aa80f9ba56a9 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java |
diffstat | 1 files changed, 20 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Tue Sep 02 17:10:22 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Tue Sep 02 17:47:03 2014 +0200 @@ -105,7 +105,6 @@ } // 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), GrainFraction.make("bed_load", BED_LOAD), @@ -285,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); @@ -319,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); @@ -484,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); @@ -498,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; } }