annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQDay.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 4de4b19b6be6
children
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: 2182
diff changeset
9 package org.dive4elements.river.artifacts.model;
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
10
7494
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
11 import java.util.ArrayList;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
12 import java.util.Collections;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
13 import java.util.Comparator;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
14
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
15 import org.dive4elements.river.artifacts.math.Linear;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
16
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
17 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
18
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 * 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
21 * '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
22 *
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 * @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
24 */
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
25 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
26 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
27 {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7494
diff changeset
28 public static final Comparator<double []> FIRST_CMP =
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7494
diff changeset
29 new Comparator<double []>() {
7494
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
30 @Override
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
31 public int compare(double [] a, double [] b) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
32 double diff = a[0] - b[0];
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
33 if (diff < 0d) return -1;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
34 if (diff > 0d) return +1;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
35 return 0;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
36 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
37 };
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
38
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
39 public static final double EPSILON = 1e-4;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
40
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
41
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
42 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
43
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
44 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
45 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
46 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
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
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
49 public WQDay(int capacity) {
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1689
diff changeset
50 super(capacity);
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
51 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
52 }
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
53
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
54 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
55 super(qs, ws, "");
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
56 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
57 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
58
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
59
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
60 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
61 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
62 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
63 }
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
64
1689
e9475d2ef343 Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 727
diff changeset
65
e9475d2ef343 Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 727
diff changeset
66 public boolean isIncreasing() {
7484
8b614d152a79 WQDay is increasing(?) if it is empty of last is greater than first.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5994
diff changeset
67 return size() == 0 || getDay(0) < getDay(size()-1);
1689
e9475d2ef343 Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 727
diff changeset
68 }
e9475d2ef343 Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 727
diff changeset
69
e9475d2ef343 Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 727
diff changeset
70
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
71 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
72 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
73 }
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
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7494
diff changeset
75 private static final Double interpolateX(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7494
diff changeset
76 ArrayList<double []> dxs,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7494
diff changeset
77 double x
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 7494
diff changeset
78 ) {
7494
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
79 Collections.sort(dxs, FIRST_CMP);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
80
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
81 if (Math.abs(x - dxs.get(0)[1]) < EPSILON) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
82 return dxs.get(0)[0];
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
83 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
84
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
85 for (int i = 1, S = dxs.size(); i < S; ++i) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
86 double [] curr = dxs.get(i);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
87 if (Math.abs(x - curr[1]) < EPSILON) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
88 return curr[0];
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
89 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
90
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
91 double [] prev = dxs.get(i-1);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
92 double x1 = Math.min(prev[1], curr[1]);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
93 double x2 = Math.max(prev[1], curr[1]);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
94 if (x > x1 && x < x2) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
95 return Linear.linear(
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
96 x,
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
97 prev[1], curr[1],
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
98 prev[0], curr[0]);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
99 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
100 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
101
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
102 return null;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
103 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
104
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
105 public Double interpolateDayByW(double w) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
106
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
107 int S = days.size();
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
108
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
109 if (S == 0) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
110 return null;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
111 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
112
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
113 ArrayList<double[]> dws = new ArrayList<double[]>(S);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
114
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
115 for (int i = 0; i < S; ++i) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
116 dws.add(new double[] { getDay(i), getW(i) });
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
117 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
118
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
119 return interpolateX(dws, w);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
120 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
121
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
122 public Double interpolateDayByQ(double q) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
123
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
124 int S = days.size();
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
125
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
126 if (S == 0) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
127 return null;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
128 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
129
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
130 ArrayList<double[]> dqs = new ArrayList<double[]>(S);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
131
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
132 for (int i = 0; i < S; ++i) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
133 dqs.add(new double[] { getDay(i), getQ(i) });
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
134 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
135
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
136 return interpolateX(dqs, q);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
137 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
138
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
139 @Override
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
140 public void removeNaNs() {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
141
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
142 int dest = 0;
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1689
diff changeset
143 int N = ws.size();
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
144
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
145 for (int i = 0; i < N; ++i) {
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1689
diff changeset
146 double wi = ws.getQuick(i);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1689
diff changeset
147 double qi = qs.getQuick(i);
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
148
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
149 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
150 continue;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
151 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
152
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
153 days.setQuick(dest, days.getQuick(i));
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1689
diff changeset
154 ws.setQuick(dest, wi);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1689
diff changeset
155 qs.setQuick(dest, qi);
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
156 ++dest;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
157 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
158
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
159 if (dest < N) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
160 days.remove(dest, N-dest);
2182
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1689
diff changeset
161 ws .remove(dest, N-dest);
5ff481ab24a1 Refactored class hierachy to integrate model for W~W.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1689
diff changeset
162 qs .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
163 }
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
164 }
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
165 }
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
166 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org