Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/WstValueTable.java @ 8704:93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 23 Apr 2015 19:13:33 +0200 |
parents | b9e5fa7f7a28 |
children | 5e38e2924c07 |
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:
4797
diff
changeset
|
9 package org.dive4elements.river.artifacts.model; |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.io.Serializable; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4797
diff
changeset
|
13 import org.dive4elements.river.artifacts.math.Linear; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4797
diff
changeset
|
14 import org.dive4elements.river.artifacts.math.Function; |
6434
898afcce1d0a
Partial fix for flys/1303
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
15 import org.dive4elements.river.utils.DoubleUtil; |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
16 |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
17 import java.util.Arrays; |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 import java.util.ArrayList; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import java.util.List; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import java.util.Collections; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
22 import org.apache.log4j.Logger; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
23 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
24 import org.apache.commons.math.analysis.interpolation.SplineInterpolator; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
25 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
26 import org.apache.commons.math.analysis.polynomials.PolynomialSplineFunction; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
27 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
28 import org.apache.commons.math.ArgumentOutsideDomainException; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
29 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
30 import org.apache.commons.math.exception.MathIllegalArgumentException; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
31 |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
32 import gnu.trove.TDoubleArrayList; |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
33 |
8662
c9b8ad659d5b
Use EpsilonComparator instead of redundant implementation.
"Tom Gottfried <tom@intevation.de>"
parents:
7015
diff
changeset
|
34 import static org.dive4elements.river.backend.utils.EpsilonComparator.CMP; |
c9b8ad659d5b
Use EpsilonComparator instead of redundant implementation.
"Tom Gottfried <tom@intevation.de>"
parents:
7015
diff
changeset
|
35 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
36 /** |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
37 * W, Q and km data from database 'wsts' spiced with interpolation algorithms. |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
38 */ |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 public class WstValueTable |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 implements Serializable |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 { |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
42 private static Logger log = Logger.getLogger(WstValueTable.class); |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 |
395
aae8f327425e
'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
380
diff
changeset
|
44 public static final int DEFAULT_Q_STEPS = 500; |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
45 |
2253
707b47d8c554
Dont sort the data series in reference curve.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2248
diff
changeset
|
46 public static final int RELATE_WS_SAMPLES = 200; |
2186
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
47 |
8664
b9e5fa7f7a28
(issue1787) Do not accept any non-NaN W-value but check for epsilon.
"Tom Gottfried <tom@intevation.de>"
parents:
8663
diff
changeset
|
48 public static final double W_EPSILON = 0.000001; |
b9e5fa7f7a28
(issue1787) Do not accept any non-NaN W-value but check for epsilon.
"Tom Gottfried <tom@intevation.de>"
parents:
8663
diff
changeset
|
49 |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
50 /** |
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
51 * A Column in the table, typically representing one measurement session. |
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
52 */ |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
53 public static final class Column |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
54 implements Serializable |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 protected String name; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 |
632
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
58 protected QRangeTree qRangeTree; |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
59 |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 public Column() { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 public Column(String name) { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 this.name = name; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 public String getName() { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 return name; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 public void setName(String name) { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 this.name = name; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 } |
632
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
74 |
4797
43e69af28b3c
A naive algorithm to figure out the "Umhuellende" of a set of WQKms.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4119
diff
changeset
|
75 public QRangeTree getQRangeTree() { |
632
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
76 return qRangeTree; |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
77 } |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
78 |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
79 public void setQRangeTree(QRangeTree qRangeTree) { |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
80 this.qRangeTree = qRangeTree; |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
81 } |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
82 } // class Column |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
84 /** |
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
85 * A (weighted) position used for interpolation. |
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
86 */ |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
87 public static final class QPosition { |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
88 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
89 protected int index; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
90 protected double weight; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
91 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
92 public QPosition() { |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
93 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
94 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
95 public QPosition(int index, double weight) { |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
96 this.index = index; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
97 this.weight = weight; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
98 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
99 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
100 public QPosition set(int index, double weight) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
101 this.index = index; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
102 this.weight = weight; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
103 return this; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
104 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
105 |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
106 } // class Position |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
107 |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
108 public static final class SplineFunction { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
109 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
110 public PolynomialSplineFunction spline; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
111 public double [] splineQs; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
112 public double [] splineWs; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
113 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
114 public SplineFunction( |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
115 PolynomialSplineFunction spline, |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2560
diff
changeset
|
116 double [] splineQs, |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
117 double [] splineWs |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
118 ) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
119 this.spline = spline; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
120 this.splineQs = splineQs; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
121 this.splineWs = splineWs; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
122 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
123 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
124 public double [][] sample( |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2560
diff
changeset
|
125 int numSamples, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2560
diff
changeset
|
126 double km, |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
127 Calculation errors |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
128 ) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
129 double minQ = getQMin(); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
130 double maxQ = getQMax(); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
131 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
132 double [] outWs = new double[numSamples]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
133 double [] outQs = new double[numSamples]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
134 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
135 Arrays.fill(outWs, Double.NaN); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
136 Arrays.fill(outQs, Double.NaN); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
137 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
138 double stepWidth = (maxQ - minQ)/numSamples; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
139 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
140 try { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
141 double q = minQ; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
142 for (int i = 0; i < outWs.length; ++i, q += stepWidth) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
143 outWs[i] = spline.value(outQs[i] = q); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
144 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
145 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
146 catch (ArgumentOutsideDomainException aode) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
147 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
148 errors.addProblem(km, "spline.interpolation.failed"); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
149 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
150 log.error("spline interpolation failed.", aode); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
151 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
152 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
153 return new double [][] { outWs, outQs }; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
154 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
155 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
156 public double getQMin() { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
157 return Math.min(splineQs[0], splineQs[splineQs.length-1]); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
158 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
159 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
160 public double getQMax() { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
161 return Math.max(splineQs[0], splineQs[splineQs.length-1]); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
162 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
163 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
164 /** Constructs a continues index between the columns to Qs. */ |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
165 public PolynomialSplineFunction createIndexQRelation() { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
166 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
167 double [] indices = new double[splineQs.length]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
168 for (int i = 0; i < indices.length; ++i) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
169 indices[i] = i; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
170 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
171 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
172 try { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
173 SplineInterpolator interpolator = new SplineInterpolator(); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
174 return interpolator.interpolate(indices, splineQs); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
175 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
176 catch (MathIllegalArgumentException miae) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
177 // Ignore me! |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
178 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
179 return null; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
180 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
181 } // class SplineFunction |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
182 |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
183 /** |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
184 * A row, typically a position where measurements were taken. |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
185 */ |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
186 public static final class Row |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
187 implements Serializable, Comparable<Row> |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
188 { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
189 double km; |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
190 double [] ws; |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
192 public Row() { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
193 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
194 |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
195 public Row(double km) { |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
196 this.km = km; |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
197 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
198 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
199 public Row(double km, double [] ws) { |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
200 this(km); |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
201 this.ws = ws; |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
202 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
203 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
204 /** |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
205 * Sort Qs and Ws for this Row over Q. |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
206 */ |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
207 private double[][] getSortedWQ( |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
208 WstValueTable table, |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
209 Calculation errors |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
210 ) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
211 int W = ws.length; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
212 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
213 if (W < 1) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
214 if (errors != null) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
215 errors.addProblem(km, "no.ws.found"); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
216 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
217 return new double[][] {{Double.NaN}, {Double.NaN}}; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
218 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
219 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
220 double [] sortedWs = ws; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
221 double [] sortedQs = new double[W]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
222 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
223 for (int i=0; i < W; ++i) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
224 double q = table.getQIndex(i, km); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
225 if (Double.isNaN(q) && errors != null) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
226 errors.addProblem( |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
227 km, "no.q.found.in.column", i+1); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
228 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
229 sortedQs[i] = q; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
230 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
231 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
232 DoubleUtil.sortByFirst(sortedQs, sortedWs); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
233 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
234 return new double[][] { sortedWs, sortedQs }; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
235 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
236 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
237 /** |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
238 * Return an array of Qs and Ws for the given km between |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
239 * this Row and another, sorted over Q. |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
240 */ |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
241 private double[][] getSortedWQ( |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
242 Row other, |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
243 double km, |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
244 WstValueTable table, |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
245 Calculation errors |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
246 ) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
247 int W = Math.min(ws.length, other.ws.length); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
248 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
249 if (W < 1) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
250 if (errors != null) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
251 errors.addProblem("no.ws.found"); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
252 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
253 return new double[][] {{Double.NaN}, {Double.NaN}}; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
254 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
255 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
256 double factor = Linear.factor(km, this.km, other.km); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
257 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
258 double [] sortedQs = new double[W]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
259 double [] sortedWs = new double[W]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
260 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
261 for (int i = 0; i < W; ++i) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
262 double wws = Linear.weight(factor, ws[i], other.ws[i]); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
263 double wqs = table.getQIndex(i, km); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
264 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
265 if (Double.isNaN(wws) || Double.isNaN(wqs)) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
266 if (errors != null) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
267 errors.addProblem(km, "cannot.find.w.or.q"); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
268 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
269 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
270 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
271 sortedWs[i] = wws; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
272 sortedQs[i] = wqs; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
273 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
274 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
275 DoubleUtil.sortByFirst(sortedQs, sortedWs); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
276 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
277 return new double[][] { sortedWs, sortedQs }; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
278 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
279 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
280 /** |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
281 * Find Qs matching w in an array of Qs and Ws sorted over Q. |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
282 */ |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
283 private double[] findQsForW(double w, double[][] sortedWQ) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
284 int W = sortedWQ[0].length; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
285 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
286 double[] sortedQs = sortedWQ[1]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
287 double[] sortedWs = sortedWQ[0]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
288 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
289 TDoubleArrayList qs = new TDoubleArrayList(); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
290 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
291 if (W > 0 && Math.abs(sortedWs[0]-w) < W_EPSILON) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
292 double q = sortedQs[0]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
293 if (!Double.isNaN(q)) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
294 qs.add(q); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
295 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
296 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
297 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
298 for (int i = 1; i < W; ++i) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
299 double w2 = sortedWs[i]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
300 if (Double.isNaN(w2)) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
301 continue; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
302 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
303 if (Math.abs(w2-w) < W_EPSILON) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
304 double q = sortedQs[i]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
305 if (!Double.isNaN(q)) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
306 qs.add(q); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
307 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
308 continue; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
309 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
310 double w1 = sortedWs[i-1]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
311 if (Double.isNaN(w1)) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
312 continue; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
313 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
314 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
315 if (w < Math.min(w1, w2) || w > Math.max(w1, w2)) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
316 continue; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
317 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
318 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
319 double q1 = sortedQs[i-1]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
320 double q2 = sortedQs[i]; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
321 if (Double.isNaN(q1) || Double.isNaN(q2)) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
322 continue; |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
323 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
324 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
325 double q = Linear.linear(w, w1, w2, q1, q2); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
326 qs.add(q); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
327 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
328 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
329 return qs.toNativeArray(); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
330 } |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
331 |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
332 /** |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
333 * Compare according to place of measurement (km). |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
334 */ |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
335 public int compareTo(Row other) { |
8662
c9b8ad659d5b
Use EpsilonComparator instead of redundant implementation.
"Tom Gottfried <tom@intevation.de>"
parents:
7015
diff
changeset
|
336 return CMP.compare(km, other.km); |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
337 } |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
338 |
1887
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
339 /** |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
340 * Interpolate Ws, given Qs and a km. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
341 * |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
342 * @param iqs Given ("input") Qs. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
343 * @param ows Resulting ("output") Ws. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
344 * @param table Table of which to use data for interpolation. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
345 */ |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
346 public void interpolateW( |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
347 Row other, |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
348 double km, |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
349 double [] iqs, |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
350 double [] ows, |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
351 WstValueTable table, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
352 Calculation errors |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
353 ) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
354 double kmWeight = Linear.factor(km, this.km, other.km); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
355 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
356 QPosition qPosition = new QPosition(); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
357 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
358 for (int i = 0; i < iqs.length; ++i) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
359 if (table.getQPosition(km, iqs[i], qPosition) != null) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
360 double wt = getW(qPosition); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
361 double wo = other.getW(qPosition); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
362 if (Double.isNaN(wt) || Double.isNaN(wo)) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
363 if (errors != null) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
364 errors.addProblem( |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
365 km, "cannot.find.w.for.q", iqs[i]); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
366 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
367 ows[i] = Double.NaN; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
368 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
369 else { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
370 ows[i] = Linear.weight(kmWeight, wt, wo); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
371 } |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
372 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
373 else { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
374 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
375 errors.addProblem(km, "cannot.find.q", iqs[i]); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
376 } |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
377 ows[i] = Double.NaN; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
378 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
379 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
380 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
381 |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
382 |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
383 public SplineFunction createSpline( |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
384 WstValueTable table, |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
385 Calculation errors |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
386 ) { |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
387 double[][] sortedWQ = getSortedWQ(table, errors); |
7000
7a7cb22395b4
Fix for flys/issue1018: Sort the pairs of (q, w) in q before creating a spline also in case of non interpolation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
6923
diff
changeset
|
388 |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
389 try { |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
390 SplineInterpolator interpolator = new SplineInterpolator(); |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
391 PolynomialSplineFunction spline = |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
392 interpolator.interpolate(sortedWQ[1], sortedWQ[0]); |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
393 |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
394 return new SplineFunction(spline, sortedWQ[1], ws); |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
395 } |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
396 catch (MathIllegalArgumentException miae) { |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
397 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
398 errors.addProblem(km, "spline.creation.failed"); |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
399 } |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
400 log.error("spline creation failed", miae); |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
401 } |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
402 return null; |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
403 } |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
404 |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
405 public SplineFunction createSpline( |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
406 Row other, |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
407 double km, |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
408 WstValueTable table, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
409 Calculation errors |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
410 ) { |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
411 double[][] sortedWQ = getSortedWQ(other, km, table, errors); |
6434
898afcce1d0a
Partial fix for flys/1303
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
412 |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
413 SplineInterpolator interpolator = new SplineInterpolator(); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
414 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
415 try { |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
416 PolynomialSplineFunction spline = |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
417 interpolator.interpolate(sortedWQ[1], sortedWQ[0]); |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
418 |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
419 return new SplineFunction(spline, sortedWQ[1], sortedWQ[0]); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
420 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
421 catch (MathIllegalArgumentException miae) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
422 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
423 errors.addProblem(km, "spline.creation.failed"); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
424 } |
1860
ddd425858169
Improved logging to include exception in fail case of spline interpolation of wst.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
425 log.error("spline creation failed", miae); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
426 } |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
427 |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
428 return null; |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
429 } |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
430 |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
431 public double [][] interpolateWQ( |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
432 Row other, |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
433 double km, |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
434 int steps, |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
435 WstValueTable table, |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
436 Calculation errors |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
437 ) { |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
438 SplineFunction sf = createSpline(other, km, table, errors); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
439 |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
440 return sf != null |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
441 ? sf.sample(steps, km, errors) |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
442 : new double[2][0]; |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
443 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
444 |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
445 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
446 public double [][] interpolateWQ( |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
447 int steps, |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
448 WstValueTable table, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
449 Calculation errors |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
450 ) { |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
451 SplineFunction sf = createSpline(table, errors); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
452 |
1938
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
453 return sf != null |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
454 ? sf.sample(steps, km, errors) |
1d991c91285b
Refactored the code of the 'berechnete Abflusskurve' to be reusable in the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1937
diff
changeset
|
455 : new double[2][0]; |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
456 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
457 |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
458 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
459 public double getW(QPosition qPosition) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
460 int index = qPosition.index; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
461 double weight = qPosition.weight; |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
462 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
463 return weight == 1.0 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
464 ? ws[index] |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
465 : Linear.weight(weight, ws[index-1], ws[index]); |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
466 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
467 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
468 public double getW( |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
469 Row other, |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
470 double km, |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
471 QPosition qPosition |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
472 ) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
473 double kmWeight = Linear.factor(km, this.km, other.km); |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
474 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
475 int index = qPosition.index; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
476 double weight = qPosition.weight; |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
477 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
478 double tw, ow; |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
479 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
480 if (weight == 1.0) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
481 tw = ws[index]; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
482 ow = other.ws[index]; |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
483 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
484 else { |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
485 tw = Linear.weight(weight, ws[index-1], ws[index]); |
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
486 ow = Linear.weight(weight, other.ws[index-1], other.ws[index]); |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
487 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
488 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
489 return Linear.weight(kmWeight, tw, ow); |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
490 } |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
491 |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
492 public double [] findQsForW( |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
493 double w, |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
494 WstValueTable table, |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
495 Calculation errors |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
496 ) { |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
497 log.debug("Find Qs for given W at tabulated km " + km); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
498 return findQsForW(w, getSortedWQ(table, errors)); |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
499 } |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
500 |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
501 public double [] findQsForW( |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
502 Row other, |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
503 double w, |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2560
diff
changeset
|
504 double km, |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
505 WstValueTable table, |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
506 Calculation errors |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
507 ) { |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
508 log.debug("Find Qs for given W at non-tabulated km " + km); |
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
509 return findQsForW(w, getSortedWQ(other, km, table, errors)); |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
510 } |
2423
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
511 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
512 public double [] getMinMaxW(double [] result) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
513 double minW = Double.MAX_VALUE; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
514 double maxW = -Double.MAX_VALUE; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
515 for (int i = 0; i < ws.length; ++i) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
516 double w = ws[i]; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
517 if (w < minW) minW = w; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
518 if (w > maxW) maxW = w; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
519 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
520 result[0] = minW; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
521 result[1] = maxW; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
522 return result; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
523 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
524 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
525 public double [] getMinMaxW(Row other, double km, double [] result) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
526 double [] m1 = this .getMinMaxW(new double [2]); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
527 double [] m2 = other.getMinMaxW(new double [2]); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
528 double factor = Linear.factor(km, this.km, other.km); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
529 result[0] = Linear.weight(factor, m1[0], m2[0]); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
530 result[1] = Linear.weight(factor, m1[1], m2[1]); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
531 return result; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
532 } |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
533 } // class Row |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
534 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
535 /** Rows in table. */ |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
536 protected List<Row> rows; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
537 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
538 /** Columns in table. */ |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
539 protected Column [] columns; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
540 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
541 public WstValueTable() { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
542 rows = new ArrayList<Row>(); |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
543 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
544 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
545 public WstValueTable(Column [] columns) { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
546 this(); |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
547 this.columns = columns; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
548 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
549 |
8663
b78ca00d4659
Sorting rows is a prerequisite.
"Tom Gottfried <tom@intevation.de>"
parents:
8662
diff
changeset
|
550 /** |
b78ca00d4659
Sorting rows is a prerequisite.
"Tom Gottfried <tom@intevation.de>"
parents:
8662
diff
changeset
|
551 * @param columns The WST-columns. |
b78ca00d4659
Sorting rows is a prerequisite.
"Tom Gottfried <tom@intevation.de>"
parents:
8662
diff
changeset
|
552 * @param rows A list of Rows that must be sorted by km. |
b78ca00d4659
Sorting rows is a prerequisite.
"Tom Gottfried <tom@intevation.de>"
parents:
8662
diff
changeset
|
553 */ |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
554 public WstValueTable(Column [] columns, List<Row> rows) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
555 this.columns = columns; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
556 this.rows = rows; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
557 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
558 |
4797
43e69af28b3c
A naive algorithm to figure out the "Umhuellende" of a set of WQKms.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4119
diff
changeset
|
559 public Column [] getColumns() { |
43e69af28b3c
A naive algorithm to figure out the "Umhuellende" of a set of WQKms.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4119
diff
changeset
|
560 return columns; |
43e69af28b3c
A naive algorithm to figure out the "Umhuellende" of a set of WQKms.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4119
diff
changeset
|
561 } |
43e69af28b3c
A naive algorithm to figure out the "Umhuellende" of a set of WQKms.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4119
diff
changeset
|
562 |
1887
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
563 /** |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
564 * @param km Given kilometer. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
565 * @param qs Given Q values. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
566 * @param ws output parameter. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
567 */ |
380
5f55047a17e8
Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
374
diff
changeset
|
568 public double [] interpolateW(double km, double [] qs, double [] ws) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
569 return interpolateW(km, qs, ws, null); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
570 } |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
571 |
1098
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
572 |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
573 /** |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
574 * @param ws (output parameter), gets returned. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
575 * @return output parameter ws. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
576 */ |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
577 public double [] interpolateW( |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
578 double km, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
579 double [] qs, |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
580 double [] ws, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
581 Calculation errors |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
582 ) { |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
583 int rowIndex = Collections.binarySearch(rows, new Row(km)); |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
584 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
585 QPosition qPosition = new QPosition(); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
586 |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
587 if (rowIndex >= 0) { // direct row match |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
588 Row row = rows.get(rowIndex); |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
589 for (int i = 0; i < qs.length; ++i) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
590 if (getQPosition(km, qs[i], qPosition) == null) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
591 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
592 errors.addProblem(km, "cannot.find.q", qs[i]); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
593 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
594 ws[i] = Double.NaN; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
595 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
596 else { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
597 if (Double.isNaN(ws[i] = row.getW(qPosition)) |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
598 && errors != null) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
599 errors.addProblem( |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
600 km, "cannot.find.w.for.q", qs[i]); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
601 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
602 } |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
603 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
604 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
605 else { // needs bilinear interpolation |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
606 rowIndex = -rowIndex -1; |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
607 |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
608 if (rowIndex < 1 || rowIndex >= rows.size()) { |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
609 // do not extrapolate |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
610 Arrays.fill(ws, Double.NaN); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
611 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
612 errors.addProblem(km, "km.not.found"); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
613 } |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
614 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
615 else { |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
616 Row r1 = rows.get(rowIndex-1); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
617 Row r2 = rows.get(rowIndex); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
618 r1.interpolateW(r2, km, qs, ws, this, errors); |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
619 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
620 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
621 |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
622 return ws; |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
623 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
624 |
2559
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
625 public double [] getMinMaxQ(double km) { |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
626 return getMinMaxQ(km, new double [2]); |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
627 } |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
628 |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
629 public double [] getMinMaxQ(double km, double [] result) { |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
630 double minQ = Double.MAX_VALUE; |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
631 double maxQ = -Double.MAX_VALUE; |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
632 |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
633 for (int i = 0; i < columns.length; ++i) { |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
634 double q = columns[i].getQRangeTree().findQ(km); |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
635 if (!Double.isNaN(q)) { |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
636 if (q < minQ) minQ = q; |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
637 if (q > maxQ) maxQ = q; |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
638 } |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
639 } |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
640 |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
641 if (minQ < Double.MAX_VALUE) { |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
642 result[0] = minQ; |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
643 result[1] = maxQ; |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
644 return result; |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
645 } |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
646 |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
647 return null; |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
648 } |
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
649 |
2560
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
650 public double [] getMinMaxQ(double from, double to, double step) { |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
651 double [] result = new double[2]; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
652 |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
653 double minQ = Double.MAX_VALUE; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
654 double maxQ = -Double.MAX_VALUE; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
655 |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
656 if (from > to) { |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
657 double tmp = from; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
658 from = to; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
659 to = tmp; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
660 } |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
661 |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
662 step = Math.max(Math.abs(step), 0.0001); |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
663 |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
664 double d = from; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
665 for (; d <= to; d += step) { |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
666 if (getMinMaxQ(d, result) != null) { |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
667 if (result[0] < minQ) minQ = result[0]; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
668 if (result[1] > maxQ) maxQ = result[1]; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
669 } |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
670 } |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
671 |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
672 if (d != to) { |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
673 if (getMinMaxQ(to, result) != null) { |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
674 if (result[0] < minQ) minQ = result[0]; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
675 if (result[1] > maxQ) maxQ = result[1]; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
676 } |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
677 } |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
678 |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
679 return minQ < Double.MAX_VALUE |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
680 ? new double [] { minQ, maxQ } |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
681 : null; |
0d8c97374dc9
WstValueTable: Forget to check in the range method of getMinMaxQ().
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2559
diff
changeset
|
682 } |
2559
407bbc74fe0b
WstValueTable: Symmetrical to getMinMaxW() add two methods to find min/max Q for a given
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2558
diff
changeset
|
683 |
2423
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
684 public double [] getMinMaxW(double km) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
685 return getMinMaxW(km, new double [2]); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
686 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
687 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
688 public double [] getMinMaxW(double km, double [] result) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
689 int rowIndex = Collections.binarySearch(rows, new Row(km)); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
690 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
691 if (rowIndex >= 0) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
692 return rows.get(rowIndex).getMinMaxW(result); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
693 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
694 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
695 rowIndex = -rowIndex -1; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
696 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
697 if (rowIndex < 1 || rowIndex >= rows.size()) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
698 // do not extrapolate |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
699 return null; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
700 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
701 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
702 Row r1 = rows.get(rowIndex-1); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
703 Row r2 = rows.get(rowIndex); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
704 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
705 return r1.getMinMaxW(r2, km, result); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
706 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
707 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
708 public double [] getMinMaxW(double from, double to, double step) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
709 double [] result = new double[2]; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
710 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
711 double minW = Double.MAX_VALUE; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
712 double maxW = -Double.MAX_VALUE; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
713 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
714 if (from > to) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
715 double tmp = from; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
716 from = to; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
717 to = tmp; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
718 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
719 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
720 step = Math.max(Math.abs(step), 0.0001); |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
721 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
722 double d = from; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
723 for (; d <= to; d += step) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
724 if (getMinMaxW(d, result) != null) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
725 if (result[0] < minW) minW = result[0]; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
726 if (result[1] > maxW) maxW = result[1]; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
727 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
728 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
729 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
730 if (d != to) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
731 if (getMinMaxW(to, result) != null) { |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
732 if (result[0] < minW) minW = result[0]; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
733 if (result[1] > maxW) maxW = result[1]; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
734 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
735 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
736 |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
737 return minW < Double.MAX_VALUE |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
738 ? new double [] { minW, maxW } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
739 : null; |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
740 } |
ac528b883b47
Picked rev 4070,4074,4076,4080 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2404
diff
changeset
|
741 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
742 /** |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
743 * Interpolate W and Q values at a given km. |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
744 */ |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
745 public double [][] interpolateWQ(double km) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
746 return interpolateWQ(km, null); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
747 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
748 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
749 /** |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
750 * Interpolate W and Q values at a given km. |
3265
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
751 * |
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
752 * @param errors where to store errors. |
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
753 * |
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
754 * @return double double array, first index Ws, second Qs. |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
755 */ |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
756 public double [][] interpolateWQ(double km, Calculation errors) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
757 return interpolateWQ(km, DEFAULT_Q_STEPS, errors); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
758 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
759 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
760 |
1860
ddd425858169
Improved logging to include exception in fail case of spline interpolation of wst.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
761 /** |
ddd425858169
Improved logging to include exception in fail case of spline interpolation of wst.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
762 * Interpolate W and Q values at a given km. |
ddd425858169
Improved logging to include exception in fail case of spline interpolation of wst.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
763 */ |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
764 public double [][] interpolateWQ(double km, int steps, Calculation errors) { |
395
aae8f327425e
'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
380
diff
changeset
|
765 |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
766 int rowIndex = Collections.binarySearch(rows, new Row(km)); |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
767 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
768 if (rowIndex >= 0) { // direct row match |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
769 Row row = rows.get(rowIndex); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
770 return row.interpolateWQ(steps, this, errors); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
771 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
772 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
773 rowIndex = -rowIndex -1; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
774 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
775 if (rowIndex < 1 || rowIndex >= rows.size()) { |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
776 // do not extrapolate |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
777 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
778 errors.addProblem(km, "km.not.found"); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
779 } |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
780 return new double[2][0]; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
781 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
782 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
783 Row r1 = rows.get(rowIndex-1); |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
784 Row r2 = rows.get(rowIndex); |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
785 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
786 return r1.interpolateWQ(r2, km, steps, this, errors); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
787 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
788 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
789 public boolean interpolate( |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
790 double km, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
791 double [] out, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
792 QPosition qPosition, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
793 Function qFunction |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
794 ) { |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
795 int R1 = rows.size()-1; |
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
796 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
797 out[1] = qFunction.value(getQ(qPosition, km)); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
798 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
799 if (Double.isNaN(out[1])) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
800 return false; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
801 } |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
802 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
803 QPosition nPosition = new QPosition(); |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
804 if (getQPosition(km, out[1], nPosition) == null) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
805 return false; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
806 } |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
807 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
808 int rowIndex = Collections.binarySearch(rows, new Row(km)); |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
809 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
810 if (rowIndex >= 0) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
811 // direct row match |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
812 out[0] = rows.get(rowIndex).getW(nPosition); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
813 return !Double.isNaN(out[0]); |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
814 } |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
815 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
816 rowIndex = -rowIndex -1; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
817 |
1681
e5f7f25a511c
fixed flys/issue201
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1098
diff
changeset
|
818 if (rowIndex < 1 || rowIndex > R1) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
819 // do not extrapolate |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
820 return false; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
821 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
822 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
823 Row r1 = rows.get(rowIndex-1); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
824 Row r2 = rows.get(rowIndex); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
825 out[0] = r1.getW(r2, km, nPosition); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
826 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
827 return !Double.isNaN(out[0]); |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
828 } |
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
829 |
1098
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
830 |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
831 /** |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
832 * Look up interpolation of a Q at given positions. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
833 * |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
834 * @param q the non-interpolated Q value. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
835 * @param referenceKm the reference km (e.g. gauge position). |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
836 * @param kms positions for which to interpolate. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
837 * @param ws (output) resulting interpolated ws. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
838 * @param qs (output) resulting interpolated qs. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
839 * @param errors calculation object to store errors. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
840 */ |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
841 public QPosition interpolate( |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
842 double q, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
843 double referenceKm, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
844 double [] kms, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
845 double [] ws, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
846 double [] qs, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
847 Calculation errors |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
848 ) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
849 return interpolate( |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
850 q, referenceKm, kms, ws, qs, 0, kms.length, errors); |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
851 } |
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
852 |
6711 | 853 /** |
854 * Interpolate Q at given positions. | |
855 * @param kms positions for which to calculate qs and ws | |
856 * @param ws [out] calculated ws for kms | |
857 * @param qs [out] looked up qs for kms. | |
858 */ | |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
859 public QPosition interpolate( |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
860 double q, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
861 double referenceKm, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
862 double [] kms, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
863 double [] ws, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
864 double [] qs, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
865 int startIndex, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
866 int length, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
867 Calculation errors |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
868 ) { |
645
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
869 QPosition qPosition = getQPosition(referenceKm, q); |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
870 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
871 if (qPosition == null) { |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
872 // we cannot locate q at km |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
873 Arrays.fill(ws, Double.NaN); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
874 Arrays.fill(qs, Double.NaN); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
875 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
876 errors.addProblem(referenceKm, "cannot.find.q", q); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
877 } |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
878 return null; |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
879 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
880 |
645
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
881 Row kmKey = new Row(); |
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
882 |
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
883 int R1 = rows.size()-1; |
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
884 |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
885 for (int i = startIndex, end = startIndex+length; i < end; ++i) { |
458
523a256451cd
Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
886 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
887 if (Double.isNaN(qs[i] = getQ(qPosition, kms[i]))) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
888 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
889 errors.addProblem(kms[i], "cannot.find.q", q); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
890 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
891 ws[i] = Double.NaN; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
892 continue; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
893 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
894 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
895 kmKey.km = kms[i]; |
645
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
896 int rowIndex = Collections.binarySearch(rows, kmKey); |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
897 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
898 if (rowIndex >= 0) { |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
899 // direct row match |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
900 if (Double.isNaN(ws[i] = rows.get(rowIndex).getW(qPosition)) |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
901 && errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
902 errors.addProblem(kms[i], "cannot.find.w.for.q", q); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
903 } |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
904 continue; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
905 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
906 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
907 rowIndex = -rowIndex -1; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
908 |
1681
e5f7f25a511c
fixed flys/issue201
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1098
diff
changeset
|
909 if (rowIndex < 1 || rowIndex > R1) { |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
910 // do not extrapolate |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
911 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
912 errors.addProblem(kms[i], "km.not.found"); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
913 } |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
914 ws[i] = Double.NaN; |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
915 continue; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
916 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
917 Row r1 = rows.get(rowIndex-1); |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
918 Row r2 = rows.get(rowIndex); |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
919 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
920 if (Double.isNaN(ws[i] = r1.getW(r2, kms[i], qPosition)) |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
921 && errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
922 errors.addProblem(kms[i], "cannot.find.w.for.q", q); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
923 } |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
924 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
925 |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
926 return qPosition; |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
927 } |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
928 |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
929 /** |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
930 * Linearly interpolate w at a km at a column of two rows. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
931 * |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
932 * @param km position for which to interpolate. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
933 * @param row1 first row. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
934 * @param row2 second row. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
935 * @param col column-index at which to look. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
936 * |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
937 * @return Linearly interpolated w, NaN if one of the given rows was null. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
938 */ |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
939 public static double linearW(double km, Row row1, Row row2, int col) { |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
940 if (row1 == null || row2 == null) { |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
941 return Double.NaN; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
942 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
943 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
944 return Linear.linear(km, |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
945 row1.km, row2.km, |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
946 row1.ws[col], row2.ws[col]); |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
947 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
948 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
949 /** |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
950 * Do interpolation/lookup of W and Q within columns (i.e. ignoring values |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
951 * of other columns). |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
952 * @param km position (km) at which to interpolate/lookup. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
953 * @return [[q0, q1, .. qx] , [w0, w1, .. wx]] (can contain NaNs) |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
954 */ |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
955 public double [][] interpolateWQColumnwise(double km) { |
1919
9bec7d2f8c35
Prevent ArrayIndexOutOfBounds, log method entry.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1907
diff
changeset
|
956 log.debug("WstValueTable.interpolateWQColumnwise"); |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
957 double [] qs = new double[columns.length]; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
958 double [] ws = new double[columns.length]; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
959 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
960 // Find out row from where we will start searching. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
961 int rowIndex = Collections.binarySearch(rows, new Row(km)); |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
962 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
963 if (rowIndex < 0) { |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
964 rowIndex = -rowIndex -1; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
965 } |
2248 | 966 |
967 // TODO Beyond definition, we could stop more clever. | |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
968 if (rowIndex >= rows.size()) { |
1919
9bec7d2f8c35
Prevent ArrayIndexOutOfBounds, log method entry.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1907
diff
changeset
|
969 rowIndex = rows.size() -1; |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
970 } |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
971 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
972 Row startRow = rows.get(rowIndex); |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
973 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
974 for (int col = 0; col < columns.length; col++) { |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
975 qs[col] = columns[col].getQRangeTree().findQ(km); |
7015
a9ff696c2d18
Fixed misuse of x !=/== Double.NaN
Sascha L. Teichmann <teichmann@intevation.de>
parents:
7000
diff
changeset
|
976 if (startRow.km == km && !Double.isNaN(startRow.ws[col])) { |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
977 // Great. W is defined at km. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
978 ws[col] = startRow.ws[col]; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
979 continue; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
980 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
981 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
982 // Search neighbouring rows that define w at this col. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
983 Row rowBefore = null; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
984 Row rowAfter = null; |
1899
d002198c64a2
Removed logging noise, find better suited rows for W interpolation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1888
diff
changeset
|
985 for (int before = rowIndex -1; before >= 0; before--) { |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
986 if (!Double.isNaN(rows.get(before).ws[col])) { |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
987 rowBefore = rows.get(before); |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
988 break; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
989 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
990 } |
2248 | 991 if (rowBefore != null) { |
992 for (int after = rowIndex, R = rows.size(); after < R; after++) { | |
993 if (!Double.isNaN(rows.get(after).ws[col])) { | |
994 rowAfter = rows.get(after); | |
995 break; | |
996 } | |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
997 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
998 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
999 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
1000 ws[col] = linearW(km, rowBefore, rowAfter, col); |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
1001 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
1002 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
1003 return new double [][] {qs, ws}; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
1004 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
1005 |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
1006 public double [] findQsForW(double km, double w, Calculation errors) { |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1007 |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1008 int rowIndex = Collections.binarySearch(rows, new Row(km)); |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1009 |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1010 if (rowIndex >= 0) { |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
1011 return rows.get(rowIndex).findQsForW(w, this, errors); |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1012 } |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1013 |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1014 rowIndex = -rowIndex - 1; |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1015 |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1016 if (rowIndex < 1 || rowIndex >= rows.size()) { |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1017 // Do not extrapolate. |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1018 return new double[0]; |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1019 } |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1020 |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1021 // Needs bilinear interpolation. |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1022 Row r1 = rows.get(rowIndex-1); |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1023 Row r2 = rows.get(rowIndex); |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1024 |
8704
93a31cfb18c0
(issue1787) Sort WQ data locally over Q bevor lookup of Qs for given W.
Tom Gottfried <tom@intevation.de>
parents:
8664
diff
changeset
|
1025 return r1.findQsForW(r2, w, km, this, errors); |
1937
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1026 } |
f07d64d5cbe1
'W auf freier Strecke' calculation. Fetch corresponding Qs for given Ws from the WST model
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1919
diff
changeset
|
1027 |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1028 protected SplineFunction createSpline(double km, Calculation errors) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1029 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1030 int rowIndex = Collections.binarySearch(rows, new Row(km)); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1031 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1032 if (rowIndex >= 0) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1033 SplineFunction sf = rows.get(rowIndex).createSpline(this, errors); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1034 if (sf == null && errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
1035 errors.addProblem(km, "cannot.create.wq.relation"); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1036 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1037 return sf; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1038 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1039 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1040 rowIndex = -rowIndex - 1; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1041 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1042 if (rowIndex < 1 || rowIndex >= rows.size()) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1043 // Do not extrapolate. |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1044 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
1045 errors.addProblem(km, "km.not.found"); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1046 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1047 return null; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1048 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1049 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1050 // Needs bilinear interpolation. |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1051 Row r1 = rows.get(rowIndex-1); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1052 Row r2 = rows.get(rowIndex); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1053 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1054 SplineFunction sf = r1.createSpline(r2, km, this, errors); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1055 if (sf == null && errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
1056 errors.addProblem(km, "cannot.create.wq.relation"); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1057 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1058 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1059 return sf; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1060 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1061 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1062 /** 'Bezugslinienverfahren' */ |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1063 public double [][] relateWs( |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2560
diff
changeset
|
1064 double km1, |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1065 double km2, |
2186
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1066 Calculation errors |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1067 ) { |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1068 return relateWs(km1, km2, RELATE_WS_SAMPLES, errors); |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1069 } |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1070 |
2330
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1071 private static class ErrorHandler { |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1072 |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1073 boolean hasErrors; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1074 Calculation errors; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1075 |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1076 ErrorHandler(Calculation errors) { |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1077 this.errors = errors; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1078 } |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1079 |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1080 void error(double km, String key, Object ... args) { |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1081 if (errors != null && !hasErrors) { |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1082 hasErrors = true; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1083 errors.addProblem(km, key, args); |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1084 } |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1085 } |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1086 } // class ErrorHandler |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1087 |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1088 |
2186
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1089 /* TODO: Add optimized methods of relateWs to relate one |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2560
diff
changeset
|
1090 * start km to many end kms. The index generation/spline stuff for |
2186
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1091 * the start km is always the same. |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1092 */ |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1093 public double [][] relateWs( |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2560
diff
changeset
|
1094 double km1, |
2186
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
1095 double km2, |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1096 int numSamples, |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1097 Calculation errors |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1098 ) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1099 SplineFunction sf1 = createSpline(km1, errors); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1100 if (sf1 == null) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1101 return new double[2][0]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1102 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1103 |
2248 | 1104 SplineFunction sf2 = createSpline(km2, errors); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1105 if (sf2 == null) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1106 return new double[2][0]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1107 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1108 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1109 PolynomialSplineFunction iQ1 = sf1.createIndexQRelation(); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1110 if (iQ1 == null) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1111 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
1112 errors.addProblem(km1, "cannot.create.index.q.relation"); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1113 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1114 return new double[2][0]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1115 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1116 |
2404
750cdcccb39c
'Bezugslinienverfahren': Fix the index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2403
diff
changeset
|
1117 PolynomialSplineFunction iQ2 = sf2.createIndexQRelation(); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1118 if (iQ2 == null) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1119 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
1120 errors.addProblem(km2, "cannot.create.index.q.relation"); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1121 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1122 return new double[2][0]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1123 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1124 |
2316
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1125 int N = Math.min(sf1.splineQs.length, sf2.splineQs.length); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1126 double stepWidth = N/(double)numSamples; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1127 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1128 PolynomialSplineFunction qW1 = sf1.spline; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1129 PolynomialSplineFunction qW2 = sf2.spline; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1130 |
2316
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1131 TDoubleArrayList ws1 = new TDoubleArrayList(numSamples); |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1132 TDoubleArrayList ws2 = new TDoubleArrayList(numSamples); |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1133 TDoubleArrayList qs1 = new TDoubleArrayList(numSamples); |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1134 TDoubleArrayList qs2 = new TDoubleArrayList(numSamples); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1135 |
2330
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1136 ErrorHandler err = new ErrorHandler(errors); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1137 |
2316
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1138 int i = 0; |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1139 for (double p = 0d; p <= N-1; p += stepWidth, ++i) { |
2330
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1140 |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1141 double q1; |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1142 try { |
2330
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1143 q1 = iQ1.value(p); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1144 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1145 catch (ArgumentOutsideDomainException aode) { |
2330
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1146 err.error(km1, "w.w.qkm1.failed", p); |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1147 continue; |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1148 } |
2330
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1149 |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1150 double w1; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1151 try { |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1152 w1 = qW1.value(q1); |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1153 } |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1154 catch (ArgumentOutsideDomainException aode) { |
2403
177b0c91928d
'Bezugslinienverfahren': Improve the error messages even more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2330
diff
changeset
|
1155 err.error(km1, "w.w.wkm1.failed", q1, p); |
2330
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1156 continue; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1157 } |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1158 |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1159 double q2; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1160 try { |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1161 q2 = iQ2.value(p); |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1162 } |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1163 catch (ArgumentOutsideDomainException aode) { |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1164 err.error(km2, "w.w.qkm2.failed", p); |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1165 continue; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1166 } |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1167 |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1168 double w2; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1169 try { |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1170 w2 = qW2.value(q2); |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1171 } |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1172 catch (ArgumentOutsideDomainException aode) { |
2403
177b0c91928d
'Bezugslinienverfahren': Improve the error messages even more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2330
diff
changeset
|
1173 err.error(km2, "w.w.wkm2.failed", q2, p); |
2330
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1174 continue; |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1175 } |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1176 |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1177 ws1.add(w1); |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1178 ws2.add(w2); |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1179 qs1.add(q1); |
594885703687
Picked changes r4015:4026 from trunk.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2316
diff
changeset
|
1180 qs2.add(q2); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1181 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1182 |
2316
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1183 return new double [][] { |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1184 ws1.toNativeArray(), |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2560
diff
changeset
|
1185 qs1.toNativeArray(), |
2316
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1186 ws2.toNativeArray(), |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1187 qs2.toNativeArray() }; |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1188 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1189 |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1190 public QPosition getQPosition(double km, double q) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1191 return getQPosition(km, q, new QPosition()); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1192 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1193 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1194 public QPosition getQPosition(double km, double q, QPosition qPosition) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1195 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1196 if (columns.length == 0) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1197 return null; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1198 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1199 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1200 double qLast = columns[0].getQRangeTree().findQ(km); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1201 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1202 if (Math.abs(qLast - q) < 0.00001) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1203 return qPosition.set(0, 1d); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1204 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1205 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1206 for (int i = 1; i < columns.length; ++i) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1207 double qCurrent = columns[i].getQRangeTree().findQ(km); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1208 if (Math.abs(qCurrent - q) < 0.00001) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1209 return qPosition.set(i, 1d); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1210 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1211 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1212 double qMin, qMax; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1213 if (qLast < qCurrent) { qMin = qLast; qMax = qCurrent; } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1214 else { qMin = qCurrent; qMax = qLast; } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1215 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1216 if (q > qMin && q < qMax) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
1217 double weight = Linear.factor(q, qLast, qCurrent); |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1218 return qPosition.set(i, weight); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1219 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1220 qLast = qCurrent; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1221 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1222 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1223 return null; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1224 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1225 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1226 public double getQIndex(int index, double km) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1227 return columns[index].getQRangeTree().findQ(km); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1228 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1229 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1230 public double getQ(QPosition qPosition, double km) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1231 int index = qPosition.index; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1232 double weight = qPosition.weight; |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1233 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1234 if (weight == 1d) { |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1235 return columns[index].getQRangeTree().findQ(km); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1236 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1237 double q1 = columns[index-1].getQRangeTree().findQ(km); |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1238 double q2 = columns[index ].getQRangeTree().findQ(km); |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
1239 return Linear.weight(weight, q1, q2); |
633
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1240 } |
3736
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1241 |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1242 public double [][] interpolateTabulated(double km) { |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1243 return interpolateTabulated(km, new double[2][columns.length]); |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1244 } |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1245 |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1246 public double [][] interpolateTabulated(double km, double [][] result) { |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1247 |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1248 int rowIndex = Collections.binarySearch(rows, new Row(km)); |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1249 |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1250 if (rowIndex >= 0) { |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1251 // Direct hit -> copy ws. |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1252 Row row = rows.get(rowIndex); |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1253 System.arraycopy( |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1254 row.ws, 0, result[0], 0, |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1255 Math.min(row.ws.length, result[0].length)); |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1256 } |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1257 else { |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1258 rowIndex = -rowIndex -1; |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1259 if (rowIndex < 1 || rowIndex >= rows.size()) { |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1260 // Out of bounds. |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1261 return null; |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1262 } |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1263 // Interpolate ws. |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1264 Row r1 = rows.get(rowIndex-1); |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1265 Row r2 = rows.get(rowIndex); |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1266 double factor = Linear.factor(km, r1.km, r2.km); |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1267 Linear.weight(factor, r1.ws, r2.ws, result[0]); |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1268 } |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1269 |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1270 double [] qs = result[1]; |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1271 for (int i = Math.min(qs.length, columns.length)-1; i >= 0; --i) { |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1272 qs[i] = columns[i].getQRangeTree().findQ(km); |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1273 } |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1274 return result; |
da1969b05292
WST tables: Added interpolation of tabulated values only.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3271
diff
changeset
|
1275 } |
3743
51f76225823b
Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3736
diff
changeset
|
1276 |
4119
760e2fe00138
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3969
diff
changeset
|
1277 |
6923
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1278 /** True if no QRange is given or Q equals zero. */ |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1279 public boolean hasEmptyQ() { |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1280 for (Column column: columns) { |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1281 if (column.getQRangeTree() == null) { |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1282 return true; |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1283 } |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1284 else { |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1285 if (Math.abs(column.getQRangeTree().maxQ()) <= 0.01d) { |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1286 return true; |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1287 } |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1288 } |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1289 } |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1290 |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1291 if (columns.length == 0) { |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1292 log.warn("No columns in WstValueTable."); |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1293 } |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1294 |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1295 return false; |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1296 } |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1297 |
254a3f3556ee
WstValueTable: Add method to find out wether the Qs are 'fake'
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6711
diff
changeset
|
1298 |
4119
760e2fe00138
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3969
diff
changeset
|
1299 /** Find ranges that are between km1 and km2 (inclusive?) */ |
3743
51f76225823b
Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3736
diff
changeset
|
1300 public List<Range> findSegments(double km1, double km2) { |
51f76225823b
Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3736
diff
changeset
|
1301 return columns.length != 0 |
51f76225823b
Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3736
diff
changeset
|
1302 ? columns[columns.length-1].getQRangeTree().findSegments(km1, km2) |
51f76225823b
Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3736
diff
changeset
|
1303 : Collections.<Range>emptyList(); |
51f76225823b
Extreme waterlevels: calculate the segments for Q km ranges.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3736
diff
changeset
|
1304 } |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1305 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1306 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |