Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQDay.java @ 1971:741d2067cfe1
Given CrossSections a name, let crosssection facets survive.
flys-artifacts/trunk@3387 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 12 Dec 2011 11:19:56 +0000 |
parents | e9475d2ef343 |
children | 5ff481ab24a1 |
rev | line source |
---|---|
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import gnu.trove.TIntArrayList; |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 /** |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 * This class represents a pool of data triples that consists of 'W', 'Q' and |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 * 'Day' data. |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 * |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 */ |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
11 public class WQDay |
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
12 extends WQ |
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
13 { |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 protected TIntArrayList days; |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 public WQDay() { |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
17 super(""); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 days = new TIntArrayList(); |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 public WQDay(int capacity) { |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 days = new TIntArrayList(capacity); |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
25 public WQDay(int [] days, double [] ws, double [] qs) { |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
26 super(qs, ws, ""); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
27 this.days = new TIntArrayList(days); |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
28 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
29 |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 public void add(int day, double w, double q) { |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
32 super.add(w, q); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 days.add(day); |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
1689
e9475d2ef343
Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
727
diff
changeset
|
36 |
e9475d2ef343
Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
727
diff
changeset
|
37 public boolean isIncreasing() { |
e9475d2ef343
Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
727
diff
changeset
|
38 int lo = getDay(0); |
e9475d2ef343
Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
727
diff
changeset
|
39 int hi = getDay(size()-1); |
e9475d2ef343
Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
727
diff
changeset
|
40 |
e9475d2ef343
Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
727
diff
changeset
|
41 return lo < hi; |
e9475d2ef343
Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
727
diff
changeset
|
42 } |
e9475d2ef343
Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
727
diff
changeset
|
43 |
e9475d2ef343
Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
727
diff
changeset
|
44 |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 public int getDay(int idx) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
46 return days.getQuick(idx); |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
49 @Override |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
50 public void removeNaNs() { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
51 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
52 int dest = 0; |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
53 int N = w.size(); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
54 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
55 for (int i = 0; i < N; ++i) { |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
56 double wi = w.getQuick(i); |
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
57 double qi = q.getQuick(i); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
58 |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
59 if (Double.isNaN(wi) || Double.isNaN(qi)) { |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
60 continue; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
61 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
62 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
63 days.setQuick(dest, days.getQuick(i)); |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
64 w.setQuick(dest, wi); |
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
65 q.setQuick(dest, qi); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
66 ++dest; |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
67 } |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
68 |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
69 if (dest < N) { |
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
70 days.remove(dest, N-dest); |
727
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
71 w .remove(dest, N-dest); |
11e9489eb1a7
WQDay is based on WQ now to make it exportable as AT.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
704
diff
changeset
|
72 q .remove(dest, N-dest); |
686
3dc61e00385e
Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
385
diff
changeset
|
73 } |
385
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 } |
478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |