annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation2.java @ 2257:86685feb5b1c

Adjusted to name change in River class (hibernate fix). flys-artifacts/trunk@3912 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 06 Feb 2012 07:39:59 +0000
parents 2898b1ff6013
children c1f445b94d03
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) {
2166
2898b1ff6013 I18N for WINFO calculation result messages.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
28 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
29 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
30 }
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 double [] ws = wqs[0];
a95f34f1f39a Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 double [] qs = wqs[1];
a95f34f1f39a Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 double [] kms = new double[ws.length];
a95f34f1f39a Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
a95f34f1f39a Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 Arrays.fill(kms, km);
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 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
39
a95f34f1f39a Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 if (hasProblems()) {
a95f34f1f39a Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 logger.debug("found + "+numProblems()+" problems.");
a95f34f1f39a Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 wqkms.removeNaNs();
a95f34f1f39a Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 }
a95f34f1f39a Added error reporting to 'Abflusskurve' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 677
diff changeset
45 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
46 }
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 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org