Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation2.java @ 3781:8e713e9bb4d7
Defined colors for bed quality themes.
flys-artifacts/trunk@5488 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 17 Sep 2012 09:40:00 +0000 |
parents | c1f445b94d03 |
children |
rev | line source |
---|---|
677
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import java.util.Arrays; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
3265
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2166
diff
changeset
|
7 |
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2166
diff
changeset
|
8 /** ComputedDischargeCurve. */ |
677
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 public class Calculation2 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 extends Calculation |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 { |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 private static Logger logger = Logger.getLogger(Calculation2.class); |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 protected double km; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 public Calculation2() { |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 } |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 public Calculation2(double km) { |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 this.km = km; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 } |
a95f34f1f39a
Added error reporting to 'Abflusskurve' 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:
677
diff
changeset
|
23 public CalculationResult calculate(WstValueTable wst) { |
677
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 logger.debug("Calculation2.calculate"); |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 double [][] wqs = wst.interpolateWQ(km, this); |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 if (wqs == null || wqs[0].length == 0) { |
2166
2898b1ff6013
I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
709
diff
changeset
|
30 addProblem("cannot.compute.discharge.curve"); |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
677
diff
changeset
|
31 return new CalculationResult(new WQKms[0], this); |
677
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 } |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 double [] ws = wqs[0]; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 double [] qs = wqs[1]; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 double [] kms = new double[ws.length]; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 Arrays.fill(kms, km); |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 WQKms wqkms = new WQKms(kms, qs, ws, String.valueOf(km)); |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 if (hasProblems()) { |
3265
c1f445b94d03
Cosmetics, doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
2166
diff
changeset
|
43 logger.debug("found " + numProblems() + " problems."); |
677
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 wqkms.removeNaNs(); |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 } |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
677
diff
changeset
|
47 return new CalculationResult(new WQKms[] { wqkms }, this); |
677
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 } |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |