Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java @ 6678:0a70a320bfca
Doc.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 29 Jul 2013 09:22:11 +0200 |
parents | 1ca0688dddc7 |
children | 68c7b5811c4f |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5788
diff
changeset
|
9 package org.dive4elements.river.artifacts.model.minfo; |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 import gnu.trove.TDoubleArrayList; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 import java.util.ArrayList; |
6498
686bbfeacfe5
issue1235: sort km when running over them for total sediment load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6411
diff
changeset
|
14 import java.util.TreeSet; |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 import java.util.List; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 import org.apache.log4j.Logger; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5788
diff
changeset
|
19 import org.dive4elements.river.artifacts.access.SedimentLoadAccess; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5788
diff
changeset
|
20 import org.dive4elements.river.artifacts.model.Calculation; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5788
diff
changeset
|
21 import org.dive4elements.river.artifacts.model.CalculationResult; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
22 import org.dive4elements.river.artifacts.model.Range; |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 |
4483
cc6323401643
Cosmetics: Removed some WSP, obsolete imports. Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4373
diff
changeset
|
25 /** Calculate sediment load. */ |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 public class SedimentLoadCalculation |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 extends Calculation |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 |
4483
cc6323401643
Cosmetics: Removed some WSP, obsolete imports. Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4373
diff
changeset
|
30 /** Private logger. */ |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 private static final Logger logger = Logger |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
32 .getLogger(SedimentLoadCalculation.class); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 protected String river; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 protected String yearEpoch; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 protected double kmUp; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 protected double kmLow; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 protected int[] period; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 protected int[][] epoch; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 protected String unit; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
41 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 public SedimentLoadCalculation() { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 |
6678 | 45 /** Returns CalculationResult with array of SedimentLoadResults. */ |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 public CalculationResult calculate(SedimentLoadAccess access) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 logger.info("SedimentLoadCalculation.calculate"); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 String river = access.getRiver(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 String yearEpoch = access.getYearEpoch(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 String unit = access.getUnit(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 int[] period = null; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 int[][] epoch = null; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 double kmUp = access.getUpperKM(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 double kmLow = access.getLowerKM(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 if (yearEpoch.equals("year")) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 period = access.getPeriod(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 epoch = null; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 } |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
60 else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) { |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 epoch = access.getEpochs(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 period = null; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 else { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 addProblem("minfo.missing.year_epoch"); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 if (river == null) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
69 // TODO: i18n |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 addProblem("minfo.missing.river"); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
71 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
73 if (period == null && epoch == null) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 addProblem("minfo.missing.time"); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
77 if (!hasProblems()) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 this.river = river; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 this.yearEpoch = yearEpoch; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 this.unit = unit; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 this.period = period; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 this.epoch = epoch; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
83 this.kmUp = kmUp; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 this.kmLow = kmLow; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
85 return internalCalculate(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 return new CalculationResult(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
90 |
6678 | 91 /** Returns CalculationResult with array of SedimentLoadResults. */ |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
92 private CalculationResult internalCalculate() { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
93 logger.debug("internalCalulate; mode:" + yearEpoch); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
94 if (yearEpoch.equals("year")) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
95 List<SedimentLoadResult> results = |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
96 new ArrayList<SedimentLoadResult>(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
97 for (int i = period[0]; i <= period[1]; i++) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
98 SedimentLoadResult res = calculateYear(i); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
99 results.add(res); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
100 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
101 return new CalculationResult( |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
102 results.toArray(new SedimentLoadResult[results.size()]), this); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
104 else if (yearEpoch.equals("epoch")) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 List<SedimentLoadResult> results = |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 new ArrayList<SedimentLoadResult>(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 for (int i = 0; i < epoch.length; i++) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 SedimentLoadResult res = calculateEpoch(i); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
109 results.add(res); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
110 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 return new CalculationResult( |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
112 results.toArray(new SedimentLoadResult[results.size()]), this); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
113 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
114 else if (yearEpoch.equals("off_epoch")) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
115 List<SedimentLoadResult> results = |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
116 new ArrayList<SedimentLoadResult>(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
117 for (int i = 0; i < epoch.length; i++) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
118 SedimentLoadResult res = calculateOffEpoch(i); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
119 results.add(res); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
120 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
121 return new CalculationResult( |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
122 results.toArray(new SedimentLoadResult[results.size()]), this); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
123 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
124 return null; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
125 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
126 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
127 private SedimentLoadResult calculateEpoch(int i) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
128 List<SedimentLoad> epochLoads = new ArrayList<SedimentLoad>(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
129 for (int j = epoch[i][0]; j < epoch[i][1]; j++) { |
5661
b6297a67823e
SedimentLoadFactory: Renamed getLoadwithData to getLoadWithData, update callers.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4543
diff
changeset
|
130 epochLoads.add(SedimentLoadFactory.getLoadWithData( |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
131 this.river, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
132 this.yearEpoch, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
133 this.kmLow, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
134 this.kmUp, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
135 j, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
136 j)); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
137 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
138 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
139 SedimentLoad resLoad = new SedimentLoad(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
140 TDoubleArrayList kms = new TDoubleArrayList(); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
141 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
142 for (SedimentLoad load : epochLoads) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
143 for (double km : load.getKms()) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
144 if (!kms.contains(km)) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
145 kms.add(km); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
146 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
147 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
148 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
149 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
150 for (int j = 0; j < kms.size(); j++) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
151 int cSum = 0; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
152 int fmSum = 0; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
153 int sSum = 0; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
154 int ssSum = 0; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
155 int ssbSum = 0; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
156 int sseSum = 0; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
157 double km = kms.get(j); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
158 for (SedimentLoad load : epochLoads) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
159 SedimentLoadFraction f = load.getFraction(km); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
160 if (f.getCoarse() > 0d) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
161 double c = resLoad.getFraction(km).getCoarse(); |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
162 resLoad.setCoarse(km, c + f.getCoarse(), f.getCoarseRange()); |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
163 cSum++; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
164 } |
6376
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
165 if (f.getFineMiddle() > 0d) { |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
166 double fm = resLoad.getFraction(km).getFineMiddle(); |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
167 resLoad.setFineMiddle(km, fm + f.getFineMiddle(), f.getFineMiddleRange()); |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
168 fmSum++; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
169 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
170 if (f.getSand() > 0d) { |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
171 double s = resLoad.getFraction(km).getSand(); |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
172 resLoad.setSand(km, s + f.getSand(), f.getSandRange()); |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
173 sSum++; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
174 } |
6376
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
175 if (f.getSuspSand() > 0d) { |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
176 double s = resLoad.getFraction(km).getSuspSand(); |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
177 resLoad.setSuspSand(km, s + f.getSuspSand(), f.getSuspSandRange()); |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
178 ssSum++; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
179 } |
6376
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
180 if (f.getSuspSandBed() > 0d) { |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
181 double s = resLoad.getFraction(km).getSuspSandBed(); |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
182 resLoad.setSuspSandBed(km, s + f.getSuspSandBed(), f.getSuspSandBedRange()); |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
183 ssbSum++; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
184 } |
6376
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
185 if (f.getSuspSediment() > 0d) { |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
186 double s = resLoad.getFraction(km).getSuspSediment(); |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
187 resLoad.setSuspSediment(km, s + f.getSuspSediment(), f.getSuspSedimentRange()); |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
188 sseSum++; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
189 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
190 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
191 SedimentLoadFraction fr = resLoad.getFraction(km); |
6543
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
192 // Prevent divisions by zero, the fraction defaults to 0d. |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
193 if (cSum != 0) { |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
194 resLoad.setCoarse(km, fr.getCoarse()/cSum, fr.getCoarseRange()); |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
195 } |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
196 if (fmSum != 0) { |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
197 resLoad.setFineMiddle(km, fr.getFineMiddle()/fmSum, |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
198 fr.getFineMiddleRange()); |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
199 } |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
200 if (sSum != 0) { |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
201 resLoad.setSand(km, fr.getSand()/sSum, fr.getSandRange()); |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
202 } |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
203 if (ssSum != 0) { |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
204 resLoad.setSuspSand(km, fr.getSuspSand()/ssSum, |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
205 fr.getSuspSandRange()); |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
206 } |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
207 if (ssbSum != 0) { |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
208 resLoad.setSuspSandBed(km, fr.getSuspSandBed()/ssbSum, |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
209 fr.getSuspSandBedRange()); |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
210 } |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
211 if (sseSum != 0) { |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
212 resLoad.setSuspSediment(km, fr.getSuspSediment()/sseSum, fr.getSuspSedimentRange()); |
1ca0688dddc7
issue1235: Prevent division by zeros leading to NaNs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6500
diff
changeset
|
213 } |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
214 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
215 resLoad.setDescription(""); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
216 resLoad.setEpoch(true); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
217 |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
218 SedimentLoadResult result; |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
219 SedimentLoad sl = calculateTotalLoad(resLoad, this.epoch[i][0]); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
220 if (this.unit.equals("m3_per_a")) { |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
221 SedimentLoad slu = calculateUnit(sl, this.epoch[i][0]); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
222 result = new SedimentLoadResult( |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
223 this.epoch[i][0], |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
224 this.epoch[i][1], |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
225 slu); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
226 } |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
227 else { |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
228 result = new SedimentLoadResult( |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
229 this.epoch[i][0], |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
230 this.epoch[i][1], |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
231 sl); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
232 } |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
233 |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
234 return result; |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
235 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
236 |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
237 private SedimentLoadResult calculateOffEpoch(int i) { |
5661
b6297a67823e
SedimentLoadFactory: Renamed getLoadwithData to getLoadWithData, update callers.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4543
diff
changeset
|
238 SedimentLoad load = SedimentLoadFactory.getLoadWithData( |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
239 this.river, |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
240 this.yearEpoch, |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
241 kmLow, |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
242 kmUp, |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
243 this.epoch[i][0], |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
244 this.epoch[i][1]); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
245 SedimentLoadResult result; |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
246 SedimentLoad sl = calculateTotalLoad(load, this.epoch[i][0]); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
247 if (unit.equals("m3_per_a")) { |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
248 SedimentLoad slu = calculateUnit(sl, epoch[i][0]); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
249 result = new SedimentLoadResult( |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
250 this.epoch[i][0], |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
251 this.epoch[i][1], |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
252 slu); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
253 } |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
254 else { |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
255 result = new SedimentLoadResult( |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
256 this.epoch[i][0], |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
257 this.epoch[i][1], |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
258 sl); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
259 } |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
260 |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
261 return result; |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
262 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
263 |
6678 | 264 /** |
265 * Fetch loads for a single year, calculate total and | |
266 * return the result containing both. | |
267 * @param y year, e.g. 1980 | |
268 */ | |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
269 private SedimentLoadResult calculateYear(int y) { |
5661
b6297a67823e
SedimentLoadFactory: Renamed getLoadwithData to getLoadWithData, update callers.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4543
diff
changeset
|
270 SedimentLoad load = SedimentLoadFactory.getLoadWithData( |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
271 this.river, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
272 this.yearEpoch, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
273 this.kmLow, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
274 this.kmUp, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
275 y, |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
276 y); |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
277 |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
278 SedimentLoadResult result; |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
279 SedimentLoad sl = calculateTotalLoad(load, y); |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
280 if (unit.equals("m3_per_a")) { |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
281 SedimentLoad slu = calculateUnit(sl, y); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
282 result = new SedimentLoadResult(y, 0, slu); |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
283 } |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
284 else { |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
285 result = new SedimentLoadResult(y, 0, sl); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
286 } |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
287 return result; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
288 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
289 |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
290 /** Add up the loads of a year. */ |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
291 private SedimentLoad calculateTotalLoad(SedimentLoad load, int year) { |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
292 logger.debug("calculateTotalLoad"); |
5685
756df79274e1
SedimentLoadCalculation: Partly fix 1250 (calculate more than one total if possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
293 boolean problemThisYear = false; |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
294 if (!load.hasCoarse()) { |
5742
a4a894b15c35
Minor part of issue1235: dont show decimals of years.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5685
diff
changeset
|
295 addProblem("missing.fraction.coarse", Integer.toString(year)); |
5685
756df79274e1
SedimentLoadCalculation: Partly fix 1250 (calculate more than one total if possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
296 problemThisYear = true; |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
297 } |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
298 if (!load.hasFineMiddle()) { |
5742
a4a894b15c35
Minor part of issue1235: dont show decimals of years.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5685
diff
changeset
|
299 addProblem("missing.fraction.fine_middle", Integer.toString(year)); |
5685
756df79274e1
SedimentLoadCalculation: Partly fix 1250 (calculate more than one total if possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
300 problemThisYear = true; |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
301 } |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
302 if (!load.hasSand()) { |
5742
a4a894b15c35
Minor part of issue1235: dont show decimals of years.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5685
diff
changeset
|
303 addProblem("missing.fraction.sand", Integer.toString(year)); |
5685
756df79274e1
SedimentLoadCalculation: Partly fix 1250 (calculate more than one total if possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
304 problemThisYear = true; |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
305 } |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
306 if (!load.hasSuspSand()) { |
5742
a4a894b15c35
Minor part of issue1235: dont show decimals of years.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5685
diff
changeset
|
307 addProblem("missing.fraction.susp_sand", Integer.toString(year)); |
5685
756df79274e1
SedimentLoadCalculation: Partly fix 1250 (calculate more than one total if possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
308 problemThisYear = true; |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
309 } |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
310 if (!load.hasSuspSediment()) { |
5742
a4a894b15c35
Minor part of issue1235: dont show decimals of years.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5685
diff
changeset
|
311 addProblem("missing.fraction.susp_sediment", Integer.toString(year)); |
5685
756df79274e1
SedimentLoadCalculation: Partly fix 1250 (calculate more than one total if possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
312 problemThisYear = true; |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
313 } |
5685
756df79274e1
SedimentLoadCalculation: Partly fix 1250 (calculate more than one total if possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
314 if (problemThisYear) { |
756df79274e1
SedimentLoadCalculation: Partly fix 1250 (calculate more than one total if possible).
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5661
diff
changeset
|
315 logger.warn("Some problem, not calculating total load."); |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
316 return load; |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
317 } |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
318 return partialTotal(load); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
319 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
320 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
321 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
322 /** Returns true if all fraction values except SuspSediment are unset. */ |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
323 private boolean hasOnlySuspValues(SedimentLoadFraction fraction) { |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
324 return (fraction.getSuspSediment() != 0d && |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
325 fraction.getCoarse() == 0d && |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
326 fraction.getFineMiddle() == 0d && |
6411
a21f7a3e4be5
Revert to rev 6404 for issue1235
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6405
diff
changeset
|
327 fraction.getSand() == 0d && |
a21f7a3e4be5
Revert to rev 6404 for issue1235
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6405
diff
changeset
|
328 fraction.getSuspSand() == 0d); |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
329 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
330 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
331 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
332 /** Returns true if all fraction values except SuspSediment are set. */ |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
333 private boolean hasButSuspValues(SedimentLoadFraction fraction) { |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
334 return (fraction.getSuspSediment() == 0d && |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
335 fraction.getCoarse() != 0d && |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
336 fraction.getFineMiddle() != 0d && |
6411
a21f7a3e4be5
Revert to rev 6404 for issue1235
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6405
diff
changeset
|
337 fraction.getSand() != 0d && |
a21f7a3e4be5
Revert to rev 6404 for issue1235
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6405
diff
changeset
|
338 fraction.getSuspSand() != 0d); |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
339 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
340 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
341 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
342 /** Returns true if all fraction needed for total calculation are set. */ |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
343 private boolean complete(SedimentLoadFraction fraction) { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
344 return (fraction.getCoarse() != 0d && |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
345 fraction.getFineMiddle() != 0d && |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
346 fraction.getSand() != 0d && |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
347 fraction.getSuspSand() != 0d && |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
348 fraction.getSuspSediment() != 0d); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
349 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
350 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
351 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
352 /** |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
353 * Set total values in load. |
6678 | 354 * |
355 * Therefore, run over the sorted kms and find ranges where either all | |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
356 * or all Geschiebe or just the Schwebstoff fractions are set. |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
357 * Merge these ranges and add (maybe new) respective fractions to |
6678 | 358 * load. In the process, remember any 'unfished' ends from measurements |
359 * where the km-ranges did not completely match. | |
360 * | |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
361 * @param load SedimentLoad to add total values (and ranges) to. |
6678 | 362 * @return input param load, with total values set. |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
363 */ |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
364 private SedimentLoad partialTotal(SedimentLoad load) { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
365 SedimentLoad fairLoad = load; |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
366 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
367 Range lastOtherRange = null; |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
368 double lastOtherValue = 0d; |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
369 |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
370 Range lastSuspRange = null; |
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
371 double lastSuspValue = 0d; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
372 |
6498
686bbfeacfe5
issue1235: sort km when running over them for total sediment load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6411
diff
changeset
|
373 TreeSet<Double> kms = new TreeSet<Double>(load.getKms()); |
686bbfeacfe5
issue1235: sort km when running over them for total sediment load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6411
diff
changeset
|
374 |
686bbfeacfe5
issue1235: sort km when running over them for total sediment load.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6411
diff
changeset
|
375 for (double km: kms) { |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
376 logger.debug ("Trying to add at km " + km); |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
377 SedimentLoadFraction fraction = load.getFraction(km); |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
378 if (complete(fraction)) { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
379 double total = fraction.getCoarse() + |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
380 fraction.getFineMiddle() + |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
381 fraction.getSand() + |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
382 fraction.getSuspSand() + |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
383 fraction.getSuspSediment(); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
384 // Easiest case. Add values up and set'em. |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
385 if (fraction.getCoarseRange().equals( |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
386 fraction.getSuspSedimentRange())) { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
387 lastOtherRange = null; |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
388 lastSuspRange = null; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
389 fairLoad.setTotal(km, total, fraction.getCoarseRange()); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
390 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
391 else { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
392 // Need to split a range. |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
393 if (fraction.getCoarseRange().getEnd() |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
394 < fraction.getSuspSedimentRange().getEnd()) { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
395 // Schwebstoff is longer. |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
396 // Adjust and remember schwebstoffs range and value. |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
397 lastSuspRange = (Range) fraction.getSuspSedimentRange().clone(); |
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
398 lastSuspRange.setStart(fraction.getCoarseRange().getEnd()); |
6411
a21f7a3e4be5
Revert to rev 6404 for issue1235
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6405
diff
changeset
|
399 lastSuspValue = fraction.getSuspSediment(); |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
400 lastOtherRange = null; |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
401 fairLoad.setTotal(km, total, fraction.getCoarseRange()); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
402 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
403 else { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
404 // Geschiebe is longer. |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
405 // Adjust and remember other values. |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
406 lastOtherRange = (Range) fraction.getSuspSedimentRange().clone(); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
407 lastOtherRange.setStart(fraction.getSuspSedimentRange().getEnd()); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
408 lastOtherValue = (total - fraction.getSuspSediment()); |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
409 lastSuspRange = null; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
410 fairLoad.setTotal(km, total, fraction.getSuspSedimentRange()); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
411 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
412 } |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
413 } |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
414 else if (hasOnlySuspValues(fraction) && lastOtherRange != null) { |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
415 // Split stuff. |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
416 Range suspSedimentRange = fraction.getSuspSedimentRange(); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
417 // if intersects with last other range, cool! merge and add! |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
418 if (lastOtherRange.contains(km)) { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
419 double maxStart = 0d; |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
420 double minEnd = 0d; |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
421 maxStart = Math.max(suspSedimentRange.getStart(), |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
422 lastOtherRange.getStart()); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
423 |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
424 minEnd = Math.min(suspSedimentRange.getEnd(), |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
425 lastOtherRange.getEnd()); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
426 double total = lastOtherValue + fraction.getSuspSediment(); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
427 Range totalRange = new Range(maxStart, minEnd); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
428 if (suspSedimentRange.getEnd() > lastOtherRange.getEnd()) { |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
429 lastSuspRange = (Range) suspSedimentRange.clone(); |
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
430 lastSuspRange.setStart(lastOtherRange.getEnd()); |
6411
a21f7a3e4be5
Revert to rev 6404 for issue1235
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6405
diff
changeset
|
431 lastSuspValue = fraction.getSuspSediment(); |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
432 lastOtherRange = null; |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
433 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
434 else { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
435 // Other is "longer". |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
436 lastOtherRange.setStart(suspSedimentRange.getEnd()); |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
437 lastSuspRange = null; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
438 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
439 if (Math.abs(suspSedimentRange.getEnd() - lastOtherRange.getEnd()) < 0.1d) { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
440 lastOtherRange = null; |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
441 lastSuspRange = null; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
442 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
443 fairLoad.setTotal(km, total + fraction.getSuspSediment(), totalRange); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
444 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
445 else { |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
446 lastSuspRange = suspSedimentRange; |
6411
a21f7a3e4be5
Revert to rev 6404 for issue1235
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6405
diff
changeset
|
447 lastSuspValue = fraction.getSuspSediment(); |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
448 lastOtherRange = null; |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
449 } |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
450 } |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
451 else if (hasButSuspValues(fraction) && lastSuspRange != null) { |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
452 // If intersects with last suspsed range, merge and add |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
453 double total = fraction.getCoarse() + |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
454 fraction.getFineMiddle() + |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
455 fraction.getSand() + |
6411
a21f7a3e4be5
Revert to rev 6404 for issue1235
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6405
diff
changeset
|
456 fraction.getSuspSand() + |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
457 lastSuspValue; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
458 double maxStart = Math.max(fraction.getCoarseRange().getStart(), |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
459 lastSuspRange.getStart()); |
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
460 if (lastSuspRange.contains(km)) { |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
461 double minEnd = Math.min(fraction.getCoarseRange().getEnd(), |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
462 lastSuspRange.getEnd()); |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
463 Range totalRange = new Range(maxStart, minEnd); |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
464 if (lastSuspRange.getEnd() > fraction.getCoarseRange().getEnd()) { |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
465 // SuspSed longer. |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
466 lastSuspRange.setStart(fraction.getCoarseRange().getEnd()); |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
467 lastOtherRange = null; |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
468 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
469 else { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
470 // Other longer |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
471 lastOtherRange = (Range) fraction.getCoarseRange().clone(); |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
472 lastOtherRange.setStart(lastSuspRange.getEnd()); |
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
473 lastSuspRange = null; |
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
474 lastOtherValue = total - lastSuspValue; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
475 } |
6499
857f4d51d859
issue1235: Avoid NPE.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6498
diff
changeset
|
476 if (lastSuspRange != null && Math.abs(lastSuspRange.getEnd() - lastOtherRange.getEnd()) < 0.1d) { |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
477 lastOtherRange = null; |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
478 lastSuspRange = null; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
479 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
480 fairLoad.setTotal(km, total, totalRange); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
481 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
482 else { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
483 // Ranges are disjoint. |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
484 lastOtherRange = fraction.getCoarseRange(); |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
485 lastOtherValue = total - fraction.getSuspSediment(); |
6404
e6ceab9e3091
prep issue1235: Rename functions and variable to indicate use of other susp values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6381
diff
changeset
|
486 lastSuspRange = null; |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
487 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
488 } |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
489 else { |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
490 // Some values are missing or no intersection with former values. |
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
491 // Stay as we are. |
6500
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
492 if (hasButSuspValues(fraction)) { |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
493 double total = fraction.getCoarse() + |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
494 fraction.getFineMiddle() + |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
495 fraction.getSand() + |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
496 fraction.getSuspSand(); |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
497 lastOtherRange = fraction.getCoarseRange(); |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
498 lastOtherValue = total; |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
499 lastSuspRange = null; |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
500 } |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
501 else if (hasOnlySuspValues(fraction)) { |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
502 lastSuspRange = fraction.getSuspSedimentRange(); |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
503 lastSuspValue = fraction.getSuspSediment(); |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
504 lastOtherRange = null; |
f3b3742fbdad
SedimentLoadCalculation: Handle boring cases in total sed load calculation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6499
diff
changeset
|
505 } |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
506 } |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
507 } |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
508 return fairLoad; |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
509 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
510 |
6381
df1a3826c691
SedimentLoadCalculation: Calculate and set Total Load values ind a brutal range merging manner.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6377
diff
changeset
|
511 |
6678 | 512 /** |
513 * Transform values in load. | |
514 * @param load The load of which values should be transformed. | |
515 * @return parameter load with transformed values. | |
516 */ | |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
517 private SedimentLoad calculateUnit(SedimentLoad load, int year) { |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
518 SedimentDensity density = |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
519 SedimentDensityFactory.getSedimentDensity(river, kmLow, kmUp, year); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
520 for (double km: load.getKms()) { |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
521 double dens = density.getDensity(km, year); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
522 SedimentLoadFraction fraction = load.getFraction(km); |
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
523 double coarse = fraction.getCoarse(); |
6376
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
524 double fineMiddle = fraction.getFineMiddle(); |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
525 double sand = fraction.getSand(); |
6376
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
526 double suspSand = fraction.getSuspSand(); |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
527 double bedSand = fraction.getSuspSandBed(); |
8d6f23243d1d
SedimentLoad*: Switch from snake_case to camelCase.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6375
diff
changeset
|
528 double sediment = fraction.getSuspSediment(); |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
529 double total = fraction.getTotal(); |
6374
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
530 load.setCoarse(km, (coarse * dens), fraction.getCoarseRange()); |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
531 load.setFineMiddle(km, (fineMiddle * dens), fraction.getFineMiddleRange()); |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
532 load.setSand(km, (sand * dens), fraction.getSandRange()); |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
533 load.setSuspSand(km, (suspSand * dens), fraction.getSuspSandRange()); |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
534 load.setSuspSandBed(km, (bedSand * dens), fraction.getSuspSandBedRange()); |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
535 load.setSuspSediment(km, (sediment * dens), fraction.getSuspSedimentRange()); |
48e92ff57f23
SedimentLoad*: Set range to fraction/fractions values.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5994
diff
changeset
|
536 load.setTotal(km, (total * dens), fraction.getTotalRange()); |
4522
a9753f717b3d
Completed and fixed sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
4483
diff
changeset
|
537 } |
4373
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
538 return load; |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
539 } |
1fb224bb2c6b
Added sediment load calculation.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
540 } |
4483
cc6323401643
Cosmetics: Removed some WSP, obsolete imports. Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4373
diff
changeset
|
541 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |