comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/Calculation3.java @ 9534:b380a5693514

Calculation of Dauerlinie corrected in WInfo (fix wst position according to a reference gauge, km specific discharge instead of that of the gauge); using same calculation in SInfo flood duration
author mschaefer
date Thu, 11 Oct 2018 18:39:21 +0200
parents e4606eae8ea5
children
comparison
equal deleted inserted replaced
9533:d9fda7af24ca 9534:b380a5693514
7 */ 7 */
8 8
9 package org.dive4elements.river.artifacts.model; 9 package org.dive4elements.river.artifacts.model;
10 10
11 import org.apache.log4j.Logger; 11 import org.apache.log4j.Logger;
12 import org.dive4elements.river.artifacts.model.WstValueTable.QPosition;
12 13
14 /**
15 * Duration curve calculation of a km based on the duration curve of a gauge
16 */
13 public class Calculation3 17 public class Calculation3
14 extends Calculation 18 extends Calculation
15 { 19 {
16 private static Logger log = Logger.getLogger(Calculation3.class); 20 private static Logger log = Logger.getLogger(Calculation3.class);
17 21
18 protected double km; 22 protected double km;
19 protected int [] days; 23 protected int [] days;
20 protected double [] qs; 24 protected double [] qs;
25 private double gaugeKm;
21 26
22 public Calculation3() { 27 public Calculation3() {
23 } 28 }
24 29
25 public Calculation3(double km, int [] days, double [] qs) { 30 public Calculation3(final double km, final int[] days, final double[] qs, final double gaugeKm) {
26 this.km = km; 31 this.km = km;
27 this.days = days; 32 this.days = days;
28 this.qs = qs; 33 this.qs = qs;
34 this.gaugeKm = gaugeKm;
29 } 35 }
30 36
31 public CalculationResult calculate(WstValueTable wst) { 37 /**
38 * Calculates the W and Q duration curve of the active km
39 */
40 public CalculationResult calculate(final WstValueTable wst) {
32 41
33 double [] ws = wst.interpolateW(km, qs, new double[qs.length], this); 42 if (this.days == null || this.days.length == 0) {
43 addProblem(this.km, "cannot.find.ds");
44 }
34 45
35 if (days == null || days.length == 0) { 46 final double[] ws = new double[this.days.length];
36 addProblem(km, "cannot.find.ds"); 47 final double[] kmqs = new double[this.days.length];
48 for (int i = 0; i <= this.days.length - 1; i++) {
49 final QPosition qpos = wst.getQPosition(this.gaugeKm, this.qs[i]);
50 if (qpos != null) {
51 ws[i] = wst.interpolateW(this.km, qpos);
52 kmqs[i] = wst.getQ(qpos, this.km);
53 }
54 else {
55 addProblem(this.km, "cannot.find.q", this.qs[i]);
56 ws[i] = Double.NaN;
57 }
37 } 58 }
38 59
39 if (log.isDebugEnabled()) { 60 if (log.isDebugEnabled()) {
40 log.debug("Calculate duration curve data:"); 61 log.debug("Calculate duration curve data:");
41 log.debug(" km : " + km); 62 log.debug(" km : " + this.km);
42 log.debug(" num Days : " + (days != null ? days.length : 0)); 63 log.debug(" num Days : " + (this.days != null ? this.days.length : 0));
43 log.debug(" num Qs : " + (qs != null ? qs.length : 0)); 64 log.debug(" num Qs : " + (this.qs != null ? this.qs.length : 0));
44 log.debug(" result Ws: " + (ws != null ? ws.length : 0)); 65 log.debug(" result Ws: " + (ws != null ? ws.length : 0));
45 } 66 }
46 67
47 WQDay wqday = new WQDay(days, ws, qs); 68 final WQDay wqday = new WQDay(this.days, ws, kmqs);
48 69
49 if (hasProblems()) { 70 if (hasProblems()) {
50 log.debug("calculation caused "+numProblems()+" problem(s)."); 71 log.debug("calculation caused "+numProblems()+" problem(s).");
51 wqday.removeNaNs(); 72 wqday.removeNaNs();
52 } 73 }

http://dive4elements.wald.intevation.org