Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/HistoricalWQTimerange.java @ 6309:ebba1a795d76
Correctly set the reference system after conversion
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 12 Jun 2013 17:45:35 +0200 |
parents | af13ceeba52a |
children | 5e38e2924c07 |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5343
diff
changeset
|
9 package org.dive4elements.river.artifacts.model; |
2311
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import gnu.trove.TDoubleArrayList; |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
13 import java.util.ArrayList; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
14 import java.util.Collections; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
15 import java.util.List; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
16 |
2311
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 /** |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 * A subclass of WQTimerange that stores besides W, Q and Timerange values |
5343
61f4d4164a30
Doc, cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
5335
diff
changeset
|
20 * another double value (difference to something). |
2311
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 * |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 */ |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 public class HistoricalWQTimerange extends WQTimerange { |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
26 public static class HistoricalTimerangeItem extends TimerangeItem { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
27 public double diff; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
28 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
29 public HistoricalTimerangeItem (Timerange timerange, double q, double w, double diff) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
30 super(timerange, q, w); |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
31 this.diff = diff; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
32 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
33 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
34 public double[] get(double[] wq) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
35 if (wq.length >= 3) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
36 wq[0] = w; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
37 wq[1] = q; |
4172
9fd17cb69047
Added missing delta Q value to calculation results of historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4171
diff
changeset
|
38 wq[2] = diff; |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
39 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
40 else if (wq.length >= 2) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
41 return super.get(wq); |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
42 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
43 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
44 return wq; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
45 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
46 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
47 |
2311
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 protected TDoubleArrayList diffs; |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 public HistoricalWQTimerange(String name) { |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 super(name); |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 diffs = new TDoubleArrayList(); |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 public void add(double w, double q, double diff, Timerange t) { |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 ws.add(w); |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 qs.add(q); |
5335
05eeedc5b156
Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4185
diff
changeset
|
61 timeranges.add(t); |
2311
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 diffs.add(diff); |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 /** |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 * This method requires a 3dim double array for <i>res</i>! |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 */ |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 @Override |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 public double[] get(int idx, double[] res) { |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 res[0] = ws.getQuick(idx); |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 res[1] = qs.getQuick(idx); |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 res[2] = diffs.getQuick(idx); |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 return res; |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 public double[] getDiffs() { |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 return diffs.toNativeArray(); |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 } |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
82 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
83 @Override |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
84 public List<TimerangeItem> sort() { |
5335
05eeedc5b156
Doc, cosmetic and TODO fixes, renamed field in WQTimeRange.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4185
diff
changeset
|
85 ArrayList<TimerangeItem> items = new ArrayList<TimerangeItem>(timeranges.size()); |
4171
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
86 for (int i = 0, n = size(); i < n; i++) { |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
87 items.add(new HistoricalTimerangeItem(getTimerange(i), getQ(i), getW(i), diffs.get(i))); |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
88 } |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
89 |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
90 Collections.sort(items); |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
91 return items; |
1d8faeedda0c
Sort calculation results of a historical discharge calculation based on their start date.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
92 } |
2311
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |