Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation2.java @ 921:610d0e0f4f85
#159 Modifications in the transition model to support a state with a kilometer range input only.
flys-artifacts/trunk@2270 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 30 Jun 2011 11:32:17 +0000 |
parents | 3b7e9ddf6bb1 |
children | 2898b1ff6013 |
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 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 public class Calculation2 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 extends Calculation |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 { |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 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
|
11 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 protected double km; |
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 public Calculation2() { |
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 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 public Calculation2(double km) { |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 this.km = km; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 } |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
677
diff
changeset
|
21 public CalculationResult calculate(WstValueTable wst) { |
677
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 logger.debug("Calculation2.calculate"); |
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 double [][] wqs = wst.interpolateWQ(km, this); |
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 if (wqs == null || wqs[0].length == 0) { |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 logger.debug("Cannot compute discharge curve data."); |
709
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
677
diff
changeset
|
29 addProblem("Cannot compute discharge curve data."); |
3b7e9ddf6bb1
New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
677
diff
changeset
|
30 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
|
31 } |
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 double [] ws = wqs[0]; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 double [] qs = wqs[1]; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 double [] kms = new double[ws.length]; |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 Arrays.fill(kms, km); |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 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
|
40 |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 if (hasProblems()) { |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 logger.debug("found + "+numProblems()+" problems."); |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 wqkms.removeNaNs(); |
a95f34f1f39a
Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 } |
a95f34f1f39a
Added error reporting to 'Abflusskurve' 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:
677
diff
changeset
|
46 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
|
47 } |
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |