Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation3.java @ 3405:b0ba96bbf01d
Use Integer.parseInt() instead of Integer.valueOf() + Autounboxing.
flys-artifacts/trunk@5057 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 19 Jul 2012 09:37:52 +0000 |
parents | 2898b1ff6013 |
children |
rev | line source |
---|---|
676
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 public class Calculation3 |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 extends Calculation |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 { |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 private static Logger logger = Logger.getLogger(Calculation3.class); |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 protected double km; |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 protected int [] days; |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 protected double [] qs; |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 public Calculation3() { |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 } |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 public Calculation3(double km, int [] days, double [] qs) { |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 this.km = km; |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 this.days = days; |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 this.qs = qs; |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 } |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
676
diff
changeset
|
23 public CalculationResult calculate(WstValueTable wst) { |
676
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 double [] ws = wst.interpolateW(km, qs, new double[qs.length], this); |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
1669
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
27 if (days == null || days.length == 0) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1669
diff
changeset
|
28 addProblem(km, "cannot.find.ds"); |
1669
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
29 } |
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
30 |
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
31 if (logger.isDebugEnabled()) { |
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
32 logger.debug("Calculate duration curve data:"); |
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
33 logger.debug(" km : " + km); |
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
34 logger.debug(" num Days : " + (days != null ? days.length : 0)); |
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
35 logger.debug(" num Qs : " + (qs != null ? qs.length : 0)); |
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
36 logger.debug(" result Ws: " + (ws != null ? ws.length : 0)); |
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
37 } |
0296684a5553
Bugfix: #330 Add problem if no data was found for duration curves.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
709
diff
changeset
|
38 |
676
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 WQDay wqday = new WQDay(days, ws, qs); |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 if (hasProblems()) { |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 logger.debug("calculation caused "+numProblems()+" problem(s)."); |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 wqday.removeNaNs(); |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
676
diff
changeset
|
46 return new CalculationResult(wqday, this); |
676
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 } |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
c501f27c1f71
Added error reporting to 'Dauerzahlen' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |