annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java @ 1767:b2730e31ff5b

Store Facets without association to state id. flys-artifacts/trunk@3088 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Wed, 26 Oct 2011 12:45:34 +0000
parents eb35570df0e8
children 853cd2120d69
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
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 public class WstValueTable
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 implements Serializable
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 {
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
26 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
27
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
28 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
29
1721
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
30 /**
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
31 * A Column in the table, typically representing one measurement session.
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
32 */
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
33 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
34 implements Serializable
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 {
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 protected String name;
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37
632
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
38 protected QRangeTree qRangeTree;
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
39
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 public Column() {
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 }
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 public Column(String name) {
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 this.name = name;
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 }
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 public String getName() {
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 return name;
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
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 public void setName(String name) {
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 this.name = name;
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 }
632
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
54
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
55 public QRangeTree getQRangeTree() {
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
56 return qRangeTree;
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
57 }
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
58
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
59 public void setQRangeTree(QRangeTree qRangeTree) {
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
60 this.qRangeTree = qRangeTree;
07640ab913fd First part of storing qs in ranges
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 621
diff changeset
61 }
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
62 } // class Column
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63
1721
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
64 /**
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
65 * A (weighted) position used for interpolation.
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
66 */
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
67 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
68
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
69 protected int index;
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
70 protected double weight;
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
71
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
72 public QPosition() {
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
73 }
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
74
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
75 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
76 this.index = index;
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
77 this.weight = 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
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
80 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
81 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
82 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
83 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
84 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
85
426
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
86 } // class Position
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
87
1721
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
88 /**
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
89 * A row, typically a position where measurements whrere taken.
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
90 */
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
91 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
92 implements Serializable, Comparable<Row>
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93 {
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 double km;
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
95 double [] ws;
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97 public Row() {
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 }
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
100 public Row(double km) {
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 this.km = km;
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
102 }
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
103
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
104 public Row(double km, double [] ws) {
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
105 this(km);
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
106 this.ws = ws;
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
107 }
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
108
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
109 public int compareTo(Row other) {
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
110 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
111 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
112 if (d > 0.0001) return +1;
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
113 return 0;
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114 }
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
115
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
116 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
117 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
118 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
119 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
120 double [] ows,
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
121 WstValueTable table,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
122 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
123 ) {
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
124 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
125
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
126 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
127
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
128 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
129 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
130 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
131 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
132 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
133 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
134 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
135 errors.addProblem(
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
136 km, "cannot find w for q = " + iqs[i]);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
137 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
138 ows[i] = Double.NaN;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
139 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
140 else {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
141 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
142 }
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
143 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
144 else {
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
145 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
146 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
147 errors.addProblem(km, "cannot find q = " + iqs[i]);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
148 }
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
149 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
150 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
151 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
152 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
153
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
154 public double [][] interpolateWQ(
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
155 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
156 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
157 int steps,
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
158 WstValueTable table,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
159 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
160 ) {
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
161 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
162
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
163 if (W < 1) {
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
164 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
165 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
166 errors.addProblem("no ws found");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
167 }
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
168 return new double[2][0];
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
169 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
170
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
171 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
172
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
173 double [] splineQ = new double[W];
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
174 double [] splineW = new double[W];
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
175
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
176 double minQ = Double.MAX_VALUE;
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
177 double maxQ = -Double.MAX_VALUE;
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
178
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
179 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
180 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
181 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
182 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
183 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
184 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
185
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
186 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
187 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
188 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
189 errors.addProblem(km, "cannot find w or q");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
190 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
191 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
192 else {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
193 if (wqs < minQ) minQ = wqs;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
194 if (wqs > maxQ) maxQ = wqs;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
195 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
196
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
197 splineW[i] = wws;
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
198 splineQ[i] = wqs;
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
199 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
200
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
201 double stepWidth = (maxQ - minQ)/steps;
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
202
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
203 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
204 PolynomialSplineFunction spline;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
205
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
206 try {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
207 spline = interpolator.interpolate(splineQ, splineW);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
208 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
209 catch (MathIllegalArgumentException miae) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
210 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
211 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
212 errors.addProblem(km, "spline creation failed");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
213 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
214 log.error("spline creation failed");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
215 return new double[2][0];
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
216 }
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
217
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
218 double [] outWs = new double[steps];
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
219 double [] outQs = new double[steps];
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
220
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
221 Arrays.fill(outWs, Double.NaN);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
222 Arrays.fill(outQs, Double.NaN);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
223
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
224 try {
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
225 double q = minQ;
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
226 for (int i = 0; i < outWs.length; ++i, q += stepWidth) {
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
227 outWs[i] = spline.value(outQs[i] = q);
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
228 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
229 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
230 catch (ArgumentOutsideDomainException aode) {
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
231 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
232 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
233 errors.addProblem(km, "spline interpolation failed");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
234 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
235 log.error("spline interpolation failed", aode);
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
236 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
237
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
238 return new double [][] { outWs, outQs };
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
239 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
240
1721
eb35570df0e8 Cosmetics, docs.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 1681
diff changeset
241
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
242 public double [][] interpolateWQ(
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
243 int steps,
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
244 WstValueTable table,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
245 Calculation errors
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
246 ) {
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
247 int W = ws.length;
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
248
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
249 if (W < 1) {
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
250 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
251 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
252 errors.addProblem(km, "no ws found");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
253 }
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
254 return new double[2][0];
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
255 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
256
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
257 double [] splineQ = new double[W];
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
258
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
259 double minQ = Double.MAX_VALUE;
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
260 double maxQ = -Double.MAX_VALUE;
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
261
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
262 for (int i = 0; i < W; ++i) {
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
263 double sq = table.getQIndex(i, km);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
264 if (Double.isNaN(sq)) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
265 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
266 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
267 errors.addProblem(
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
268 km, "no q found in " + (i+1) + " column");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
269 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
270 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
271 else {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
272 if (sq < minQ) minQ = sq;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
273 if (sq > maxQ) maxQ = sq;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
274 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
275 splineQ[i] = sq;
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
276 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
277
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
278 double stepWidth = (maxQ - minQ)/steps;
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
279
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
280 SplineInterpolator interpolator = new SplineInterpolator();
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
281
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
282 PolynomialSplineFunction spline;
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
283
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
284 try {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
285 spline = interpolator.interpolate(splineQ, ws);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
286 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
287 catch (MathIllegalArgumentException miae) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
288 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
289 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
290 errors.addProblem(km, "spline creation failed");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
291 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
292 log.error("spline creation failed");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
293 return new double[2][0];
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
294 }
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
295
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
296 double [] outWs = new double[steps];
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
297 double [] outQs = new double[steps];
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
298
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
299 Arrays.fill(outWs, Double.NaN);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
300 Arrays.fill(outQs, Double.NaN);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
301
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
302 try {
395
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
303 double q = minQ;
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
304 for (int i = 0; i < outWs.length; ++i, q += stepWidth) {
aae8f327425e 'berechnete Abflusskurve': generate ws from qs
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 380
diff changeset
305 outWs[i] = spline.value(outQs[i] = q);
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
306 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
307 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
308 catch (ArgumentOutsideDomainException aode) {
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
309 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
310 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
311 errors.addProblem(km, "spline interpolation failed");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
312 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
313 log.error("spline interpolation failed.", aode);
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
314 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
315
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
316 return new double [][] { outWs, outQs };
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
317 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
318
426
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
319
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
320 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
321 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
322 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
323
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
324 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
325 ? ws[index]
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
326 : 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
327 }
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
328
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
329 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
330 Row other,
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
331 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
332 QPosition qPosition
426
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
333 ) {
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
334 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
335
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
336 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
337 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
338
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
339 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
340
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
341 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
342 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
343 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
344 }
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
345 else {
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
346 tw = Linear.weight(weight, ws[index-1], ws[index]);
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
347 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
348 }
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
349
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
350 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
351 }
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
352 } // class Row
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
353
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
354 protected List<Row> rows;
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
355
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
356 protected Column [] columns;
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
357
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
358 public WstValueTable() {
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
359 rows = new ArrayList<Row>();
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
360 }
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
361
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
362 public WstValueTable(Column [] columns) {
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
363 this();
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
364 this.columns = columns;
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
365 }
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
366
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
367 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
368 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
369 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
370 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
371
458
523a256451cd Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 443
diff changeset
372 public void sortRows() {
523a256451cd Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 443
diff changeset
373 Collections.sort(rows);
523a256451cd Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 443
diff changeset
374 }
523a256451cd Use unsharp km lookup (epsilon = 0.0001).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 443
diff changeset
375
380
5f55047a17e8 Moved expensive allocation of result arrays out of km loop.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 374
diff changeset
376 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
377 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
378 }
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
379
1098
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
380
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
381 /**
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
382 * @param ws (output parameter), gets returned.
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
383 * @return output parameter ws.
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
384 */
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
385 public double [] interpolateW(
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
386 double km,
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 704
diff changeset
387 double [] qs,
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
388 double [] ws,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
389 Calculation errors
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
390 ) {
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
391 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
392
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
393 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
394
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
395 if (rowIndex >= 0) { // direct row match
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
396 Row row = rows.get(rowIndex);
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
397 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
398 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
399 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
400 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
401 errors.addProblem(km, "cannot find q = " + qs[i]);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
402 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
403 ws[i] = Double.NaN;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
404 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
405 else {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
406 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
407 && errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
408 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
409 errors.addProblem(
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
410 km, "cannot find w for q = " + qs[i]);
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
411 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
412 }
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
413 }
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
414 }
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
415 else { // needs bilinear interpolation
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
416 rowIndex = -rowIndex -1;
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
417
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
418 if (rowIndex < 1 || rowIndex >= rows.size()) {
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
419 // do not extrapolate
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
420 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
421 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
422 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
423 errors.addProblem(km, "km not found");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
424 }
335
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
425 }
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
426 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
427 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
428 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
429 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
430 }
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
431 }
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
432
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
433 return ws;
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
434 }
64cfbd631f29 Implemented the "Wasserstand/Wasserspiegellagen" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 327
diff changeset
435
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
436 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
437 return interpolateWQ(km, null);
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
438 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
439
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
440 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
441 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
442 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
443
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
444 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
445
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
446 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
447
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
448 if (rowIndex >= 0) { // direct row match
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
449 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
450 return row.interpolateWQ(steps, this, errors);
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
451 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
452
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
453 rowIndex = -rowIndex -1;
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
454
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
455 if (rowIndex < 1 || rowIndex >= rows.size()) {
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
456 // do not extrapolate
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
457 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
458 // TODO: I18N
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
459 errors.addProblem(km, "km not found");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
460 }
339
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
461 return new double[2][0];
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
462 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
463
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
464 Row r1 = rows.get(rowIndex-1);
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
465 Row r2 = rows.get(rowIndex);
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
466
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
467 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
468 }
4509ba8fae68 Implementation of "Abflusskurve/Abflusstafel" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 335
diff changeset
469
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
470 public boolean interpolate(
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
471 double km,
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
472 double [] out,
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
473 QPosition qPosition,
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
474 Function qFunction
649
44175d4720f8 Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 645
diff changeset
475 ) {
427
909196be11a0 First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
476 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
477
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
478 out[1] = qFunction.value(getQ(qPosition, km));
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
479
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
480 if (Double.isNaN(out[1])) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
481 return false;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
482 }
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
483
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
484 QPosition nPosition = new QPosition();
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
485 if (getQPosition(km, out[1], nPosition) == null) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
486 return false;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
487 }
427
909196be11a0 First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
488
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
489 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
490
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
491 if (rowIndex >= 0) {
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
492 // direct row match
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
493 out[0] = rows.get(rowIndex).getW(nPosition);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
494 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
495 }
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
496
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
497 rowIndex = -rowIndex -1;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
498
1681
e5f7f25a511c fixed flys/issue201
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1098
diff changeset
499 if (rowIndex < 1 || rowIndex > R1) {
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
500 // do not extrapolate
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
501 return false;
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
502 }
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
503
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
504 Row r1 = rows.get(rowIndex-1);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
505 Row r2 = rows.get(rowIndex);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
506 out[0] = r1.getW(r2, km, nPosition);
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
507
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
508 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
509 }
909196be11a0 First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
510
1098
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
511
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
512 /**
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
513 * Look up interpolation of a Q at given positions.
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
514 *
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
515 * @param q the non-interpolated Q value.
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
516 * @param referenceKm the reference km (e.g. gauge position).
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
517 * @param kms positions for which to interpolate.
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
518 * @param ws (output) resulting interpolated ws.
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
519 * @param qs (output) resulting interpolated qs.
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
520 * @param errors calculation object to store errors.
1ea7eb72aaa6 Minor cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 742
diff changeset
521 */
427
909196be11a0 First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
522 public QPosition interpolate(
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
523 double q,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
524 double referenceKm,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
525 double [] kms,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
526 double [] ws,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
527 double [] qs,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
528 Calculation errors
426
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
529 ) {
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
530 return interpolate(
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
531 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
532 }
44175d4720f8 Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 645
diff changeset
533
44175d4720f8 Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 645
diff changeset
534 public QPosition interpolate(
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
535 double q,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
536 double referenceKm,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
537 double [] kms,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
538 double [] ws,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
539 double [] qs,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
540 int startIndex,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
541 int length,
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
542 Calculation errors
649
44175d4720f8 Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 645
diff changeset
543 ) {
645
433f67a076aa Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 633
diff changeset
544 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
545
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
546 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
547 // 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
548 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
549 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
550 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
551 errors.addProblem(referenceKm, "cannot find q");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
552 }
427
909196be11a0 First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
553 return null;
426
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
554 }
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
555
645
433f67a076aa Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 633
diff changeset
556 Row kmKey = new Row();
433f67a076aa Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 633
diff changeset
557
433f67a076aa Use an explicit reference km for interpolation now.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 633
diff changeset
558 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
559
649
44175d4720f8 Fix crashes in back jump correction.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 645
diff changeset
560 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
561
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
562 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
563 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
564 errors.addProblem(kms[i], "cannot find q");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
565 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
566 ws[i] = Double.NaN;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
567 continue;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
568 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
569
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
570 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
571 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
572
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
573 if (rowIndex >= 0) {
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
574 // direct row match
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
575 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
576 && errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
577 errors.addProblem(kms[i], "cannot find w");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
578 }
426
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
579 continue;
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
580 }
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
581
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
582 rowIndex = -rowIndex -1;
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
583
1681
e5f7f25a511c fixed flys/issue201
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1098
diff changeset
584 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
585 // do not extrapolate
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
586 if (errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
587 errors.addProblem(kms[i], "cannot find km");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
588 }
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
589 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
590 continue;
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
591 }
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
592 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
593 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
594
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
595 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
596 && errors != null) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
597 errors.addProblem(kms[i], "cannot find w");
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 655
diff changeset
598 }
426
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
599 }
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
600
427
909196be11a0 First step to calculate "W fuer ungleichwertige Abfluesse" correctly. flys/issue55
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 426
diff changeset
601 return qPosition;
426
c6b7ca0febcb Fix step to fix issue69: Do the right calculation
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 395
diff changeset
602 }
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
603
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
604 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
605 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
606 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
607
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
608 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
609
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
610 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
611 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
612 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
613
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
614 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
615
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
616 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
617 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
618 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
619
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
620 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
621 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
622 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
623 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
624 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
625
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
626 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
627 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
628 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
629
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
630 if (q > qMin && q < qMax) {
655
913b52064449 Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 649
diff changeset
631 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
632 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
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
634 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
635 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
636
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
637 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
638 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
639
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
640 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
641 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
642 }
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 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
645 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
646 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
647
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
648 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
649 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
650 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
651 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
652 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
653 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
654 }
d08f77e7f7e8 WST value table: Qs are now stored in ranges for each column.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 632
diff changeset
655
326
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
656 }
07eba6d3b4a5 Fetches w/q value tables from the backend.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
657 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org