Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation6.java @ 7300:83bb52fa0c32
(issue1529) Be more tolerant in the fitting.
The invalid value warning is removed because invalid data
is expected there when datapoints are not valid for this KM
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 11 Oct 2013 18:40:33 +0200 |
parents | a56fe3bc6700 |
children | b8f343230eab |
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; |
6839
fe03337c8011
(issue1353) Add river name handling
Andre Heinecke <aheinecke@intevation.de>
parents:
6301
diff
changeset
|
40 private String riverName; |
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
|
41 |
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
|
42 |
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
|
43 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
|
44 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
|
45 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
|
46 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
|
47 ? 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
|
48 : access.getQs(); |
7261
a56fe3bc6700
Refactoring: Let RiverAccess.getRiver return an River.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
6839
diff
changeset
|
49 riverName = access.getRiverName(); |
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
|
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 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
|
52 |
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 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
|
54 // 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
|
55 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
|
56 } |
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 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
|
58 // 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
|
59 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
|
60 } |
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 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
|
62 // 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
|
63 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
|
64 } |
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 |
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 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
|
67 // 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
|
68 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
|
69 } |
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 |
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
|
71 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
|
72 set( |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5962
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 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
|
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 } |
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 |
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 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 ) { |
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.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
|
87 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
|
88 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
|
89 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
|
90 } |
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
|
91 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
92 protected CalculationResult error(String msg) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
93 addProblem(msg); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
94 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
|
95 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
96 |
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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 } |
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
|
102 |
6839
fe03337c8011
(issue1353) Add river name handling
Andre Heinecke <aheinecke@intevation.de>
parents:
6301
diff
changeset
|
103 Gauge gauge = Gauge.getGaugeByOfficialNumber(officialGaugeNumber, |
fe03337c8011
(issue1353) Add river name handling
Andre Heinecke <aheinecke@intevation.de>
parents:
6301
diff
changeset
|
104 riverName); |
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 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
|
106 // TODO: i18n |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
107 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
|
108 } |
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
|
109 |
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
|
110 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
|
111 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
|
112 } |
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
|
113 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
114 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
|
115 if (dts.isEmpty()) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
116 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
|
117 } |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
118 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
119 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
|
120 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
121 boolean debug = log.isDebugEnabled(); |
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 if (debug) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
124 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
|
125 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
126 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
127 ValuesCache vc = new ValuesCache(); |
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 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
|
130 WQKms [] wqs = prepareWQData(dts, vc); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
131 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
132 if (debug) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
133 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
|
134 } |
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
|
135 |
4241
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
136 return new CalculationResult(new HistoricalDischargeData(wqt, wqs), |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
137 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
|
138 } |
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
|
139 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
140 /** 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
|
141 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
|
142 DischargeTable ref = null; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
143 long now = System.currentTimeMillis(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
144 for (DischargeTable dt: dts) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
145 if (ref == null) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
146 ref = dt; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
147 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
148 else { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
149 TimeInterval cti = dt.getTimeInterval(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
150 TimeInterval rti = ref.getTimeInterval(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
151 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
152 long ct = cti.getStopTime() != null |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
153 ? cti.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 long rt = rti.getStopTime() != null |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
156 ? rti.getStopTime().getTime() |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
157 : now; |
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 if (ct > rt) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
160 ref = dt; |
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 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
163 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
164 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
165 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
|
166 } |
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
|
167 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
168 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
|
169 |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
170 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
|
171 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
|
172 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 } |
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 |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
179 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
|
180 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
181 |
5339
1b73b731f7bd
Doc, debug fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4281
diff
changeset
|
182 /** 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
|
183 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
|
184 |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
185 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
|
186 |
2598
e96bf6c47c12
Improved selecting discharge tables for historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2418
diff
changeset
|
187 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
|
188 return false; |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
189 } |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
190 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
191 long dtStart = ti.getStartTime().getTime(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
192 long dtStop = ti.getStopTime() != null |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
193 ? ti.getStopTime().getTime() |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
194 : 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
|
195 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
196 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
|
197 } |
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
198 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
199 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
|
200 WQKms[] wqs = new WQKms[dts.size()]; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
201 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
202 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
|
203 DischargeTable dt = dts.get(i); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
204 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
|
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 return wqs; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
208 } |
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 protected WQKms prepareWQ(DischargeTable dt, double[][] values) { |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
211 double km = dt.getGauge().getStation().doubleValue(); |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
212 |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
213 double[] kms = new double[values[0].length]; |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
214 Arrays.fill(kms, km); |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
215 |
4281
7b6c31390427
Fixed interchanged Ws and Qs in Historical Discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4241
diff
changeset
|
216 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
|
217 String.valueOf(km), dt.getTimeInterval()); |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
218 } |
49cb65d5932d
Improved the historical discharge calculation.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4232
diff
changeset
|
219 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
220 protected String name(double value) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
221 return mode == EvaluationMode.W.getMode() |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
222 ? "W=" + value |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
223 : "Q=" + value; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
224 } |
2228
4db19a88bddb
Implemented the first step of Calculation6; create Facets for each calculation results.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2219
diff
changeset
|
225 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
226 /** With reference. */ |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
227 protected HistoricalWQTimerange[] prepareData( |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
228 DischargeTable refTable, |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
229 List<DischargeTable> dts, |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
230 ValuesCache vc |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
231 ) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
232 List<HistoricalWQTimerange> wqts = |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
233 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
|
234 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
235 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
|
236 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
237 for (double value: values) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
238 if (debug) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
239 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
|
240 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
241 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
242 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
|
243 ? vc.findValueForW(refTable, value) |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
244 : vc.findValueForQ(refTable, value); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
245 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
246 if (Double.isNaN(ref)) { |
6064
9e84e323bdf6
Fixed i18n key
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
247 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
|
248 continue; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
249 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
250 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
251 String name = name(value); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
252 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
|
253 |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
254 for (DischargeTable dt : dts) { |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
255 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
|
256 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
|
257 double w; |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
258 double q; |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
259 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
|
260 |
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
|
261 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
|
262 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
|
263 |
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 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
|
265 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
|
266 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
|
267 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
|
268 } |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
269 |
4232
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
270 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
|
271 } |
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
|
272 else { |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
273 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
|
274 |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
275 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
|
276 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
|
277 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
|
278 continue; |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
279 } |
b3aa91e45010
Implemented the Q evaluation mode for historical discharge calculations.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
4138
diff
changeset
|
280 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
|
281 } |
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
|
282 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
283 if (debug) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
284 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
|
285 } |
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
|
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 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
|
288 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
|
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 |
2315
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
291 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
|
292 } |
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 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
|
295 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
|
296 } |
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
|
297 } |
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 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
299 return (HistoricalWQTimerange[])wqts.toArray( |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
300 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
|
301 } |
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
|
302 |
5339
1b73b731f7bd
Doc, debug fix.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4281
diff
changeset
|
303 /** 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
|
304 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
|
305 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
|
306 |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
307 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
|
308 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
|
309 |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
310 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
|
311 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
|
312 |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
313 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
|
314 } |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
315 |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
316 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
|
317 } |
c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
2311
diff
changeset
|
318 |
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 /** 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
|
321 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
|
322 |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
323 private Map<Integer, double[][]> cache; |
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 ValuesCache() { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
326 cache = new HashMap<Integer, double [][]>(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
327 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
328 |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
329 double [][] getValues(DischargeTable dt) { |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
330 Integer id = dt.getId(); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
331 double [][] vs = cache.get(id); |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
332 if (vs == null) { |
6301
20a32dbdbb59
Remove discharge table scaling but add reference system to W
Andre Heinecke <aheinecke@intevation.de>
parents:
6064
diff
changeset
|
333 vs = DischargeTables.loadDischargeTableValues(dt); |
5962
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
334 cache.put(id, vs); |
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 return vs; |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
337 } |
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 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
|
340 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
|
341 } |
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 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
|
344 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
|
345 } |
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 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
|
348 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
|
349 } |
d861efa13272
Partial rewrite of historical discharge curves. Needs testing.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5959
diff
changeset
|
350 } // 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
|
351 |
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
|
352 /** |
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 * 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
|
354 */ |
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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 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
|
361 } |
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
|
362 } |
ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
363 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |