Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java @ 2407:dce0cc856357
'Bezugslinien': Added axis labels matching the displayed data.
flys-artifacts/trunk@4036 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 10 Feb 2012 16:00:57 +0000 |
parents | 750cdcccb39c |
children | ac528b883b47 adb8641f5b5d |
rev | line source |
---|---|
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.io.Serializable; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
5 import de.intevation.flys.artifacts.math.Linear; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
6 import de.intevation.flys.artifacts.math.Function; |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
7 |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
8 import java.util.Arrays; |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import java.util.ArrayList; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import java.util.List; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.util.Collections; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
13 import org.apache.log4j.Logger; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
14 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
15 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
|
16 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
17 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
|
18 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
19 import org.apache.commons.math.ArgumentOutsideDomainException; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
20 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
21 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
|
22 |
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
|
23 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
|
24 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
25 /** |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
26 * 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
|
27 */ |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 public class WstValueTable |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 implements Serializable |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 { |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
31 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
|
32 |
395
aae8f327425e
'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
380
diff
changeset
|
33 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
|
34 |
2253
707b47d8c554
Dont sort the data series in reference curve.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2248
diff
changeset
|
35 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
|
36 |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
37 /** |
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
38 * A Column in the table, typically representing one measurement session. |
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
39 */ |
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
|
40 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
|
41 implements Serializable |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 protected String name; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 |
632
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
45 protected QRangeTree qRangeTree; |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
46 |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 public Column() { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 public Column(String name) { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 this.name = name; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 public String getName() { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 return name; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 public void setName(String name) { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 this.name = name; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 } |
632
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
61 |
1907
6c7fdfd262ac
Do not re-evaluate constant size() in for-loops.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1899
diff
changeset
|
62 public QRangeTree getQRangeTree() { |
632
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
63 return qRangeTree; |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
64 } |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
65 |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
66 public void setQRangeTree(QRangeTree qRangeTree) { |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
67 this.qRangeTree = qRangeTree; |
07640ab913fd
First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
621
diff
changeset
|
68 } |
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
|
69 } // class Column |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
71 /** |
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
72 * A (weighted) position used for interpolation. |
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
73 */ |
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
|
74 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
|
75 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
76 protected int index; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
77 protected double weight; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
78 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
79 public QPosition() { |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
80 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
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 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
|
83 this.index = index; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
84 this.weight = weight; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
85 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
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 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
|
88 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
|
89 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
|
90 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
|
91 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
92 |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
93 } // class Position |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
94 |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
95 public static final class SplineFunction { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
96 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
97 public PolynomialSplineFunction spline; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
98 public double [] splineQs; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
99 public double [] splineWs; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
100 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
101 public SplineFunction( |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
102 PolynomialSplineFunction spline, |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
103 double [] splineQs, |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
104 double [] splineWs |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
105 ) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
106 this.spline = spline; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
107 this.splineQs = splineQs; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
108 this.splineWs = splineWs; |
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 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
111 public double [][] sample( |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
112 int numSamples, |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
113 double km, |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
114 Calculation errors |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
115 ) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
116 double minQ = getQMin(); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
117 double maxQ = getQMax(); |
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 double [] outWs = new double[numSamples]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
120 double [] outQs = new double[numSamples]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
121 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
122 Arrays.fill(outWs, Double.NaN); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
123 Arrays.fill(outQs, Double.NaN); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
124 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
125 double stepWidth = (maxQ - minQ)/numSamples; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
126 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
127 try { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
128 double q = minQ; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
129 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
|
130 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
|
131 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
132 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
133 catch (ArgumentOutsideDomainException aode) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
134 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
135 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
|
136 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
137 log.error("spline interpolation failed.", aode); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
138 } |
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 return new double [][] { outWs, outQs }; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
141 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
142 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
143 public double getQMin() { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
144 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
|
145 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
146 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
147 public double getQMax() { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
148 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
|
149 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
150 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
151 /** 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
|
152 public PolynomialSplineFunction createIndexQRelation() { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
153 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
154 double [] indices = new double[splineQs.length]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
155 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
|
156 indices[i] = i; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
157 } |
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 try { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
160 SplineInterpolator interpolator = new SplineInterpolator(); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
161 return interpolator.interpolate(indices, splineQs); |
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 catch (MathIllegalArgumentException miae) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
164 // Ignore me! |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
165 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
166 return null; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
167 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
168 } // class SplineFunction |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
169 |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
170 /** |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
171 * A row, typically a position where measurements were taken. |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
172 */ |
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
|
173 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
|
174 implements Serializable, Comparable<Row> |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 double km; |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
177 double [] ws; |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
178 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
179 public Row() { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
180 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
181 |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
182 public Row(double km) { |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
183 this.km = km; |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
184 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
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 Row(double km, double [] ws) { |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
187 this(km); |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
188 this.ws = ws; |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
189 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
190 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
191 /** |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
192 * Compare according to place of measurement (km). |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
193 */ |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
194 public int compareTo(Row other) { |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
195 double d = km - other.km; |
458
523a256451cd
Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
196 if (d < -0.0001) return -1; |
523a256451cd
Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
197 if (d > 0.0001) return +1; |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
198 return 0; |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
199 } |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
200 |
1887
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
201 /** |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
202 * Interpolate Ws, given Qs and a km. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
203 * |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
204 * @param iqs Given ("input") Qs. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
205 * @param ows Resulting ("output") Ws. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
206 * @param table Table of which to use data for interpolation. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
207 */ |
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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 double [] ows, |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
213 WstValueTable table, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
214 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
|
215 ) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
216 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
|
217 |
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
|
218 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
|
219 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 if (errors != null) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
226 errors.addProblem( |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
227 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
|
228 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
229 ows[i] = Double.NaN; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
230 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
231 else { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
232 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
|
233 } |
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
|
234 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
235 else { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
236 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
237 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
|
238 } |
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
|
239 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
|
240 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
241 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
242 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
243 |
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
|
244 |
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
|
245 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
|
246 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
|
247 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
|
248 ) { |
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
|
249 int W = ws.length; |
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
|
250 |
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
|
251 if (W < 1) { |
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
|
252 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
253 errors.addProblem(km, "no.ws.found"); |
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
|
254 } |
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
|
255 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
|
256 } |
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
|
257 |
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
|
258 double [] splineQs = new double[W]; |
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
|
259 |
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
|
260 for (int i = 0; i < W; ++i) { |
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
|
261 double sq = table.getQIndex(i, 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
|
262 if (Double.isNaN(sq) && errors != 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
|
263 errors.addProblem( |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
264 km, "no.q.found.in.column", (i+1)); |
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
|
265 } |
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
|
266 splineQs[i] = sq; |
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
|
267 } |
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
|
268 |
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
|
269 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
|
270 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
|
271 PolynomialSplineFunction spline = |
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
|
272 interpolator.interpolate(splineQs, ws); |
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
|
273 |
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
|
274 return new SplineFunction(spline, splineQs, ws); |
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
|
275 } |
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
|
276 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
|
277 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
278 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
|
279 } |
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
|
280 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
|
281 } |
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
|
282 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
|
283 } |
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
|
284 |
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
|
285 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
|
286 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
|
287 double km, |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
288 WstValueTable table, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
289 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
|
290 ) { |
395
aae8f327425e
'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
380
diff
changeset
|
291 int W = Math.min(ws.length, other.ws.length); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
292 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
293 if (W < 1) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
294 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
295 errors.addProblem("no.ws.found"); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
296 } |
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
|
297 return null; |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
298 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
299 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
300 double factor = 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
|
301 |
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
|
302 double [] splineQs = new double[W]; |
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
|
303 double [] splineWs = new double[W]; |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
304 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
305 for (int i = 0; i < W; ++i) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
306 double wws = Linear.weight(factor, ws[i], other.ws[i]); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
307 double wqs = Linear.weight( |
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
|
308 factor, |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
309 table.getQIndex(i, 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
|
310 table.getQIndex(i, other.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
|
311 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
312 if (Double.isNaN(wws) || Double.isNaN(wqs)) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
313 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
314 errors.addProblem(km, "cannot.find.w.or.q"); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
315 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
316 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
317 |
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
|
318 splineWs[i] = wws; |
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
|
319 splineQs[i] = wqs; |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
320 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
321 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
322 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
|
323 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
324 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
|
325 PolynomialSplineFunction spline = |
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
|
326 interpolator.interpolate(splineQs, splineWs); |
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
|
327 |
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
|
328 return new SplineFunction(spline, splineQs, splineWs); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
329 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
330 catch (MathIllegalArgumentException miae) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
331 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
332 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
|
333 } |
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
|
334 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
|
335 } |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
336 |
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
|
337 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
|
338 } |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
339 |
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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 ) { |
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
|
347 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
|
348 |
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
|
349 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
|
350 ? 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
|
351 : new double[2][0]; |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
352 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
353 |
1721
eb35570df0e8
Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1681
diff
changeset
|
354 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
355 public double [][] interpolateWQ( |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
356 int steps, |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
357 WstValueTable table, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
358 Calculation errors |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
359 ) { |
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
|
360 SplineFunction sf = createSpline(table, errors); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
361 |
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
|
362 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
|
363 ? 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
|
364 : new double[2][0]; |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
365 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
366 |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
367 |
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
|
368 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
|
369 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
|
370 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
|
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 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
|
373 ? ws[index] |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
374 : 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
|
375 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
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 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
|
378 Row other, |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
379 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
|
380 QPosition qPosition |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
381 ) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
382 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
|
383 |
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
|
384 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
|
385 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
|
386 |
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
|
387 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
|
388 |
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
|
389 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
|
390 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
|
391 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
|
392 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
393 else { |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
394 tw = Linear.weight(weight, ws[index-1], ws[index]); |
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
395 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
|
396 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
397 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
398 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
|
399 } |
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
|
400 |
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
|
401 public double [] findQsForW(double w, WstValueTable table) { |
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
|
402 |
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
|
403 TDoubleArrayList qs = new 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
|
404 |
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
|
405 if (ws.length > 0 && Math.abs(ws[0]-w) < 0.000001) { |
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
|
406 double q = table.getQIndex(0, 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
|
407 if (!Double.isNaN(q)) { |
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
|
408 qs.add(q); |
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
|
409 } |
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
|
410 } |
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
|
411 |
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
|
412 for (int i = 1; i < ws.length; ++i) { |
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
|
413 double w2 = ws[i]; |
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
|
414 if (Double.isNaN(w2)) { |
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
|
415 continue; |
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
|
416 } |
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
|
417 if (Math.abs(w2-w) < 0.000001) { |
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
|
418 double q = table.getQIndex(i, 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
|
419 if (!Double.isNaN(q)) { |
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
|
420 qs.add(q); |
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
|
421 } |
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
|
422 continue; |
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
|
423 } |
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
|
424 double w1 = ws[i-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
|
425 if (Double.isNaN(w1)) { |
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
|
426 continue; |
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
|
427 } |
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
|
428 |
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
|
429 if (w < Math.min(w1, w2) || w > Math.max(w1, w2)) { |
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
|
430 continue; |
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
|
431 } |
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
|
432 |
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
|
433 double q1 = table.getQIndex(i-1, 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
|
434 double q2 = table.getQIndex(i, 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
|
435 if (Double.isNaN(q1) || Double.isNaN(q2)) { |
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
|
436 continue; |
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
|
437 } |
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
|
438 |
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
|
439 double q = Linear.linear(w, w1, w2, q1, q2); |
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
|
440 qs.add(q); |
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
|
441 } |
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
|
442 |
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
|
443 return qs.toNativeArray(); |
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
|
444 } |
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
|
445 |
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
|
446 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
|
447 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
|
448 double w, |
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
|
449 double 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
|
450 WstValueTable table |
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
|
451 ) { |
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
|
452 TDoubleArrayList qs = new 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
|
453 |
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
|
454 double factor = Linear.factor(km, this.km, other.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
|
455 |
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
|
456 if (ws.length > 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
|
457 double wt = Linear.weight(factor, ws[0], other.ws[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
|
458 if (!Double.isNaN(wt)) { |
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
|
459 double q = table.getQIndex(0, 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
|
460 if (!Double.isNaN(q)) { |
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
|
461 qs.add(q); |
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
|
462 } |
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
|
463 } |
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
|
464 } |
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
|
465 |
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
|
466 for (int i = 1; i < ws.length; ++i) { |
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
|
467 double w2 = Linear.weight(factor, ws[i], other.ws[i]); |
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
|
468 if (Double.isNaN(w2)) { |
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
|
469 continue; |
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
|
470 } |
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
|
471 if (Math.abs(w2-w) < 0.000001) { |
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
|
472 double q = table.getQIndex(i, 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
|
473 if (!Double.isNaN(q)) { |
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
|
474 qs.add(q); |
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
|
475 } |
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
|
476 continue; |
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
|
477 } |
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
|
478 double w1 = Linear.weight(factor, ws[i-1], other.ws[i-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
|
479 if (Double.isNaN(w1)) { |
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
|
480 continue; |
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
|
481 } |
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
|
482 |
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
|
483 if (w < Math.min(w1, w2) || w > Math.max(w1, w2)) { |
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
|
484 continue; |
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
|
485 } |
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
|
486 |
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
|
487 double q1 = table.getQIndex(i-1, 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
|
488 double q2 = table.getQIndex(i, 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
|
489 if (Double.isNaN(q1) || Double.isNaN(q2)) { |
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
|
490 continue; |
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 } |
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
|
492 |
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
|
493 double q = Linear.linear(w, w1, w2, q1, q2); |
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
|
494 qs.add(q); |
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
|
495 } |
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
|
496 |
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
|
497 return qs.toNativeArray(); |
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
|
498 } |
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
|
499 } // class Row |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
500 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
501 /** Rows in table. */ |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
502 protected List<Row> rows; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
503 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
504 /** Columns in table. */ |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
505 protected Column [] columns; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
506 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
507 public WstValueTable() { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
508 rows = new ArrayList<Row>(); |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
509 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
510 |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
511 public WstValueTable(Column [] columns) { |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
512 this(); |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
513 this.columns = columns; |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
514 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
515 |
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
|
516 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
|
517 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
|
518 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
|
519 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
520 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
521 /** Sort rows (by km). */ |
458
523a256451cd
Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
522 public void sortRows() { |
523a256451cd
Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
523 Collections.sort(rows); |
523a256451cd
Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
524 } |
523a256451cd
Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
443
diff
changeset
|
525 |
1887
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
526 /** |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
527 * @param km Given kilometer. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
528 * @param qs Given Q values. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
529 * @param ws output parameter. |
d2e217f438bc
Minor doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1860
diff
changeset
|
530 */ |
380
5f55047a17e8
Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
374
diff
changeset
|
531 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
|
532 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
|
533 } |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
534 |
1098
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
535 |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
536 /** |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
537 * @param ws (output parameter), gets returned. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
538 * @return output parameter ws. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
539 */ |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
540 public double [] interpolateW( |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
541 double km, |
742
c09c9e05ecfa
Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
542 double [] qs, |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
543 double [] ws, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
544 Calculation errors |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
545 ) { |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
546 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
|
547 |
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
|
548 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
|
549 |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
550 if (rowIndex >= 0) { // direct row match |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
551 Row row = rows.get(rowIndex); |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
552 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
|
553 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
|
554 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
555 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
|
556 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
557 ws[i] = Double.NaN; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
558 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
559 else { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
560 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
|
561 && errors != null) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
562 errors.addProblem( |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
563 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
|
564 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
565 } |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
566 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
567 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
568 else { // needs bilinear interpolation |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
569 rowIndex = -rowIndex -1; |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
570 |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
571 if (rowIndex < 1 || rowIndex >= rows.size()) { |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
572 // do not extrapolate |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
573 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
|
574 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
575 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
|
576 } |
335
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
577 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
578 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
|
579 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
|
580 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
|
581 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
|
582 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
583 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
584 |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
585 return ws; |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
586 } |
64cfbd631f29
Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
327
diff
changeset
|
587 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
588 /** |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
589 * Interpolate W and Q values at a given km. |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
590 */ |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
591 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
|
592 return interpolateWQ(km, null); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
593 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
594 |
1838
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
595 /** |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
596 * Interpolate W and Q values at a given km. |
853cd2120d69
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1721
diff
changeset
|
597 */ |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
598 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
|
599 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
|
600 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
601 |
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
|
602 /** |
ddd425858169
Improved logging to include exception in fail case of spline interpolation of wst.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1838
diff
changeset
|
603 * 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
|
604 */ |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
605 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
|
606 |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
607 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
|
608 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
609 if (rowIndex >= 0) { // direct row match |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
610 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
|
611 return row.interpolateWQ(steps, this, errors); |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
612 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
613 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
614 rowIndex = -rowIndex -1; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
615 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
616 if (rowIndex < 1 || rowIndex >= rows.size()) { |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
617 // do not extrapolate |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
618 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
619 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
|
620 } |
339
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
621 return new double[2][0]; |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
622 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
623 |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
624 Row r1 = rows.get(rowIndex-1); |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
625 Row r2 = rows.get(rowIndex); |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
626 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
627 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
|
628 } |
4509ba8fae68
Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
335
diff
changeset
|
629 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
630 public boolean interpolate( |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
631 double km, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
632 double [] out, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
633 QPosition qPosition, |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
634 Function qFunction |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
635 ) { |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
636 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
|
637 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
638 out[1] = qFunction.value(getQ(qPosition, km)); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
639 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
640 if (Double.isNaN(out[1])) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
641 return false; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
642 } |
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
|
643 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
644 QPosition nPosition = new QPosition(); |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
645 if (getQPosition(km, out[1], nPosition) == null) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
646 return false; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
647 } |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
648 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
649 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
|
650 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
651 if (rowIndex >= 0) { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
652 // direct row match |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
653 out[0] = rows.get(rowIndex).getW(nPosition); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
654 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
|
655 } |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
656 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
657 rowIndex = -rowIndex -1; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
658 |
1681
e5f7f25a511c
fixed flys/issue201
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1098
diff
changeset
|
659 if (rowIndex < 1 || rowIndex > R1) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
660 // do not extrapolate |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
661 return false; |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
662 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
663 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
664 Row r1 = rows.get(rowIndex-1); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
665 Row r2 = rows.get(rowIndex); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
666 out[0] = r1.getW(r2, km, nPosition); |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
667 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
668 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
|
669 } |
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
670 |
1098
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
671 |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
672 /** |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
673 * Look up interpolation of a Q at given positions. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
674 * |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
675 * @param q the non-interpolated Q value. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
676 * @param referenceKm the reference km (e.g. gauge position). |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
677 * @param kms positions for which to interpolate. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
678 * @param ws (output) resulting interpolated ws. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
679 * @param qs (output) resulting interpolated qs. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
680 * @param errors calculation object to store errors. |
1ea7eb72aaa6
Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
742
diff
changeset
|
681 */ |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
682 public QPosition interpolate( |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
683 double q, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
684 double referenceKm, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
685 double [] kms, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
686 double [] ws, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
687 double [] qs, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
688 Calculation errors |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
689 ) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
690 return interpolate( |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
691 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
|
692 } |
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
693 |
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
694 public QPosition interpolate( |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
695 double q, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
696 double referenceKm, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
697 double [] kms, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
698 double [] ws, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
699 double [] qs, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
700 int startIndex, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
701 int length, |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
702 Calculation errors |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
703 ) { |
645
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
704 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
|
705 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
706 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
|
707 // 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
|
708 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
|
709 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
|
710 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
711 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
|
712 } |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
713 return null; |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
714 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
715 |
645
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
716 Row kmKey = new Row(); |
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
717 |
433f67a076aa
Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
633
diff
changeset
|
718 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
|
719 |
649
44175d4720f8
Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
645
diff
changeset
|
720 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
|
721 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
722 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
|
723 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
724 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
|
725 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
726 ws[i] = Double.NaN; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
727 continue; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
728 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
729 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
730 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
|
731 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
|
732 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
733 if (rowIndex >= 0) { |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
734 // direct row match |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
735 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
|
736 && errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
737 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
|
738 } |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
739 continue; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
740 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
741 |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
742 rowIndex = -rowIndex -1; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
743 |
1681
e5f7f25a511c
fixed flys/issue201
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1098
diff
changeset
|
744 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
|
745 // do not extrapolate |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
746 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
747 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
|
748 } |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
749 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
|
750 continue; |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
751 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
752 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
|
753 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
|
754 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
755 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
|
756 && errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
757 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
|
758 } |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
759 } |
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
760 |
427
909196be11a0
First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
426
diff
changeset
|
761 return qPosition; |
426
c6b7ca0febcb
Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
395
diff
changeset
|
762 } |
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
|
763 |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
764 /** |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
765 * 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
|
766 * |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
767 * @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
|
768 * @param row1 first row. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
769 * @param row2 second row. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
770 * @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
|
771 * |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
772 * @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
|
773 */ |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
774 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
|
775 if (row1 == null || row2 == null) { |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
776 return Double.NaN; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
777 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
778 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
779 return Linear.linear(km, |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
780 row1.km, row2.km, |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
781 row1.ws[col], row2.ws[col]); |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
782 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
783 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
784 /** |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
785 * 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
|
786 * of other columns). |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
787 * @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
|
788 * @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
|
789 */ |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
790 public double [][] interpolateWQColumnwise(double km) { |
1919
9bec7d2f8c35
Prevent ArrayIndexOutOfBounds, log method entry.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1907
diff
changeset
|
791 log.debug("WstValueTable.interpolateWQColumnwise"); |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
792 double [] qs = new double[columns.length]; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
793 double [] ws = new double[columns.length]; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
794 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
795 // 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
|
796 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
|
797 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
798 if (rowIndex < 0) { |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
799 rowIndex = -rowIndex -1; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
800 } |
2248 | 801 |
802 // 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
|
803 if (rowIndex >= rows.size()) { |
1919
9bec7d2f8c35
Prevent ArrayIndexOutOfBounds, log method entry.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1907
diff
changeset
|
804 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
|
805 } |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
806 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
807 Row startRow = rows.get(rowIndex); |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
808 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
809 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
|
810 qs[col] = columns[col].getQRangeTree().findQ(km); |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
811 if (startRow.km == km && startRow.ws[col] != Double.NaN) { |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
812 // Great. W is defined at km. |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
813 ws[col] = startRow.ws[col]; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
814 continue; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
815 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
816 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
817 // 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
|
818 Row rowBefore = null; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
819 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
|
820 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
|
821 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
|
822 rowBefore = rows.get(before); |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
823 break; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
824 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
825 } |
2248 | 826 if (rowBefore != null) { |
827 for (int after = rowIndex, R = rows.size(); after < R; after++) { | |
828 if (!Double.isNaN(rows.get(after).ws[col])) { | |
829 rowAfter = rows.get(after); | |
830 break; | |
831 } | |
1888
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
832 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
833 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
834 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
835 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
|
836 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
837 |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
838 return new double [][] {qs, ws}; |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
839 } |
abf5da3b285c
Added new (at fixed columns) interpolation mechanism.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1887
diff
changeset
|
840 |
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
|
841 public double [] findQsForW(double km, double w) { |
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
|
842 |
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
|
843 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
|
844 |
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
|
845 if (rowIndex >= 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
|
846 return rows.get(rowIndex).findQsForW(w, this); |
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
|
847 } |
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
|
848 |
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
|
849 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
|
850 |
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
|
851 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
|
852 // 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
|
853 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
|
854 } |
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
|
855 |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
856 // 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
|
857 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
|
858 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
|
859 |
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
|
860 return r1.findQsForW(r2, w, km, this); |
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
|
861 } |
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
|
862 |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
863 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
|
864 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
865 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
|
866 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
867 if (rowIndex >= 0) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
868 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
|
869 if (sf == null && errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
870 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
|
871 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
872 return sf; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
873 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
874 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
875 rowIndex = -rowIndex - 1; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
876 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
877 if (rowIndex < 1 || rowIndex >= rows.size()) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
878 // Do not extrapolate. |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
879 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
880 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
|
881 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
882 return null; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
883 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
884 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
885 // Needs bilinear interpolation. |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
886 Row r1 = rows.get(rowIndex-1); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
887 Row r2 = rows.get(rowIndex); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
888 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
889 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
|
890 if (sf == null && errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
891 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
|
892 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
893 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
894 return sf; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
895 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
896 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
897 /** 'Bezugslinienverfahren' */ |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
898 public double [][] relateWs( |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
899 double km1, |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
900 double km2, |
2186
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
901 Calculation errors |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
902 ) { |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
903 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
|
904 } |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
905 |
2396
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
906 private static class ErrorHandler { |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
907 |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
908 boolean hasErrors; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
909 Calculation errors; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
910 |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
911 ErrorHandler(Calculation errors) { |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
912 this.errors = errors; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
913 } |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
914 |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
915 void error(double km, String key, Object ... args) { |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
916 if (errors != null && !hasErrors) { |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
917 hasErrors = true; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
918 errors.addProblem(km, key, args); |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
919 } |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
920 } |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
921 } // class ErrorHandler |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
922 |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
923 |
2186
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
924 /* TODO: Add optimized methods of relateWs to relate one |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
925 * start km to many end kms. The index generation/spline stuff for |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
926 * 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
|
927 */ |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
928 public double [][] relateWs( |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
929 double km1, |
ec2574eb2d32
Added calculation class for "Bezugslinienverfahren" to created by WINFOArtifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2166
diff
changeset
|
930 double km2, |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
931 int numSamples, |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
932 Calculation errors |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
933 ) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
934 SplineFunction sf1 = createSpline(km1, errors); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
935 if (sf1 == null) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
936 return new double[2][0]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
937 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
938 |
2248 | 939 SplineFunction sf2 = createSpline(km2, errors); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
940 if (sf2 == null) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
941 return new double[2][0]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
942 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
943 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
944 PolynomialSplineFunction iQ1 = sf1.createIndexQRelation(); |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
945 if (iQ1 == null) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
946 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
947 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
|
948 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
949 return new double[2][0]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
950 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
951 |
2404
750cdcccb39c
'Bezugslinienverfahren': Fix the index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2403
diff
changeset
|
952 PolynomialSplineFunction iQ2 = sf2.createIndexQRelation(); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
953 if (iQ2 == null) { |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
954 if (errors != null) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1939
diff
changeset
|
955 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
|
956 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
957 return new double[2][0]; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
958 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
959 |
2316
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
960 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
|
961 double stepWidth = N/(double)numSamples; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
962 |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
963 PolynomialSplineFunction qW1 = sf1.spline; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
964 PolynomialSplineFunction qW2 = sf2.spline; |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
965 |
2316
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
966 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
|
967 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
|
968 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
|
969 TDoubleArrayList qs2 = new TDoubleArrayList(numSamples); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
970 |
2396
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
971 ErrorHandler err = new ErrorHandler(errors); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
972 |
2316
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
973 int i = 0; |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
974 for (double p = 0d; p <= N-1; p += stepWidth, ++i) { |
2396
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
975 |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
976 double q1; |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
977 try { |
2396
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
978 q1 = iQ1.value(p); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
979 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
980 catch (ArgumentOutsideDomainException aode) { |
2396
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
981 err.error(km1, "w.w.qkm1.failed", p); |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
982 continue; |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
983 } |
2396
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
984 |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
985 double w1; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
986 try { |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
987 w1 = qW1.value(q1); |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
988 } |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
989 catch (ArgumentOutsideDomainException aode) { |
2403
177b0c91928d
'Bezugslinienverfahren': Improve the error messages even more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2396
diff
changeset
|
990 err.error(km1, "w.w.wkm1.failed", q1, p); |
2396
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
991 continue; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
992 } |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
993 |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
994 double q2; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
995 try { |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
996 q2 = iQ2.value(p); |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
997 } |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
998 catch (ArgumentOutsideDomainException aode) { |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
999 err.error(km2, "w.w.qkm2.failed", p); |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1000 continue; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1001 } |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1002 |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1003 double w2; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1004 try { |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1005 w2 = qW2.value(q2); |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1006 } |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1007 catch (ArgumentOutsideDomainException aode) { |
2403
177b0c91928d
'Bezugslinienverfahren': Improve the error messages even more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2396
diff
changeset
|
1008 err.error(km2, "w.w.wkm2.failed", q2, p); |
2396
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1009 continue; |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1010 } |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1011 |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1012 ws1.add(w1); |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1013 ws2.add(w2); |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1014 qs1.add(q1); |
2c62bbe2e415
Give more precise message when an error occurs in W~W relation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2316
diff
changeset
|
1015 qs2.add(q2); |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1016 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1017 |
2316
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1018 return new double [][] { |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1019 ws1.toNativeArray(), |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1020 qs1.toNativeArray(), |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1021 ws2.toNativeArray(), |
61b32380ffdb
Be more conservative about arrays and indices in "Bezugslinienverfahren".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2282
diff
changeset
|
1022 qs2.toNativeArray() }; |
1939
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1023 } |
2730d17df021
Added the implementation of the 'Bezugslinienverfahren'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1938
diff
changeset
|
1024 |
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
|
1025 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
|
1026 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
|
1027 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1028 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1029 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
|
1030 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1031 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
|
1032 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
|
1033 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1034 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1035 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
|
1036 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1037 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
|
1038 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
|
1039 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1040 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1041 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
|
1042 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
|
1043 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
|
1044 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
|
1045 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1046 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1047 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
|
1048 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
|
1049 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
|
1050 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1051 if (q > qMin && q < qMax) { |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
649
diff
changeset
|
1052 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
|
1053 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
|
1054 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1055 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
|
1056 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1057 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1058 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
|
1059 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1060 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1061 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
|
1062 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
|
1063 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1064 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1065 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
|
1066 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
|
1067 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
|
1068 |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1069 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
|
1070 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
|
1071 } |
d08f77e7f7e8
WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
632
diff
changeset
|
1072 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
|
1073 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
|
1074 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
|
1075 } |
326
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1076 } |
07eba6d3b4a5
Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1077 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |