annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java @ 8193:8d447516b7dd

Sum up fractions from stations and previous stations according to respective validity model.
author Tom Gottfried <tom@intevation.de>
date Thu, 04 Sep 2014 17:33:01 +0200
parents 76e1e9d81ce2
children 59e50aa0c6c2
rev   line source
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2014 by Bundesanstalt für Gewässerkunde
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
3 *
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
7 */
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
8 package org.dive4elements.river.artifacts.model.minfo;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
9
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
10 import java.util.ArrayList;
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
11 import java.util.List;
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
12 import java.util.Map;
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
13 import java.util.Set;
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
14 import java.util.TreeMap;
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
15 import java.util.TreeSet;
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
16
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
17 import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
18 import org.dive4elements.river.artifacts.model.Calculation;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
19 import org.dive4elements.river.artifacts.model.CalculationResult;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
20 import org.apache.log4j.Logger;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
21 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Value;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
22 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Station;
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
23 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.And;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
24 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsEpoch;
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
25 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsOfficial;
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
26 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.Not;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.TimeRangeIntersects;
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
28 import org.dive4elements.river.model.River;
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
29 import org.dive4elements.river.utils.DoubleUtil;
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
30
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
31 public class SedimentLoadDataCalculation
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
32 extends Calculation
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
33 {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
34 private static final Logger log = Logger
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
35 .getLogger(SedimentLoadDataCalculation.class);
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
36
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
37 public static final int [] TOTAL_LOAD = {
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
38 SedimentLoadData.GF_COARSE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
39 SedimentLoadData.GF_FINE_MIDDLE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
40 SedimentLoadData.GF_SAND,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
41 SedimentLoadData.GF_SUSP_SEDIMENT
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
42 };
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
43
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
44 public static final int [] BED_LOAD = {
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
45 SedimentLoadData.GF_COARSE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
46 SedimentLoadData.GF_FINE_MIDDLE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
47 SedimentLoadData.GF_SAND
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
48 };
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
49
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
50 public static final int [] BED_LOAD_SUSP_SAND = {
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
51 SedimentLoadData.GF_COARSE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
52 SedimentLoadData.GF_FINE_MIDDLE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
53 SedimentLoadData.GF_SAND,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
54 SedimentLoadData.GF_SUSP_SAND
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
55 };
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
56
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
57 public static final int [] COARSE = {
8050
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
58 SedimentLoadData.GF_COARSE
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
59 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
60
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
61 public static final int [] FINE_MIDDLE = {
8050
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
62 SedimentLoadData.GF_FINE_MIDDLE
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
63 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
64
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
65 public static final int [] SAND = {
8050
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
66 SedimentLoadData.GF_SAND
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
67 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
68
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
69 public static final int [] SUSP_SAND = {
8050
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
70 SedimentLoadData.GF_SUSP_SAND
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
71 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
72
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
73 public static final int [] SUSP_SAND_BED = {
8050
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
74 SedimentLoadData.GF_SUSP_SAND_BED
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
75 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
76
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
77 public static final int [] SUSP_SEDIMENT = {
8050
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
78 SedimentLoadData.GF_SUSP_SEDIMENT
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
79 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
80
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
81 public static final class LoadSum {
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
82 private String description;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
83 private int [] grainFractions;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
84
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
85 public LoadSum(String description, int [] grainFractions) {
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
86 this.description = description;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
87 this.grainFractions = grainFractions;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
88 }
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
89 public static final LoadSum make(String description, int [] grainFractions) {
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
90 return new LoadSum(description, grainFractions);
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
91 }
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
92
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
93 public String getDescription() {
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
94 return description;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
95 }
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
96
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
97 public int [] getGrainFractions() {
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
98 return grainFractions;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
99 }
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
100
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
101 public int getStationType() {
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
102 return SedimentLoadData.measurementStationType(
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
103 SedimentLoadData.grainFractionIndex(this.description));
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
104 }
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
105 } // class LoadSum
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
106
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
107 public static final LoadSum [] LOAD_SUMS = {
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
108 // Names are alignt to the grain_fractions table
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
109 LoadSum.make("total", TOTAL_LOAD),
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
110 LoadSum.make("bed_load", BED_LOAD),
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
111 LoadSum.make("bed_load_susp_sand", BED_LOAD_SUSP_SAND),
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
112 LoadSum.make("coarse", COARSE),
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
113 LoadSum.make("fine_middle", FINE_MIDDLE),
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
114 LoadSum.make("sand", SAND) ,
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
115 LoadSum.make("susp_sand", SUSP_SAND),
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
116 LoadSum.make("susp_sand_bed", SUSP_SAND_BED),
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
117 LoadSum.make("suspended_sediment", SUSP_SEDIMENT),
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
118 };
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
119
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
120 public static class Sum implements Value.Visitor {
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
121
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
122 protected int n;
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
123 protected double sum;
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
124
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
125 public Sum() {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
126 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
127
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
128 public double getSum() {
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
129 return sum;
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
130 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
131
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
132 public int getN() {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
133 return n;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
134 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
135
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
136 public void reset() {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
137 n = 0;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
138 sum = 0.0;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
139 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
140
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
141 @Override
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
142 public void visit(Value value) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
143 sum += value.getValue();
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
144 ++n;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
145 }
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
146 } // class Sum
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
147
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
148 private String river;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
149 private String yearEpoch;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
150 private String unit;
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
151 private int [][] epochs;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
152 private int [] years;
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
153 private double from;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
154 private double to;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
155
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
156
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
157 public SedimentLoadDataCalculation() {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
158 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
159
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
160 public CalculationResult calculate(SedimentLoadAccess access) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
161 log.info("SedimentLoadDataCalculation.calculate");
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
162
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
163 String river = access.getRiverName();
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
164 String yearEpoch = access.getYearEpoch();
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
165 String unit = access.getUnit();
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
166
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
167 int [] years = null;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
168 int [][] epochs = null;
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
169
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
170 double from = access.getLowerKM();
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
171 double to = access.getUpperKM();
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
172
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
173 if (yearEpoch.equals("year")) {
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
174 years = access.getPeriod();
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
175 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
176 else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) {
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
177 epochs = access.getEpochs();
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
178 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
179 else {
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
180 addProblem("minfo.missing.year_epoch");
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
181 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
182
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
183 if (river == null) {
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
184 // TODO: i18n
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
185 addProblem("minfo.missing.river");
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
186 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
187
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
188 if (years == null && epochs == null) {
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
189 addProblem("minfo.missing.time");
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
190 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
191
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
192 if (!hasProblems()) {
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
193 this.river = river;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
194 this.yearEpoch = yearEpoch;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
195 this.unit = unit;
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
196 this.years = years;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
197 this.epochs = epochs;
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
198 this.from = from;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
199 this.to = to;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
200 return internalCalculate();
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
201 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
202
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
203 return error(null);
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
204 }
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
205
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
206 private CalculationResult error(String msg) {
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
207 if (msg != null) addProblem(msg);
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
208 return new CalculationResult(this);
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
209 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
210
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
211 private CalculationResult internalCalculate() {
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
212 if ("year".equals(yearEpoch)) return calculateYears();
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
213 if ("epoch".equals(yearEpoch)) return calculateEpochs();
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
214 if ("off_epoch".equals(yearEpoch)) return calculateOffEpochs();
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
215
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
216 // TODO: i18n
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
217 return error("minfo.sediment.load.unknown.calc.mode");
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
218 }
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
219
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
220 private CalculationResult calculateYears() {
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
221 SedimentLoadData sld =
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
222 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river);
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
223 if (sld == null) {
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
224 // TODO: i18n
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
225 return error("minfo.sediment.load.no.data");
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
226 }
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
227
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
228 SedimentLoadDataResult sldr = new SedimentLoadDataResult();
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
229
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
230 Set<Integer> missingFractions = new TreeSet<Integer>();
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
231
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
232 Not notEpochs = new Not(IsEpoch.INSTANCE);
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
233
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
234 Sum sum = new Sum();
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
235
8066
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
236 SedimentDensity sd = getSedimentDensity();
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
237
8145
52504fc2cd58 Calculate all single years in given interval but only once.
Tom Gottfried <tom@intevation.de>
parents: 8131
diff changeset
238 int min = Math.min(years[0], years[1]);
52504fc2cd58 Calculate all single years in given interval but only once.
Tom Gottfried <tom@intevation.de>
parents: 8131
diff changeset
239 int max = Math.max(years[0], years[1]);
52504fc2cd58 Calculate all single years in given interval but only once.
Tom Gottfried <tom@intevation.de>
parents: 8131
diff changeset
240
52504fc2cd58 Calculate all single years in given interval but only once.
Tom Gottfried <tom@intevation.de>
parents: 8131
diff changeset
241 for (int year = min; year <= max; ++year) {
8068
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
242 Value.Filter filter = new And(notEpochs)
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
243 .add(new TimeRangeIntersects(year));
8131
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
244 String period = Integer.toString(year);
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
245
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
246 for (LoadSum ls: LOAD_SUMS) {
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
247
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
248 double [][] result = sum(
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
249 sld, ls.getGrainFractions(), ls.getStationType(),
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
250 filter, sum, missingFractions);
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
251
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
252 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
253 // TODO: resolve i18n
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
254 addProblem("minfo.sediment.load.no.fractions",
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
255 ls.getDescription());
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
256 continue;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
257 }
8066
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
258
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
259 transformT2M3(sd, year, result);
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
260
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
261 SedimentLoadDataResult.Fraction sldrf =
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
262 new SedimentLoadDataResult.Fraction(ls.getDescription(), result, period);
8066
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
263
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
264 sldr.addFraction(sldrf);
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
265 }
8145
52504fc2cd58 Calculate all single years in given interval but only once.
Tom Gottfried <tom@intevation.de>
parents: 8131
diff changeset
266
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
267 }
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
268 // TODO: Generate messages for missing fractions.
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
269 return new CalculationResult(sldr, this);
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
270 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
271
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
272 private CalculationResult calculateEpochs() {
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
273 SedimentLoadData sld =
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
274 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river);
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
275 if (sld == null) {
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
276 // TODO: i18n
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
277 return error("minfo.sediment.load.no.data");
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
278 }
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
279
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
280 SedimentLoadDataResult sldr = new SedimentLoadDataResult();
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
281
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
282 Set<Integer> missingFractions = new TreeSet<Integer>();
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
283
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
284 Sum sum = new Sum();
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
285
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
286 SedimentDensity sd = getSedimentDensity();
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
287
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
288 // They are not epochs, they are single years!
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
289 Not notEpochs = new Not(IsEpoch.INSTANCE);
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
290
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
291 for (int [] epoch: epochs) {
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
292 int min = Math.min(epoch[0], epoch[1]);
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
293 int max = Math.max(epoch[0], epoch[1]);
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
294
8131
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
295 String period = Integer.toString(epoch[0]) + " - " +
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
296 Integer.toString(epoch[1]);
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
297
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
298 for (LoadSum ls: LOAD_SUMS) {
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
299
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
300 List<double [][]> results = new ArrayList<double [][]>();
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
301
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
302 for (int year = min; year <= max; ++year) {
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
303 Value.Filter filter = new And(notEpochs)
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
304 .add(new TimeRangeIntersects(year));
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
305
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
306 double [][] result = sum(
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
307 sld, ls.getGrainFractions(), ls.getStationType(),
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
308 filter, sum, missingFractions);
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
309
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
310 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
311 // TODO: resolve i18n
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
312 addProblem("minfo.sediment.load.no.fractions",
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
313 ls.getDescription());
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
314 continue;
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
315 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
316
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
317 transformT2M3(sd, year, result);
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
318 results.add(result);
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
319 }
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
320
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
321 double [][] result = average(results);
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
322
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
323 SedimentLoadDataResult.Fraction sldrf =
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
324 new SedimentLoadDataResult.Fraction(ls.getDescription(),
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
325 result, period);
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
326 sldr.addFraction(sldrf);
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
327 }
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
328
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
329 }
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
330 // TODO: Generate messages for missing fractions.
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
331 return new CalculationResult(sldr, this);
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
332 }
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
333
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
334 private CalculationResult calculateOffEpochs() {
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
335 SedimentLoadData sld =
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
336 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river);
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
337 if (sld == null) {
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
338 // TODO: i18n
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
339 return error("minfo.sediment.load.no.data");
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
340 }
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
341
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
342 SedimentLoadDataResult sldr = new SedimentLoadDataResult();
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
343
8068
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
344 SedimentDensity sd = getSedimentDensity();
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
345
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
346 Set<Integer> missingFractions = new TreeSet<Integer>();
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
347
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
348 for (int [] epoch: epochs) {
8068
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
349 Value.Filter filter = new And(IsOfficial.INSTANCE)
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
350 .add(new TimeRangeIntersects(epoch[0], epoch[1]));
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
351
8068
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
352 int year = Math.min(epoch[0], epoch[1]);
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
353
8131
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
354 String period = Integer.toString(epoch[0]) + " - " +
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
355 Integer.toString(epoch[1]);
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
356
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
357 Sum sum = new Sum();
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
358
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
359 for (LoadSum ls: LOAD_SUMS) {
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
360 double [][] result = sum(
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
361 sld, ls.getGrainFractions(), ls.getStationType(),
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
362 filter, sum, missingFractions);
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
363
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
364 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
365 // TODO: resolve i18n
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
366 addProblem("minfo.sediment.load.no.fractions",
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
367 ls.getDescription());
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
368 continue;
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
369 }
8068
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
370 transformT2M3(sd, year, result);
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
371 SedimentLoadDataResult.Fraction sldrf =
8185
76e1e9d81ce2 Removed obsolete average and renamed some symbols to make the difference between single fractions and sums of them clearer in the calculation.
Tom Gottfried <tom@intevation.de>
parents: 8176
diff changeset
372 new SedimentLoadDataResult.Fraction(ls.getDescription(), result, period);
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
373 sldr.addFraction(sldrf);
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
374 }
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
375 }
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
376 // TODO: Generate messages for missing fractions.
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
377 return new CalculationResult(sldr, this);
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
378 }
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
379
8066
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
380 private final boolean inM3() {
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
381 return unit.equals("m3_per_a");
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
382 }
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
383
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
384 private SedimentDensity getSedimentDensity() {
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
385 return inM3()
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
386 ? SedimentDensityFactory.getSedimentDensity(river, from, to)
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
387 : null;
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
388 }
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
389
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
390 private static void transformT2M3(SedimentDensity sd, int year, double [][] data) {
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
391 if (sd == null) {
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
392 return;
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
393 }
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
394 double [] kms = data[0];
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
395 double [] values = data[1];
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
396 for (int i = 0; i < kms.length; ++i) {
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
397 if (Double.isNaN(kms[i]) || Double.isNaN(kms[i])) {
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
398 continue;
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
399 }
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
400 double density = sd.getDensity(kms[i], year);
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
401 values[i] /= density;
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
402 }
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
403 }
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
404
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
405 public double[][] sum(
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
406 SedimentLoadData sld,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
407 int [] grainFractions,
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
408 int lsSType,
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
409 Value.Filter filter,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
410 Sum sum,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
411 Set<Integer> missingFractions
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
412 ) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
413 List<Station> stations = sld.findStations(from, to);
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
414
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
415 double [] values = new double[grainFractions.length];
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
416
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
417 double [][] result = new double[2][stations.size()];
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
418
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
419 for (int j = 0, S = stations.size(); j < S; ++j) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
420 Station station = stations.get(j);
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
421 int sType = station.getType();
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
422
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
423 for (int i = 0; i < grainFractions.length; ++i) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
424 int gf = grainFractions[i];
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
425 int gfSType = SedimentLoadData.measurementStationType(gf);
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
426
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
427 sum.reset();
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
428
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
429 // Add current single fraction at current station
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
430 station.filterGrainFraction(gf, filter, sum);
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
431
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
432 if (gfSType == Station.UNKNOWN) {
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
433 log.error("No measurement station type defined for " +
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
434 "fraction-index" + gf);
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
435 }
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
436 else {
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
437 if (lsSType != Station.BED_LOAD &&
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
438 lsSType != Station.SUSPENDED &&
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
439 (sType == Station.BED_LOAD ||
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
440 sType == Station.SUSPENDED) &&
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
441 sum.getN() == 0) {
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
442 /* In case the station-type of the load sum is
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
443 a combined type and we are at non-combined station:
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
444 we need to add values from previous station of
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
445 the other type for fractions not given here. */
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
446 int otherType = sType == Station.BED_LOAD ?
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
447 Station.SUSPENDED : Station.BED_LOAD;
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
448 Station prev = station.prevByType(otherType);
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
449 if (prev != null) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
450 prev.filterGrainFraction(gf, filter, sum);
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
451 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
452 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
453 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
454
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
455 if (sum.getN() == 0) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
456 missingFractions.add(gf);
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
457 values[i] = Double.NaN;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
458 } else {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
459 values[i] = sum.getSum();
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
460 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
461 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
462 result[0][j] = station.getStation();
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
463 result[1][j] = DoubleUtil.sum(values);
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
464 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
465
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
466 // TODO: Handle 'virtual' measument stations 'from' and 'to'.
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
467
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
468 return result;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
469 }
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
470
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
471 private static final class XSum {
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
472 private double sum;
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
473 private int n;
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
474 public XSum() {
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
475 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
476 public void add(double v) {
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
477 sum += v;
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
478 ++n;
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
479 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
480 public double avg() {
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
481 return sum/n;
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
482 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
483 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
484
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
485 private static double [][] average(List<double [][]> data) {
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
486
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
487 TreeMap<Double, XSum> map = new TreeMap<Double, XSum>();
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
488
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
489 for (double [][] pair: data) {
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
490 double [] kms = pair[0];
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
491 double [] vs = pair[1];
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
492 for (int i = 0; i < kms.length; ++i) {
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
493 double km = kms[i];
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
494 double v = vs[i];
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
495 if (Double.isNaN(km)) {
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
496 continue;
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
497 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
498 XSum xsum = map.get(km);
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
499 if (xsum == null) {
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
500 map.put(km, xsum = new XSum());
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
501 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
502 xsum.add(v);
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
503 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
504 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
505
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
506 double [][] result = new double[2][map.size()];
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
507 int i = 0;
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
508 for (Map.Entry<Double, XSum> entry: map.entrySet()) {
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
509 result[0][i] = entry.getKey();
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
510 result[1][i] = entry.getValue().avg();
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
511 ++i;
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
512 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
513
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
514 return result;
8067
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
515 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
516
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
517 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
518 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org