Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQCKms.java @ 4128:11c589d68f13
Fix for NPE in FLYSWorkspace.bringUp() #933
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sun, 14 Oct 2012 10:15:50 +0200 |
parents | 5642a83420f2 |
children | bcf25d8c183e |
rev | line source |
---|---|
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import gnu.trove.TDoubleArrayList; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 /** |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 * This class represents a pool of data triples that consists of 'W', 'Q' and |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 * 'KM' data with corrected 'W' values computed by a BackJumpCorrector. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 */ |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2182
diff
changeset
|
11 public class WQCKms |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
12 extends WQKms |
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
13 { |
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
14 protected TDoubleArrayList cws; |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
402
diff
changeset
|
16 public WQCKms() { |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
402
diff
changeset
|
17 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
402
diff
changeset
|
18 |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
402
diff
changeset
|
19 public WQCKms(WQKms other, double [] cws) { |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
20 this.ws = other.ws; |
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
21 this.qs = other.qs; |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
402
diff
changeset
|
22 this.kms = other.kms; |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
23 this.cws = new TDoubleArrayList(cws); |
655
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
402
diff
changeset
|
24 } |
913b52064449
Refactored version of "Berechnung 4"
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
402
diff
changeset
|
25 |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 public WQCKms(double[] kms, double[] qs, double[] ws, double[] cws) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 super(kms, qs, ws); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
30 this.cws = new TDoubleArrayList(cws); |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
33 @Override |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
34 public void removeNaNs() { |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
35 removeNaNs(new TDoubleArrayList [] { ws, qs, cws, kms }); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
36 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
37 |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 /** |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 * Adds a new row to this data pool with corrected W. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 * @param w a W. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 * @param q a Q. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 * @param kms a Kms. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 * @param cw The corrected W. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 */ |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 public void add(double w, double q, double kms, double cw) { |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
47 super.add(w, q, kms); |
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
48 cws.add(cw); |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
51 @Override |
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
52 public double[] get(int idx) { |
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
53 return get(idx, new double[4]); |
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
54 } |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 /** |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 * This method returns a 4dim array of W, Q,Kms and corrected W. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 * @param idx The position of the triple. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 * @param dst destination array |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 * @return a 4dim array of [W, Q, Kms, CW] in dst. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 */ |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
655
diff
changeset
|
64 @Override |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 public double[] get(int idx, double[] dst) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 dst = super.get(idx, dst); |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 if (dst.length < 4) { |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 return dst; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
72 if (cws != null && cws.size() > idx) { |
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
73 dst[3] = cws.getQuick(idx); |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 return dst; |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
719
035c0095b427
Draw correction curve again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
79 public double getC(int idx) { |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
80 return cws.getQuick(idx); |
719
035c0095b427
Draw correction curve again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
81 } |
035c0095b427
Draw correction curve again.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
82 |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 /** |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 * Returns the double array of corrected W values. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 * |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 * @return the double array of corrected W values. |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 */ |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 public double[] getCWs() { |
2182
5ff481ab24a1
Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
719
diff
changeset
|
90 return cws.toNativeArray(); |
402
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 } |
eb22ffe4d74c
Implemented methods to retrieve and compute the data used to create discharge longitudinal sections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |