comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation2.java @ 3814:8083f6384023

merged flys-artifacts/pre2.6-2012-01-04
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:56 +0200
parents 3b7e9ddf6bb1
children 2898b1ff6013
comparison
equal deleted inserted replaced
1491:2a00f4849738 3814:8083f6384023
1 package de.intevation.flys.artifacts.model;
2
3 import java.util.Arrays;
4
5 import org.apache.log4j.Logger;
6
7 public class Calculation2
8 extends Calculation
9 {
10 private static Logger logger = Logger.getLogger(Calculation2.class);
11
12 protected double km;
13
14 public Calculation2() {
15 }
16
17 public Calculation2(double km) {
18 this.km = km;
19 }
20
21 public CalculationResult calculate(WstValueTable wst) {
22
23 logger.debug("Calculation2.calculate");
24
25 double [][] wqs = wst.interpolateWQ(km, this);
26
27 if (wqs == null || wqs[0].length == 0) {
28 logger.debug("Cannot compute discharge curve data.");
29 addProblem("Cannot compute discharge curve data.");
30 return new CalculationResult(new WQKms[0], this);
31 }
32
33 double [] ws = wqs[0];
34 double [] qs = wqs[1];
35 double [] kms = new double[ws.length];
36
37 Arrays.fill(kms, km);
38
39 WQKms wqkms = new WQKms(kms, qs, ws, String.valueOf(km));
40
41 if (hasProblems()) {
42 logger.debug("found + "+numProblems()+" problems.");
43 wqkms.removeNaNs();
44 }
45
46 return new CalculationResult(new WQKms[] { wqkms }, this);
47 }
48 }
49 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org