annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java @ 2096:bf598599782a

Made old calculation results available for floodmaps. flys-artifacts/trunk@3644 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 11 Jan 2012 10:17:16 +0000
parents bda04ae1154f
children 5ff481ab24a1
rev   line source
726
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
2087
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
3 import java.util.regex.Matcher;
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
4 import java.util.regex.Pattern;
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
5
1678
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1033
diff changeset
6 import de.intevation.flys.utils.DataUtil;
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1033
diff changeset
7
726
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 import gnu.trove.TDoubleArrayList;
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9
1033
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
10 import org.apache.log4j.Logger;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
11
726
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 public class WQ
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 748
diff changeset
13 extends NamedObjectImpl
726
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 {
2087
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
15 public static final Pattern NUMBERS_PATTERN =
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
16 Pattern.compile("\\D*(\\d++.\\d*)\\D*");
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
17
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
18
1033
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
19 private static Logger logger = Logger.getLogger(WQ.class);
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
20
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 748
diff changeset
21 // TODO: s/w/ws/g
726
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 protected TDoubleArrayList w;
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
925
0cb1a70b8b92 Added the math needed to calculate "W-Differenzen" in "Laengsschnitten"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 748
diff changeset
24 // TODO: s/q/qs/g
726
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 protected TDoubleArrayList q;
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 public WQ() {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 this("");
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 public WQ(String name) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 w = new TDoubleArrayList();
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 q = new TDoubleArrayList();
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public WQ(int capacity) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 this(capacity, "");
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 public WQ(int capacity, String name) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 super(name);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 w = new TDoubleArrayList(capacity);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 q = new TDoubleArrayList(capacity);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 public WQ(double [] qs, double [] ws) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 this(qs, ws, "");
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 public WQ(double [] qs, double [] ws, String name) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 super(name);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 w = new TDoubleArrayList(ws);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 q = new TDoubleArrayList(qs);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56
2087
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
57
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
58 public Double getRawValue() {
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
59 if (name == null || name.length() == 0) {
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
60 // this should never happen
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
61 return null;
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
62 }
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
63
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
64 Matcher m = NUMBERS_PATTERN.matcher(name);
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
65
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
66 if (m.matches()) {
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
67 String raw = m.group(1);
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
68
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
69 try {
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
70 return Double.valueOf(raw);
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
71 }
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
72 catch (NumberFormatException nfe) {
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
73 // do nothing
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
74 }
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
75 }
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
76
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
77 return null;
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
78 }
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
79
bda04ae1154f #196 Localized the WQ labels in CSV exports.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1678
diff changeset
80
726
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 public void add(double w, double q) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82 this.w.add(w);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 this.q.add(q);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 public int size() {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 return w.size();
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
89
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
90 public double getW(int idx) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
91 return w.getQuick(idx);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
92 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
93
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
94 public double getQ(int idx) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
95 return q.getQuick(idx);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
96 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
97
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
98 public double [] get(int idx) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 return get(idx, new double [2]);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 public double [] get(int idx, double [] dst) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 dst[0] = w.getQuick(idx);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 dst[1] = q.getQuick(idx);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 return dst;
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 public double [] getWs() {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 return w.toNativeArray();
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112 public double [] getQs() {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
113 return q.toNativeArray();
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
114 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
115
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 public static void removeNaNs(TDoubleArrayList [] arrays) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
117
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 int dest = 0;
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
120 int A = arrays.length;
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 int N = arrays[0].size();
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 OUTER: for (int i = 0; i < N; ++i) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 for (int j = 0; j < A; ++j) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 TDoubleArrayList a = arrays[j];
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 double v = a.getQuick(i);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 if (Double.isNaN(v)) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
128 continue OUTER;
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
129 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
130 a.setQuick(dest, v);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
131 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
132 ++dest;
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
133 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
134
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
135 if (dest < N) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
136 for (int i = 0; i < A; ++i) {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
137 arrays[i].remove(dest, N-dest);
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
138 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
139 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
140 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
141
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
142 public void removeNaNs() {
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
143 removeNaNs(new TDoubleArrayList [] { w, q });
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
144 }
744
b385577bcaca WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 726
diff changeset
145
b385577bcaca WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 726
diff changeset
146 public boolean guessWaterIncreasing() {
b385577bcaca WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 726
diff changeset
147 return guessWaterIncreasing(0.05f);
b385577bcaca WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 726
diff changeset
148 }
b385577bcaca WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 726
diff changeset
149
b385577bcaca WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 726
diff changeset
150 public boolean guessWaterIncreasing(float factor) {
1678
03fbf1b30e72 Removed code duplication of guessWaterIncreasing()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1033
diff changeset
151 return DataUtil.guessWaterIncreasing(w, factor);
744
b385577bcaca WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 726
diff changeset
152 }
b385577bcaca WQ: Added a method to guess is increasing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 726
diff changeset
153
1033
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
154 public int [] longestIncreasingWRangeIndices() {
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
155 return longestIncreasingWRangeIndices(new int[2]);
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
156 }
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
157
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
158 public int [] longestIncreasingWRangeIndices(int [] bounds) {
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
159
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
160 int N = size();
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
161 int start = 0;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
162 int stop = 0;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
163
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
164 double lastW = Double.MAX_VALUE;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
165
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
166 for (int i = 0; i < N; ++i) {
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
167 double v = w.getQuick(i);
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
168 if (v <= lastW) {
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
169 if (stop-start > bounds[1]-bounds[0]) {
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
170 bounds[0] = start;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
171 bounds[1] = stop;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
172 if (logger.isDebugEnabled()) {
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
173 logger.debug("new range: " +
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
174 bounds[0] + " - " + bounds[1] + " (" +
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
175 w.getQuick(bounds[0]) + ", " +
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
176 w.getQuick(bounds[1]) + ")");
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
177
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
178 }
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
179 }
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
180 start = stop = i;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
181 }
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
182 else {
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
183 stop = i;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
184 }
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
185 lastW = v;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
186 }
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
187
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
188 if (stop-start > bounds[1]-bounds[0]) {
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
189 bounds[0] = start;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
190 bounds[1] = stop;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
191 if (logger.isDebugEnabled()) {
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
192 logger.debug("new range @end: " +
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
193 bounds[0] + " - " + bounds[1] + " (" +
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
194 w.getQuick(bounds[0]) + ", " +
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
195 w.getQuick(bounds[1]) + ")");
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
196
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
197 }
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
198 }
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
199
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
200 return bounds;
821aaceb2776 Fix for flys/issue191
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 926
diff changeset
201 }
726
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
202 }
cbaa3ca86f2f Added base class WQ for WQKms.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
203 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org