annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flowdepth/FlowVelocityKmModelValues.java @ 8964:45f1ad66560e

Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
author gernotbelger
date Thu, 29 Mar 2018 15:48:17 +0200
parents 89f3c5462a16
children 9bd4505a20dc
rev   line source
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
2 * Software engineering by
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
5 *
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
9 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
10
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
11 package org.dive4elements.river.artifacts.sinfo.flowdepth;
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
12
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
13 import org.apache.commons.math.analysis.interpolation.LinearInterpolator;
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
14 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction;
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
15
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
16 import gnu.trove.TDoubleArrayList;
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
17
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
18 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
19 * Sorted arrays of a station's q, v, and tau model values, running in parallel
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
20 *
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
21 * @author Matthias Schäfer
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
22 *
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
23 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
24 public class FlowVelocityKmModelValues {
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
25
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
26 /***** FIELDS *****/
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
27
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
28 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
29 * Km
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
30 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
31 private final double km;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
32
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
33 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
34 * The station's discharge model values, sorted in ascending order
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
35 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
36 private final TDoubleArrayList qs;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
37
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
38 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
39 * The station's main section velocity for the q values
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
40 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
41 private final TDoubleArrayList vmains;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
42
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
43 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
44 * The station's shear stress (tau) values for the q values
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
45 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
46 private final TDoubleArrayList taus;
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
47
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
48 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
49 * Discharge found by the last findQ
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
50 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
51 private double findQ;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
52
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
53 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
54 * Velocity found by the last {@link findQ}
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
55 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
56 private double vmainFound;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
57
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
58 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
59 * Shear stress found by the last {@link findQ}
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
60 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
61 private double tauFound;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
62
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
63 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
64 * Whether qFound has been interpolated
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
65 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
66 private boolean isInterpolated;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
67
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
68 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
69 * Real linear interpolator for q and v values
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
70 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
71 private PolynomialSplineFunction vInterpolator;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
72
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
73 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
74 * Real linear interpolator for q and tau values
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
75 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
76 private PolynomialSplineFunction tauInterpolator;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
77
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
78 /***** CONSTRUCTORS *****/
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
79
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
80 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
81 * Constructor with km parameter
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
82 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
83 public FlowVelocityKmModelValues(final double km) {
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
84 this.km = km;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
85 this.qs = new TDoubleArrayList();
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
86 this.vmains = new TDoubleArrayList();
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
87 this.taus = new TDoubleArrayList();
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
88 this.vInterpolator = null;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
89 this.tauInterpolator = null;
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
90 }
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
91
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
92 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
93 * Copy constructor with new km
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
94 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
95 public FlowVelocityKmModelValues(final double km, final FlowVelocityKmModelValues src) {
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
96 this(km);
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
97 src.copyTo(this.qs, this.vmains, this.taus);
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
98 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
99
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
100 /***** METHODS *****/
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
101
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
102 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
103 * Number of the q-v-tau tuples
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
104 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
105 public int size() {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
106 return this.qs.size();
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
107 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
108
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
109 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
110 * Km
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
111 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
112 public double getKm() {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
113 return this.km;
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
114 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
115
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
116 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
117 * Adds all q-v-tau to another set of arrays
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
118 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
119 void copyTo(final TDoubleArrayList dstqs, final TDoubleArrayList dstvmains, final TDoubleArrayList dsttaus) {
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
120 for (int i = 0; i <= this.qs.size(); i++) {
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
121 dstqs.add(this.qs.getQuick(i));
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
122 dstvmains.add(this.vmains.getQuick(i));
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
123 dsttaus.add(this.taus.getQuick(i));
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
124 }
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
125 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
126
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
127 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
128 * Discharge found by the last {@link findQ}
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
129 *
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
130 * @return
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
131 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
132 public double getFindQ() {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
133 return this.findQ;
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
134 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
135
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
136 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
137 * Velocity found by the last {@link findQ}
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
138 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
139 public double getVmainFound() {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
140 return this.vmainFound;
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
141 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
142
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
143 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
144 * Shear stress found by the last {@link findQ}
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
145 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
146 public double getTauFound() {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
147 return this.tauFound;
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
148 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
149
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
150 /**
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
151 * Whether qFound has been interpolated
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
152 */
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
153 public boolean getIsInterpolated() {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
154 return this.isInterpolated;
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
155 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
156
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
157 /**
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
158 * Adds a q-v-tau value triple.
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
159 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
160 public void addValues(final double q, final double vmain, final double tau) {
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
161 this.qs.add(q);
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
162 this.vmains.add(vmain);
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
163 this.taus.add(tau);
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
164 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
165
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
166 /**
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
167 * Searches a discharge value and returns it or the interpolated value
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
168 *
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
169 * @return Found or interpolated discharge, or NaN otherwise
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
170 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
171 public double findQ(final double q) {
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
172 if (this.vInterpolator == null) {
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
173 this.vInterpolator = new LinearInterpolator().interpolate(this.qs.toNativeArray(), this.vmains.toNativeArray());
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
174 this.tauInterpolator = new LinearInterpolator().interpolate(this.qs.toNativeArray(), this.taus.toNativeArray());
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
175 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
176
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
177 this.findQ = q;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
178
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
179 try {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
180 this.vmainFound = this.vInterpolator.value(q);
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
181 this.tauFound = this.tauInterpolator.value(q);
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
182 return q;
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
183 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
184 catch (final Exception e) {
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
185 e.printStackTrace();
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
186 return Double.NaN;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
187 }
8898
89f3c5462a16 Implemented S-INFO Flowdepth TKH calculation
mschaefer
parents:
diff changeset
188 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8898
diff changeset
189 }

http://dive4elements.wald.intevation.org