Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQCKms.java @ 2424:092e519ff461
merged flys-artifacts/2.6.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:26 +0200 |
parents | 5ff481ab24a1 |
children | 5642a83420f2 |
comparison
equal
deleted
inserted
replaced
2392:8112ec686a9a | 2424:092e519ff461 |
---|---|
1 package de.intevation.flys.artifacts.model; | |
2 | |
3 import gnu.trove.TDoubleArrayList; | |
4 | |
5 /** | |
6 * This class represents a pool of data triples that consists of 'W', 'Q' and | |
7 * 'KM' data with corrected 'W' values computed by a BackJumpCorrector. | |
8 * | |
9 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
10 */ | |
11 public class WQCKms | |
12 extends WQKms | |
13 { | |
14 protected TDoubleArrayList cws; | |
15 | |
16 public WQCKms() { | |
17 } | |
18 | |
19 public WQCKms(WQKms other, double [] cws) { | |
20 this.ws = other.ws; | |
21 this.qs = other.qs; | |
22 this.kms = other.kms; | |
23 this.cws = new TDoubleArrayList(cws); | |
24 } | |
25 | |
26 | |
27 public WQCKms(double[] kms, double[] qs, double[] ws, double[] cws) { | |
28 super(kms, qs, ws); | |
29 | |
30 this.cws = new TDoubleArrayList(cws); | |
31 } | |
32 | |
33 @Override | |
34 public void removeNaNs() { | |
35 removeNaNs(new TDoubleArrayList [] { ws, qs, cws, kms }); | |
36 } | |
37 | |
38 /** | |
39 * Adds a new row to this data pool with corrected W. | |
40 * | |
41 * @param w a W. | |
42 * @param q a Q. | |
43 * @param kms a Kms. | |
44 * @param cw The corrected W. | |
45 */ | |
46 public void add(double w, double q, double kms, double cw) { | |
47 super.add(w, q, kms); | |
48 cws.add(cw); | |
49 } | |
50 | |
51 @Override | |
52 public double[] get(int idx) { | |
53 return get(idx, new double[4]); | |
54 } | |
55 | |
56 /** | |
57 * This method returns a 4dim array of W, Q,Kms and corrected W. | |
58 * | |
59 * @param idx The position of the triple. | |
60 * @param dst destination array | |
61 * | |
62 * @return a 4dim array of [W, Q, Kms, CW] in dst. | |
63 */ | |
64 @Override | |
65 public double[] get(int idx, double[] dst) { | |
66 dst = super.get(idx, dst); | |
67 | |
68 if (dst.length < 4) { | |
69 return dst; | |
70 } | |
71 | |
72 if (cws != null && cws.size() > idx) { | |
73 dst[3] = cws.getQuick(idx); | |
74 } | |
75 | |
76 return dst; | |
77 } | |
78 | |
79 public double getC(int idx) { | |
80 return cws.getQuick(idx); | |
81 } | |
82 | |
83 | |
84 /** | |
85 * Returns the double array of corrected W values. | |
86 * | |
87 * @return the double array of corrected W values. | |
88 */ | |
89 public double[] getCWs() { | |
90 return cws.toNativeArray(); | |
91 } | |
92 } | |
93 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |