Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Parameters.java @ 5822:a7df90f425e2 before-dive4elements-move
Remove obsolete (duplicate) macro and its use.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 08:24:54 +0200 |
parents | bcf25d8c183e |
children |
rev | line source |
---|---|
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
3 import de.intevation.flys.artifacts.math.Linear; |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
4 |
4821
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3552
diff
changeset
|
5 import de.intevation.flys.utils.DoubleUtil; |
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3552
diff
changeset
|
6 |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import gnu.trove.TDoubleArrayList; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import java.io.Serializable; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
2785
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
11 import org.apache.log4j.Logger; |
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
12 |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 public class Parameters |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 implements Serializable |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 { |
2785
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
16 private static Logger log = Logger.getLogger(Parameters.class); |
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
17 |
3217
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
18 public interface Visitor { |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
19 |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
20 void visit(double [] row); |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
21 |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
22 } // interface Visitor |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
23 |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
24 public static final double EPSILON = 1e-4; |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
25 |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 protected String [] columnNames; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 protected TDoubleArrayList [] columns; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 public Parameters() { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 public Parameters(String [] columnNames) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 if (columnNames == null || columnNames.length < 1) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 throw new IllegalArgumentException("columnNames too short."); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 this.columnNames = columnNames; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 columns = new TDoubleArrayList[columnNames.length]; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 for (int i = 0; i < columns.length; ++i) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 columns[i] = new TDoubleArrayList(); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 public int columnIndex(String name) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 for (int i = 0; i < columnNames.length; ++i) { |
2792
fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2785
diff
changeset
|
45 if (columnNames[i].equals(name)) { |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 return i; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
3057
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
49 if (log.isDebugEnabled()) { |
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
50 log.debug("columnIndex: " + name + " not found in columnNames"); |
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
51 } |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 return -1; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
55 public int newRow() { |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 int N = columns[0].size(); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 for (int i = 0; i < columns.length; ++i) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 columns[i].add(Double.NaN); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
63 return N; |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 |
3010
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2792
diff
changeset
|
66 public double get(int row, int index) { |
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2792
diff
changeset
|
67 return columns[index].getQuick(row); |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 public double get(int i, String columnName) { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 int index = columnIndex(columnName); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 return index >= 0 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 ? columns[index].getQuick(i) |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 : Double.NaN; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 |
3010
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2792
diff
changeset
|
77 public void set(int row, int index, double value) { |
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2792
diff
changeset
|
78 columns[index].setQuick(row, value); |
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2792
diff
changeset
|
79 } |
05a3fe8800b3
FixA: Store Chi^2 of fitting into result, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2792
diff
changeset
|
80 |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
81 public void set(int i, String columnName, double value) { |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
82 int idx = columnIndex(columnName); |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
83 if (idx >= 0) { |
2785
f87fcedbfa82
FixA: Fixed stupid index bug.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2744
diff
changeset
|
84 columns[idx].setQuick(i, value); |
2729
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
85 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
86 } |
a441be7f1589
Added Fix calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2695
diff
changeset
|
87 |
3011
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
88 public boolean set(int row, int [] indices, double [] values) { |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
89 boolean invalid = false; |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
90 for (int i = 0; i < indices.length; ++i) { |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
91 double v = values[i]; |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
92 if (Double.isNaN(v)) { |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
93 invalid = true; |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
94 } |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
95 else { |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
96 columns[indices[i]].setQuick(row, v); |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
97 } |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
98 } |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
99 return invalid; |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
100 } |
ab81ffd1343e
FixA: Reactivated rewrite of the outlier checks.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3010
diff
changeset
|
101 |
3552
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
102 public boolean set(int row, String [] names, double [] values) { |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
103 boolean success = true; |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
104 for (int i = 0; i < names.length; ++i) { |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
105 int idx = columnIndex(names[i]); |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
106 if (idx >= 0) { |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
107 columns[idx].setQuick(row, values[i]); |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
108 } |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
109 else { |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
110 success = false; |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
111 } |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
112 } |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
113 return success; |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
114 } |
1df6984628c3
S/Q: Extented the result data model of the S/Q calculation to
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3392
diff
changeset
|
115 |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 public int size() { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 return columns[0].size(); |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 public int getNumberColumns() { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 return columnNames.length; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 public String [] getColumnNames() { |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 return columnNames; |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 public void removeNaNs() { |
4821
bcf25d8c183e
Moved NaN removal code from W to DoubleUtil. Create QKms when calculating the 'Umhuellende'.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3552
diff
changeset
|
129 DoubleUtil.removeNaNs(columns); |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 } |
2744
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
131 |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
132 public int [] columnIndices(String [] columns) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
133 int [] indices = new int[columns.length]; |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
134 for (int i = 0; i < columns.length; ++i) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
135 indices[i] = columnIndex(columns[i]); |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
136 } |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
137 return indices; |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
138 } |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
139 |
3392
56f62b5209f5
S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
140 public double getValue(int row, String column) { |
56f62b5209f5
S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
141 int idx = columnIndex(column); |
56f62b5209f5
S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
142 return idx >= 0 |
56f62b5209f5
S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
143 ? columns[idx].getQuick(row) |
56f62b5209f5
S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
144 : Double.NaN; |
56f62b5209f5
S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
145 } |
56f62b5209f5
S/Q relation: Write parameters as export result.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3217
diff
changeset
|
146 |
3105
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
147 public double [] get(int row, String [] columns) { |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
148 return get(row, columns, new double[columns.length]); |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
149 } |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
150 |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
151 public double [] get(int row, String [] columns, double [] values) { |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
152 for (int i = 0; i < columns.length; ++i) { |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
153 int idx = columnIndex(columns[i]); |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
154 values[i] = idx < 0 |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
155 ? Double.NaN |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
156 : this.columns[idx].getQuick(row); |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
157 } |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
158 |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
159 return values; |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
160 } |
9592b7d76633
Generate fake data for SQ curves; Implemented the Facet and Generator stuff.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3082
diff
changeset
|
161 |
2744
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
162 public void get(int row, int [] columnIndices, double [] values) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
163 for (int i = 0; i < columnIndices.length; ++i) { |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
164 int index = columnIndices[i]; |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
165 values[i] = index >= 0 && index < columns.length |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
166 ? columns[index].getQuick(row) |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
167 : Double.NaN; |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
168 } |
c1f2e792704a
FixA: Calculate Delta W/t, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2729
diff
changeset
|
169 } |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
170 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
171 public int binarySearch(String columnName, double value) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
172 return binarySearch(columnIndex(columnName), value); |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
173 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
174 |
3056
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
175 /** |
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
176 * Performes a binary search in the column identified by its |
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
177 * index. |
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
178 * @return Index of found element or negative insertion point (shifted by one) |
0b5a7a2c3724
Try to workaround some exception in FixWQCurveFacet and FixWQCurveGenerator
Christian Lins <christian.lins@intevation.de>
parents:
3027
diff
changeset
|
179 */ |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
180 public int binarySearch(int columnIndex, double value) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
181 TDoubleArrayList column = columns[columnIndex]; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
182 return column.binarySearch(value); |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
183 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
184 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
185 public int binarySearch(String columnName, double value, double epsilon) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
186 return binarySearch(columnIndex(columnName), value, epsilon); |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
187 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
188 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
189 public int binarySearch(int columnIndex, double value, double epsilon) { |
3057
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
190 if (epsilon < 0d) epsilon = -epsilon; |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
191 double vl = value - epsilon; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
192 double vh = value + epsilon; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
193 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
194 TDoubleArrayList column = columns[columnIndex]; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
195 int lo = 0, hi = column.size()-1; |
3126
fe9be7ccc5e8
Fixed binary search in Parameters.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3125
diff
changeset
|
196 while (hi >= lo) { |
fe9be7ccc5e8
Fixed binary search in Parameters.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3125
diff
changeset
|
197 int mid = (lo + hi) >> 1; |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
198 double v = column.getQuick(mid); |
3126
fe9be7ccc5e8
Fixed binary search in Parameters.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3125
diff
changeset
|
199 if (v < vl) lo = mid + 1; |
fe9be7ccc5e8
Fixed binary search in Parameters.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
3125
diff
changeset
|
200 else if (v > vh) hi = mid - 1; |
3057
febc39e77672
Make it compilable again
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3056
diff
changeset
|
201 else return mid; |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
202 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
203 |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
204 return -(lo + 1); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
205 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
206 |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
207 public double [] interpolate(int columnIndex, double key) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
208 return interpolate(columnIndex, key, new double[columns.length]); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
209 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
210 |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
211 public double [] interpolate(String columnName, double key) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
212 return interpolate( |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
213 columnIndex(columnName), key, new double[columns.length]); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
214 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
215 |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
216 public double [] interpolate( |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
217 String columnName, |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3061
diff
changeset
|
218 double key, |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
219 double [] values |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
220 ) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
221 return interpolate(columnIndex(columnName), key, values); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
222 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
223 |
3061
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
224 public double [] interpolate( |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3061
diff
changeset
|
225 int columnIndex, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3061
diff
changeset
|
226 double key, |
3061
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
227 double [] values |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
228 ) { |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
229 int row = binarySearch(columnIndex, key, EPSILON); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
230 |
3081
26119b7b3154
Fixing output generator hacking
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
231 if (row >= 0) { // direct hit |
3059
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
232 for (int i = 0; i < values.length; ++i) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
233 values[i] = columns[i].getQuick(row); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
234 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
235 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
236 else { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
237 row = -row - 1; |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
238 if (row < 1 || row >= size()) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
239 return null; |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
240 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
241 double v1 = columns[columnIndex].getQuick(row-1); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
242 double v2 = columns[columnIndex].getQuick(row); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
243 double factor = Linear.factor(key, v1, v2); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
244 for (int i = 0; i < values.length; ++i) { |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
245 values[i] = Linear.weight( |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
246 factor, |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
247 columns[i].getQuick(row-1), |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
248 columns[i].getQuick(row)); |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
249 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
250 } |
4f7171ac6153
Parameters: Linear interpolation of parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3057
diff
changeset
|
251 return values; |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
252 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
253 |
3061
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
254 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
255 public double [] interpolate( |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3061
diff
changeset
|
256 String keyName, |
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3061
diff
changeset
|
257 double key, |
3061
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
258 String [] columnNames |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
259 ) { |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
260 int keyIndex = columnIndex(keyName); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
261 return keyIndex < 0 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
262 ? null |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
263 : interpolate(keyIndex, key, columnNames); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
264 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
265 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
266 public double [] interpolate( |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
267 int keyIndex, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
268 double key, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
269 String [] columnNames |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
270 ) { |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
271 int row = binarySearch(keyIndex, key, EPSILON); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
272 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
273 if (row >= 0) { // direct match |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
274 double [] values = new double[columnNames.length]; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
275 for (int i = 0; i < values.length; ++i) { |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
276 int ci = columnIndex(columnNames[i]); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
277 values[i] = ci < 0 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
278 ? Double.NaN |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
279 : columns[ci].getQuick(row); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
280 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
281 return values; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
282 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
283 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
284 row = -row - 1; |
3081
26119b7b3154
Fixing output generator hacking
Christian Lins <christian.lins@intevation.de>
parents:
3076
diff
changeset
|
285 if (row < 1 || row >= size()) { |
3082
9e03960b3ab8
FixA: Lowered log level in parameter interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3081
diff
changeset
|
286 log.debug("interpolate: row is out of bounds"); |
3061
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
287 return null; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
288 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
289 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
290 double v1 = columns[keyIndex].getQuick(row-1); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
291 double v2 = columns[keyIndex].getQuick(row); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
292 double factor = Linear.factor(key, v1, v2); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
293 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
294 double [] values = new double[columnNames.length]; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
295 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
296 for (int i = 0; i < values.length; ++i) { |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
297 int ci = columnIndex(columnNames[i]); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
298 values[i] = ci < 0 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
299 ? Double.NaN |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
300 : Linear.weight( |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
301 factor, |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
302 columns[ci].getQuick(row-1), |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
303 columns[ci].getQuick(row)); |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
304 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
305 |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
306 return values; |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
307 } |
49baebb39305
FixA: Add interpolation of parameters that better suits the instantiation real functions.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3059
diff
changeset
|
308 |
3027
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
309 public boolean isSorted(String columnName) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
310 return isSorted(columnIndex(columnName)); |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
311 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
312 |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
313 public boolean isSorted(int columnIndex) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
314 TDoubleArrayList column = columns[columnIndex]; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
315 for (int i = 1, N = column.size(); i < N; ++i) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
316 if (column.getQuick(i-1) > column.getQuick(i)) { |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
317 return false; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
318 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
319 } |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
320 return true; |
52aac4941d2a
FixA: Added binary search methods for parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3011
diff
changeset
|
321 } |
3217
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
322 |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
323 public void visit(Visitor visitor) { |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
324 visit(visitor, new double[columns.length]); |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
325 } |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
326 |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
327 public void visit(Visitor visitor, double [] data) { |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
328 for (int i = 0, R = size(); i < R; ++i) { |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
329 for (int j = 0; j < data.length; ++j) { |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
330 data[j] = columns[j].getQuick(i); |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
331 } |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
332 visitor.visit(data); |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
333 } |
79dd823733e2
FixA: Added parameter exporter.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3126
diff
changeset
|
334 } |
2695
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
335 } |
ae0742f92cd5
Added model to store fitting results into cache.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
336 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |