Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation6.java @ 6662:ab11ce67854b
Fixed typo that made me search longer than necessary.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 25 Jul 2013 12:37:25 +0200 |
parents | 20a32dbdbb59 |
children | fe03337c8011 |
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:
5962
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:
5962
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:
5339
diff
changeset
|
9 package org.dive4elements.river.artifacts.model; |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
11 import java.util.ArrayList; |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
12 import java.util.Arrays; |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
13 import java.util.Date; |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
14 import java.util.HashMap; |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
15 import java.util.List; |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
16 import java.util.Map; |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
17 |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import org.apache.log4j.Logger; |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5339
diff
changeset
|
20 import org.dive4elements.river.model.DischargeTable; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5339
diff
changeset
|
21 import org.dive4elements.river.model.Gauge; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5339
diff
changeset
|
22 import org.dive4elements.river.model.TimeInterval; |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
23 |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
24 import org.dive4elements.river.artifacts.access.HistoricalDischargeAccess; |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
25 import org.dive4elements.river.artifacts.access.HistoricalDischargeAccess.EvaluationMode; |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
26 |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 /** |
5339
1b73b731f7bd
Doc, debug fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4281
diff
changeset
|
29 * Historical Discharge Calculation. |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 */ |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 public class Calculation6 extends Calculation { |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
34 private static final Logger log = Logger.getLogger(Calculation6.class); |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
36 private int mode; |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
37 private long [] timerange; |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
38 private double [] values; |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
39 private Long officialGaugeNumber; |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
41 |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
42 public Calculation6(HistoricalDischargeAccess access) { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
43 EvaluationMode mode = access.getEvaluationMode(); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
44 Timerange tr = access.getEvaluationTimerange(); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
45 double [] vs = mode != null && mode == EvaluationMode.W |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
46 ? access.getWs() |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
47 : access.getQs(); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
48 |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
49 Long officialGaugeNumber = access.getOfficialGaugeNumber(); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
50 |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
51 if (mode == null) { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
52 // TODO: i18n |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
53 addProblem("hist.discharge.mode.not.set"); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
54 } |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
55 if (tr == null) { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
56 // TODO: i18n |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
57 addProblem("hist.discharge.time.interval.not.set"); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
58 } |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
59 if (vs == null || vs.length == 0) { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
60 // TODO: i18n |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
61 addProblem("hist.discharge.values.not.set"); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
62 } |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
63 |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
64 if (officialGaugeNumber == null) { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
65 // TODO: i18n |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
66 addProblem("hist.discharge.reference.gauge.not.set"); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
67 } |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
68 |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
69 if (!hasProblems()) { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
70 set( |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5962
diff
changeset
|
71 mode.getMode(), |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
72 new long [] { tr.getStart(), tr.getEnd()}, |
5918
46e85199b667
Historical discharge curve: Fixed NPE in setup.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5914
diff
changeset
|
73 vs, |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
74 officialGaugeNumber); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
75 } |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
76 } |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
77 |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
78 protected void set( |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
79 int mode, |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
80 long [] timerange, |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
81 double [] values, |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
82 Long officialGaugeNumber |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
83 ) { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
84 this.mode = mode; |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
85 this.timerange = timerange; |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
86 this.values = values; |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
87 this.officialGaugeNumber = officialGaugeNumber; |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
88 } |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
89 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
90 protected CalculationResult error(String msg) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
91 addProblem(msg); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
92 return new CalculationResult(new HistoricalDischargeData(), this); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
93 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
94 |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
95 public CalculationResult calculate() { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
96 if (hasProblems()) { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
97 log.warn("Parameters not valid for calculation."); |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
98 return null; |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
99 } |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
100 |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
101 Gauge gauge = Gauge.getGaugeByOfficialNumber(officialGaugeNumber); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
102 if (gauge == null) { |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
103 // TODO: i18n |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
104 return error("hist.discharge.gauge.not.found"); |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
105 } |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
106 |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
107 if (log.isDebugEnabled()) { |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
108 debug(); |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
109 } |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
110 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
111 List<DischargeTable> dts = fetchDischargeTables(gauge); |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
112 if (dts.isEmpty()) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
113 return error("cannot.find.hist.q.tables"); |
2304
abb390101595
#483 Display error message in calculation report for empty historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2250
diff
changeset
|
114 } |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
115 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
116 DischargeTable refTable = fetchReferenceTable(dts); |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
117 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
118 boolean debug = log.isDebugEnabled(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
119 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
120 if (debug) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
121 log.debug("Take " + dts.size() + " into account."); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
122 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
123 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
124 ValuesCache vc = new ValuesCache(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
125 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
126 WQTimerange [] wqt = prepareData(refTable, dts, vc); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
127 WQKms [] wqs = prepareWQData(dts, vc); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
128 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
129 if (debug) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
130 log.debug("Number of calculation results: " + wqt.length); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
131 } |
2250
40608c82e9cb
Bugfix: create a report facet for historical discharge curves even if no data has been computed.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2244
diff
changeset
|
132 |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
133 return new CalculationResult(new HistoricalDischargeData(wqt, wqs), |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
134 this); |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 } |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
136 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
137 /** The youngest discharge table of the selected set is the reference */ |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
138 protected DischargeTable fetchReferenceTable(List<DischargeTable> dts) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
139 DischargeTable ref = null; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
140 long now = System.currentTimeMillis(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
141 for (DischargeTable dt: dts) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
142 if (ref == null) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
143 ref = dt; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
144 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
145 else { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
146 TimeInterval cti = dt.getTimeInterval(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
147 TimeInterval rti = ref.getTimeInterval(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
148 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
149 long ct = cti.getStopTime() != null |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
150 ? cti.getStopTime().getTime() |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
151 : now; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
152 long rt = rti.getStopTime() != null |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
153 ? rti.getStopTime().getTime() |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
154 : now; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
155 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
156 if (ct > rt) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
157 ref = dt; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
158 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
159 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
160 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
161 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
162 return ref; |
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:
2304
diff
changeset
|
163 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
164 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
165 protected List<DischargeTable> fetchDischargeTables(Gauge gauge) { |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
166 |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
167 List<DischargeTable> all = gauge.getDischargeTables(); |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
168 List<DischargeTable> relevant = new ArrayList<DischargeTable>(all.size()); |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
169 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
170 for (DischargeTable dt: all) { |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
171 if (isDischargeTableRelevant(dt)) { |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
172 relevant.add(dt); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
173 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
174 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
175 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
176 return relevant; |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
177 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
178 |
5339
1b73b731f7bd
Doc, debug fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4281
diff
changeset
|
179 /** True if timerange of given discharge table overlaps with timerange. */ |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
180 protected boolean isDischargeTableRelevant(DischargeTable dt) { |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
181 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
182 TimeInterval ti = dt.getTimeInterval(); |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
183 |
2598
e96bf6c47c12
Improved selecting discharge tables for historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2418
diff
changeset
|
184 if (dt.getKind() == Gauge.MASTER_DISCHARGE_TABLE || ti == null) { |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
185 return false; |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
186 } |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
187 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
188 long dtStart = ti.getStartTime().getTime(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
189 long dtStop = ti.getStopTime() != null |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
190 ? ti.getStopTime().getTime() |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
191 : System.currentTimeMillis(); |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
192 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
193 return !(timerange[1] < dtStart || timerange[0] > dtStop); |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
194 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
195 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
196 protected WQKms[] prepareWQData(List<DischargeTable> dts, ValuesCache vc) { |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
197 WQKms[] wqs = new WQKms[dts.size()]; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
198 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
199 for (int i = 0, N = wqs.length; i < N; ++i) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
200 DischargeTable dt = dts.get(i); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
201 wqs[i] = prepareWQ(dt, vc.getValues(dts.get(i))); |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
202 } |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
203 |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
204 return wqs; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
205 } |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
206 |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
207 protected WQKms prepareWQ(DischargeTable dt, double[][] values) { |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
208 double km = dt.getGauge().getStation().doubleValue(); |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
209 |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
210 double[] kms = new double[values[0].length]; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
211 Arrays.fill(kms, km); |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
212 |
4281
7b6c31390427
Fixed interchanged Ws and Qs in Historical Discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4241
diff
changeset
|
213 return new HistoricalWQKms(kms, values[0], values[1], |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
214 String.valueOf(km), dt.getTimeInterval()); |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
215 } |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
216 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
217 protected String name(double value) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
218 return mode == EvaluationMode.W.getMode() |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
219 ? "W=" + value |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
220 : "Q=" + value; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
221 } |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
222 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
223 /** With reference. */ |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
224 protected HistoricalWQTimerange[] prepareData( |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
225 DischargeTable refTable, |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
226 List<DischargeTable> dts, |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
227 ValuesCache vc |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
228 ) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
229 List<HistoricalWQTimerange> wqts = |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
230 new ArrayList<HistoricalWQTimerange>(values.length); |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
231 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
232 boolean debug = log.isDebugEnabled(); |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
233 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
234 for (double value: values) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
235 if (debug) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
236 log.debug("Prepare data plus diff for value: " + value); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
237 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
238 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
239 double ref = mode == EvaluationMode.W.getMode() |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
240 ? vc.findValueForW(refTable, value) |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
241 : vc.findValueForQ(refTable, value); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
242 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
243 if (Double.isNaN(ref)) { |
6064
9e84e323bdf6
Fixed i18n key
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
244 addProblem("hist.discharge.no.value.in.ref", value); |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
245 continue; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
246 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
247 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
248 String name = name(value); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
249 HistoricalWQTimerange wqt = null; |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
250 |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
251 for (DischargeTable dt : dts) { |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
252 Date[] ti = prepareTimeInterval(dt); |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
253 Timerange t = new Timerange(ti[0], ti[1]); |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
254 double w; |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
255 double q; |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
256 double diff; |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
257 |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
258 if (mode == EvaluationMode.W.getMode()) { |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
259 q = vc.findValueForW(dt, w = value); |
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:
2304
diff
changeset
|
260 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
261 if (Double.isNaN(q)) { |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
262 log.warn("Cannot find Q for W: " + w); |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
263 addProblem("cannot.find.hist.q.for.w", w, ti[0], ti[1]); |
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:
2304
diff
changeset
|
264 continue; |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
265 } |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
266 |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
267 diff = ref - q; |
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:
2304
diff
changeset
|
268 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
269 else { |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
270 w = vc.findValueForQ(dt, q = value); |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
271 |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
272 if (Double.isNaN(w)) { |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
273 log.warn("Cannot find W for Q: " + q); |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
274 addProblem("cannot.find.hist.w.for.q", q, ti[0], ti[1]); |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
275 continue; |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
276 } |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
277 diff = ref - w; |
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:
2304
diff
changeset
|
278 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
279 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
280 if (debug) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
281 log.debug("Q=" + q + " | W=" + w + " | Ref = " + ref); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
282 } |
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:
2304
diff
changeset
|
283 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
284 if (wqt == null) { |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
285 wqt = new HistoricalWQTimerange(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:
2304
diff
changeset
|
286 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
287 |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
288 wqt.add(w, q, diff, 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:
2304
diff
changeset
|
289 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
290 |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
291 if (wqt != null) { |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
292 wqts.add(wqt); |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
293 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
294 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
295 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
296 return (HistoricalWQTimerange[])wqts.toArray( |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
297 new HistoricalWQTimerange[wqts.size()]); |
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:
2304
diff
changeset
|
298 } |
b8df8d1476ba
Compute differences between discharge table values and reference discharge table values in historical discharge curve calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2304
diff
changeset
|
299 |
5339
1b73b731f7bd
Doc, debug fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4281
diff
changeset
|
300 /** Returns discharge table interval as Date[]. */ |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
301 protected Date[] prepareTimeInterval(DischargeTable dt) { |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
302 TimeInterval ti = dt.getTimeInterval(); |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
303 |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
304 Date start = ti.getStartTime(); |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
305 Date end = ti.getStopTime(); |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
306 |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
307 if (end == null) { |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
308 log.warn("TimeInterval has no stop time set!"); |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
309 |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
310 end = new Date(); |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
311 } |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
312 |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
313 return new Date[] { start, end }; |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
314 } |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
315 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
316 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
317 /** Helper to avoid redundant loading of discharge table values. */ |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
318 private static final class ValuesCache { |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
319 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
320 private Map<Integer, double[][]> cache; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
321 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
322 ValuesCache() { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
323 cache = new HashMap<Integer, double [][]>(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
324 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
325 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
326 double [][] getValues(DischargeTable dt) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
327 Integer id = dt.getId(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
328 double [][] vs = cache.get(id); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
329 if (vs == null) { |
6301
20a32dbdbb59
Remove discharge table scaling but add reference system to W
Andre Heinecke <aheinecke@intevation.de>
parents:
6064
diff
changeset
|
330 vs = DischargeTables.loadDischargeTableValues(dt); |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
331 cache.put(id, vs); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
332 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
333 return vs; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
334 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
335 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
336 private static double firstOrNaN(double [] vs) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
337 return vs.length > 0 ? vs[0] : Double.NaN; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
338 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
339 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
340 double findValueForW(DischargeTable dt, double w) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
341 return firstOrNaN(DischargeTables.getQsForW(getValues(dt), w)); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
342 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
343 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
344 double findValueForQ(DischargeTable dt, double q) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
345 return firstOrNaN(DischargeTables.getWsForQ(getValues(dt), q)); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
346 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
347 } // class ValuesCache |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
348 |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
349 /** |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
350 * Writes the parameters used for this calculation to log. |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
351 */ |
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
352 public void debug() { |
5914
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
353 log.debug("========== Calculation6 =========="); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
354 log.debug(" Mode: " + mode); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
355 log.debug(" Timerange: " + timerange[0] + " - " + timerange[1]); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
356 log.debug(" Input values: " + Arrays.toString(values)); |
1058b3436dad
D4E river artifacts: Removed historical discharge calculation from WINFO artifact and use access instead.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
357 log.debug("=================================="); |
2219
4b6e9b377a84
Fetch parameters for 'historical discharge curve' calculation; call Calculation6 with those information and check input parameters.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2215
diff
changeset
|
358 } |
2215
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
359 } |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
360 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |