annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation1.java @ 1078:048517d67215

Changed state spawning mechanism of MainValuesArtifact. flys-artifacts/trunk@2575 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 25 Aug 2011 10:38:45 +0000
parents c09c9e05ecfa
children
rev   line source
678
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.model;
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import org.apache.log4j.Logger;
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 public class Calculation1
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 extends Calculation
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 {
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 private static Logger logger = Logger.getLogger(Calculation1.class);
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 protected double [] kms;
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13 protected double [] qs;
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 protected double [] ws;
708
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 678
diff changeset
15 protected double refKm;
678
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 public Calculation1() {
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 }
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 public Calculation1(
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 738
diff changeset
21 double [] kms,
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 738
diff changeset
22 double [] qs,
678
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 double [] ws,
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
24 double refKm
678
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 ) {
708
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 678
diff changeset
26 this.kms = kms;
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 678
diff changeset
27 this.qs = qs;
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 678
diff changeset
28 this.ws = ws;
757ff56b43b3 Added calculation "am Pegel" version to the "Wasserspiegellage" calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 678
diff changeset
29 this.refKm = refKm;
678
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 }
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
32 public CalculationResult calculate(WstValueTable wst) {
678
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 ArrayList<WQKms> results = new ArrayList<WQKms>();
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 String prefix;
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 double [] origData;
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 if (ws != null) { prefix = "W="; origData = ws; }
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 else { prefix = "Q="; origData = qs; }
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 int oldNumProblems = numProblems();
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 for (int i = 0; i < qs.length; i++) {
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 double [] oqs = new double[kms.length];
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 double [] ows = new double[kms.length];
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 boolean success =
738
5abdb2fa8eb1 Fix for flys/issue147
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 709
diff changeset
50 wst.interpolate(qs[i], refKm, kms, ows, oqs, this) != null;
678
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 int newNumProblems = numProblems();
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 if (success) {
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 WQKms result = new WQKms(kms, oqs, ows, prefix + origData[i]);
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 if (oldNumProblems != newNumProblems) {
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 logger.debug(
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 738
diff changeset
58 qs[i] + " caused " + (newNumProblems-oldNumProblems) +
678
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 " new problem(s).");
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 result.removeNaNs();
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 }
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 results.add(result);
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 }
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 oldNumProblems = newNumProblems;
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 }
742
c09c9e05ecfa Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 738
diff changeset
67
709
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
68 return new CalculationResult(
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
69 results.toArray(new WQKms[results.size()]),
3b7e9ddf6bb1 New model to transport data and error reports of calculations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 708
diff changeset
70 this);
678
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 }
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 }
19a3185822a4 Added error reporting to 'Wasserspiegellage' calculation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org