annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/WQDay.java @ 7494:4de4b19b6be6

Fixed half broken interpolation code for lines to 'Dauerlinie'.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 01 Nov 2013 13:25:54 +0100
parents 8b614d152a79
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: 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 {
7494
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
28 public static final Comparator<double []> FIRST_CMP = new Comparator<double []>() {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
29 @Override
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
30 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
31 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
32 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
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 return 0;
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
35 }
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 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
39
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
40
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
41 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
42
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 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
44 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
45 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
46 }
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 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
49 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
50 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
51 }
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
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
53 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
54 super(qs, ws, "");
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
55 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
56 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
57
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
58
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 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
60 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
61 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
62 }
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
1689
e9475d2ef343 Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 727
diff changeset
64
e9475d2ef343 Bugfix: #189 Changed the order of a duration curve CSV export.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 727
diff changeset
65 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
66 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
67 }
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
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
70 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
71 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
72 }
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
7494
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
74 private static final Double interpolateX(ArrayList<double []> dxs, double x) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
75
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
76 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
77
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
78 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
79 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
80 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
81
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
82 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
83 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
84 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
85 return curr[0];
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
86 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
87
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
88 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
89 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
90 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
91 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
92 return Linear.linear(
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
93 x,
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
94 prev[1], curr[1],
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
95 prev[0], curr[0]);
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
96 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
97 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
98
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
99 return null;
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 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
103
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
104 int S = days.size();
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
105
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
106 if (S == 0) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
107 return null;
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
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
110 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
111
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
112 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
113 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
114 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
115
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
116 return interpolateX(dws, w);
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 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
120
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
121 int S = days.size();
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
122
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
123 if (S == 0) {
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
124 return null;
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
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
127 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
128
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
129 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
130 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
131 }
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
132
4de4b19b6be6 Fixed half broken interpolation code for lines to 'Dauerlinie'.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7484
diff changeset
133 return interpolateX(dqs, q);
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
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
136 @Override
686
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
137 public void removeNaNs() {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
138
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
139 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
140 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
141
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
142 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
143 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
144 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
145
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
146 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
147 continue;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
148 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
149
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
150 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
151 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
152 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
153 ++dest;
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
154 }
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
155
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
156 if (dest < N) {
3dc61e00385e Merged with trunk and introduced hashing of computed values.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 385
diff changeset
157 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
158 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
159 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
160 }
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
161 }
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
162 }
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
163 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org