annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java @ 8258:155a886ab19b

Suspended sand is part of total load.
author Tom Gottfried <tom@intevation.de>
date Thu, 11 Sep 2014 14:45:17 +0200
parents 0a03c1921cfe
children 73a4c3c202e5
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;
8238
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.SQTimeInterval;
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
28 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
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,
8258
155a886ab19b Suspended sand is part of total load.
Tom Gottfried <tom@intevation.de>
parents: 8244
diff changeset
41 SedimentLoadData.GF_SUSP_SAND,
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
42 SedimentLoadData.GF_SUSP_SEDIMENT
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
43 };
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
44
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
45 public static final int [] BED_LOAD = {
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
46 SedimentLoadData.GF_COARSE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
47 SedimentLoadData.GF_FINE_MIDDLE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
48 SedimentLoadData.GF_SAND
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
49 };
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
50
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
51 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
52 SedimentLoadData.GF_COARSE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
53 SedimentLoadData.GF_FINE_MIDDLE,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
54 SedimentLoadData.GF_SAND,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
55 SedimentLoadData.GF_SUSP_SAND
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
56 };
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
57
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
58 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
59 SedimentLoadData.GF_COARSE
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
60 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
61
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
62 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
63 SedimentLoadData.GF_FINE_MIDDLE
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
64 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
65
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
66 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
67 SedimentLoadData.GF_SAND
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
68 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
69
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
70 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
71 SedimentLoadData.GF_SUSP_SAND
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
72 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
73
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
74 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
75 SedimentLoadData.GF_SUSP_SAND_BED
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
76 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
77
8175
d2673ca68e70 Precalculated sums from the database will come through recommendations.
Tom Gottfried <tom@intevation.de>
parents: 8172
diff changeset
78 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
79 SedimentLoadData.GF_SUSP_SEDIMENT
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
80 };
9e79e384aa8b Sediment load: Added more 'sums' to be calculated.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8049
diff changeset
81
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
82 public static final class LoadSum {
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
83 private String description;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
84 private int [] grainFractions;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
85
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
86 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
87 this.description = description;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
88 this.grainFractions = grainFractions;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
89 }
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
90 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
91 return new LoadSum(description, grainFractions);
8055
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
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
94 public String getDescription() {
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
95 return description;
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
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
98 public int [] getGrainFractions() {
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
99 return grainFractions;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
100 }
8193
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
101
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
102 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
103 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
104 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
105 }
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
106 } // class LoadSum
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
107
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
108 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
109 // 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
110 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
111 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
112 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
113 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
114 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
115 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
116 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
117 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
118 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
119 };
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
120
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
121 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
122
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
123 protected int n;
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
124 protected double sum;
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
125
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
126 public Sum() {
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
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
129 public double getSum() {
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
130 return sum;
8049
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
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
133 public int getN() {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
134 return n;
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
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
137 public void reset() {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
138 n = 0;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
139 sum = 0.0;
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
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
142 @Override
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
143 public void visit(Value value) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
144 sum += value.getValue();
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
145 ++n;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
146 }
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
147 } // class Sum
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
148
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
149 private String river;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
150 private String yearEpoch;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
151 private String unit;
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
152 private int [][] epochs;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
153 private int [] years;
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
154 private double from;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
155 private double to;
8238
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
156 /* The sq time interval to use. 0 means this is ignored. */
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
157 private int sqTiId;
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
158
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
159
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
160 public SedimentLoadDataCalculation() {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
161 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
162
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
163 public CalculationResult calculate(SedimentLoadAccess access) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
164 log.info("SedimentLoadDataCalculation.calculate");
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
165
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
166 String river = access.getRiverName();
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
167 String yearEpoch = access.getYearEpoch();
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
168 String unit = access.getUnit();
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
169
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
170 int [] years = null;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
171 int [][] epochs = null;
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
172
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
173 double from = access.getLowerKM();
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
174 double to = access.getUpperKM();
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
175
8239
b207eeb66edd (issue1448) Objectify sq_time_interval id.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8238
diff changeset
176 Integer sqTiId = access.getSQTiId();
8238
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
177
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
178 if (yearEpoch.equals("year")) {
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
179 years = access.getPeriod();
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
180 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
181 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
182 epochs = access.getEpochs();
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
183 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
184 else {
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
185 addProblem("minfo.missing.year_epoch");
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
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
188 if (river == null) {
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
189 // TODO: i18n
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
190 addProblem("minfo.missing.river");
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
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
193 if (years == null && epochs == null) {
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
194 addProblem("minfo.missing.time");
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
195 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
196
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
197 if (!hasProblems()) {
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
198 this.river = river;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
199 this.yearEpoch = yearEpoch;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
200 this.unit = unit;
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
201 this.years = years;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
202 this.epochs = epochs;
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
203 this.from = from;
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
204 this.to = to;
8238
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
205 this.sqTiId = sqTiId;
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
206 return internalCalculate();
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
207 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
208
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
209 return error(null);
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
210 }
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
211
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
212 private CalculationResult error(String msg) {
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
213 if (msg != null) addProblem(msg);
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
214 return new CalculationResult(this);
8052
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
215 }
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
216
1dae69eff79d Sediment load: take arguments from sediment access.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8050
diff changeset
217 private CalculationResult internalCalculate() {
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
218 if ("year".equals(yearEpoch)) return calculateYears();
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
219 if ("epoch".equals(yearEpoch)) return calculateEpochs();
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
220 if ("off_epoch".equals(yearEpoch)) return calculateOffEpochs();
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
221
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
222 // TODO: i18n
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
223 return error("minfo.sedimentload.unknown.calc.mode");
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
224 }
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
225
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
226 private CalculationResult calculateYears() {
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
227 SedimentLoadData sld =
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
228 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river);
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
229 if (sld == null) {
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
230 return error("minfo.sedimentload.no.data");
8055
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
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
233 SedimentLoadDataResult sldr = new SedimentLoadDataResult();
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
234
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
235 Not notEpochs = new Not(IsEpoch.INSTANCE);
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
236
8238
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
237 SQTimeInterval sqTiFilter = new SQTimeInterval(sqTiId);
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
238
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
239 Sum sum = new Sum();
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
240
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
241 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
242
8145
52504fc2cd58 Calculate all single years in given interval but only once.
Tom Gottfried <tom@intevation.de>
parents: 8131
diff changeset
243 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
244 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
245
52504fc2cd58 Calculate all single years in given interval but only once.
Tom Gottfried <tom@intevation.de>
parents: 8131
diff changeset
246 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
247 Value.Filter filter = new And(notEpochs)
8238
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
248 .add(new TimeRangeIntersects(year)).add(sqTiFilter);
8131
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
249 String period = Integer.toString(year);
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
250
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
251 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
252
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
253 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
254 sld, ls.getGrainFractions(), ls.getStationType(),
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
255 filter, sum);
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
256
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
257 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
258 addProblem("sedimentload.missing.fraction." +
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
259 ls.getDescription(), period);
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
260 continue;
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
261 }
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
262
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 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
264
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
265 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
266 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
267
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
268 sldr.addFraction(sldrf);
8055
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
269 }
cd35b76f1ef8 Sediment load. More off year based calculations.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8053
diff changeset
270 }
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
271 return new CalculationResult(sldr, this);
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
272 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
273
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
274 private CalculationResult calculateEpochs() {
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
275 SedimentLoadData sld =
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
276 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river);
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
277 if (sld == null) {
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
278 return error("minfo.sedimentload.no.data");
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
279 }
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
280
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
281 SedimentLoadDataResult sldr = new SedimentLoadDataResult();
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
282
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
283 Sum sum = new Sum();
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
284
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
285 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
286
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
287 // 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
288 Not notEpochs = new Not(IsEpoch.INSTANCE);
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
289
8238
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
290 SQTimeInterval sqTiFilter = new SQTimeInterval(sqTiId);
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
291
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
292 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
293 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
294 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
295
8131
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
296 String period = Integer.toString(epoch[0]) + " - " +
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
297 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
298
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
299 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
300
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
301 List<double [][]> results = new ArrayList<double [][]>();
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
302
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
303 for (int year = min; year <= max; ++year) {
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
304 Value.Filter filter = new And(notEpochs)
8238
be3c11bef6e8 (issue1448) Finally use the sq time interval as filter in the calculation.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8213
diff changeset
305 .add(new TimeRangeIntersects(year)).add(sqTiFilter);
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
306
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
307 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
308 sld, ls.getGrainFractions(), ls.getStationType(),
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
309 filter, sum);
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
310
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 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
8244
0a03c1921cfe We well want to average NaNs but want to know the cause of the result being NaN.
Tom Gottfried <tom@intevation.de>
parents: 8239
diff changeset
312 addProblem("sedimentload.missing.fraction." +
0a03c1921cfe We well want to average NaNs but want to know the cause of the result being NaN.
Tom Gottfried <tom@intevation.de>
parents: 8239
diff changeset
313 ls.getDescription(), ((Integer)year).toString());
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 }
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 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
317 results.add(result);
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
318 }
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
319
8205
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
320 if (results.size() == 0) {
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
321 addProblem("sedimentload.missing.fraction." +
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
322 ls.getDescription(), period);
8205
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
323 continue;
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
324 }
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
325
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
326 double [][] result = average(results);
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
327
8205
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
328 if (!DoubleUtil.isNaN(result[1])) {
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
329 SedimentLoadDataResult.Fraction sldrf =
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
330 new SedimentLoadDataResult.Fraction(
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
331 ls.getDescription(), result, period);
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
332 sldr.addFraction(sldrf);
04d1d56d896b Do not return pure NaN data.
Tom Gottfried <tom@intevation.de>
parents: 8194
diff changeset
333 }
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
334 else {
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
335 addProblem("sedimentload.missing.fraction." +
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
336 ls.getDescription(), period);
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
337 }
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
338 }
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
339
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
340 }
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
341 return new CalculationResult(sldr, this);
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
342 }
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
343
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
344 private CalculationResult calculateOffEpochs() {
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
345 SedimentLoadData sld =
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
346 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river);
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
347 if (sld == null) {
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
348 return error("minfo.sedimentload.no.data");
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
349 }
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
350
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
351 SedimentLoadDataResult sldr = new SedimentLoadDataResult();
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
352
8068
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
353 SedimentDensity sd = getSedimentDensity();
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
354
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
355 Set<Integer> missingFractions = new TreeSet<Integer>();
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
356
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
357 for (int [] epoch: epochs) {
8068
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
358 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
359 .add(new TimeRangeIntersects(epoch[0], epoch[1]));
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
360
8068
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
361 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
362
8131
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
363 String period = Integer.toString(epoch[0]) + " - " +
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
364 Integer.toString(epoch[1]);
fae48b3c09d1 Add period to sedimentloaddataresult fraction
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8130
diff changeset
365
8060
25feef564d09 Sediment load: More of official epochs.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8057
diff changeset
366 Sum sum = new Sum();
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
367
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
368 for (LoadSum ls: LOAD_SUMS) {
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
369 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
370 sld, ls.getGrainFractions(), ls.getStationType(),
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
371 filter, sum);
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
372
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
373 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
374 addProblem("sedimentload.missing.fraction." +
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
375 ls.getDescription(), period);
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
376 continue;
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
377 }
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
378
8068
9ecd6267323b Sediment load: transform units for official epochs, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8067
diff changeset
379 transformT2M3(sd, year, result);
8062
8489565ff563 Sedimen load: Added bundle for fraction results.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8060
diff changeset
380 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
381 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
382 sldr.addFraction(sldrf);
8057
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
383 }
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
384 }
555dc5a9b282 Sediment load: More on calculating epoch loads.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8055
diff changeset
385 // 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
386 return new CalculationResult(sldr, this);
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
387 }
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
388
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
389 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
390 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
391 }
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
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 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
394 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
395 ? 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
396 : 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
397 }
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
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 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
400 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
401 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
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 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
404 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
405 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
406 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
407 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
408 }
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
409 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
410 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
411 }
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
412 }
fe5ef780f8b1 Sediment load: fetch sediment density for transforming t/a to m^3/a.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8062
diff changeset
413
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
414 public double[][] sum(
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
415 SedimentLoadData sld,
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
416 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
417 int lsSType,
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
418 Value.Filter filter,
8213
ebdf34cae14d Error reports for sediment load calculation.
Tom Gottfried <tom@intevation.de>
parents: 8205
diff changeset
419 Sum sum
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
420 ) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
421 List<Station> stations = sld.findStations(from, to);
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
422
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
423 double [] values = new double[grainFractions.length];
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
424
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
425 double [][] result = new double[2][stations.size()];
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
426
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
427 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
428 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
429 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
430
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
431 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
432 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
433 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
434
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
435 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
436
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
437 // 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
438 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
439
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
440 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
441 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
442 "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
443 }
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
444 else {
8d447516b7dd Sum up fractions from stations and previous stations according to respective validity model.
Tom Gottfried <tom@intevation.de>
parents: 8185
diff changeset
445 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
446 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
447 (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
448 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
449 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
450 /* 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
451 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
452 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
453 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
454 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
455 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
456 Station prev = station.prevByType(otherType);
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
457 if (prev != null) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
458 prev.filterGrainFraction(gf, filter, sum);
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
459 }
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
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
463 if (sum.getN() == 0) {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
464 values[i] = Double.NaN;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
465 } else {
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
466 values[i] = sum.getSum();
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 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
469 result[0][j] = station.getStation();
8053
72760ca2fc2b Sediment load: dispatch calculation modes.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8052
diff changeset
470 result[1][j] = DoubleUtil.sum(values);
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
471 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
472
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
473 return result;
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
474 }
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
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 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
477 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
478 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
479 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
480 }
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 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
482 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
483 ++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
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 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
486 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
487 }
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
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 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
491
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 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
493
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 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
495 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
496 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
497 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
498 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
499 double v = vs[i];
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
500 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
501 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
502 }
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 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
504 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
505 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
506 }
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 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
508 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
509 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
510
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 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
512 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
513 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
514 result[0][i] = entry.getKey();
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
515 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
516 ++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
517 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
518
8176
7b0b3b1a2ee8 Let epochs be averages over their years.
Tom Gottfried <tom@intevation.de>
parents: 8175
diff changeset
519 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
520 }
6d24ba2ac964 Sediment load: refactored epoch calculation to not average over all but per year.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 8066
diff changeset
521
8049
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
522 }
d49846f05108 Sediment load: (incomplete) new sediment load calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
523 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org