Mercurial > dive4elements > river
changeset 2315:c0dfa36add96
Some bugfixes and improvements in the calculation of historical discharge curves.
flys-artifacts/trunk@3996 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 09 Feb 2012 11:47:25 +0000 |
parents | f4ca234ba214 |
children | 61b32380ffdb |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java |
diffstat | 2 files changed, 45 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Thu Feb 09 11:33:47 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Feb 09 11:47:25 2012 +0000 @@ -1,3 +1,11 @@ +2012-02-09 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/Calculation6.java: Some + bugfixes and improvements: + 1) take only historical discharge tables into account for calculation + 2) use the correct values for computing differences + 3) moved timerange preparation into an own method + 2012-02-09 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/artifacts/states/EnterMultipleLocationsState.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java Thu Feb 09 11:33:47 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java Thu Feb 09 11:47:25 2012 +0000 @@ -108,6 +108,10 @@ protected boolean isDischargeTableRelevant(DischargeTable dt) { TimeInterval ti = dt.getTimeInterval(); + if (dt.getKind() == Gauge.MASTER_DISCHARGE_TABLE) { + return false; + } + Date start = ti.getStartTime(); long startTime = start.getTime(); @@ -146,8 +150,6 @@ List<WQTimerange> wqts = new ArrayList<WQTimerange>(values.length); - boolean debug = logger.isDebugEnabled(); - for (double value: values) { logger.debug("Prepare data for value: " + value); @@ -155,18 +157,8 @@ WQTimerange wqt = null; for (DischargeTable dt: dts) { - TimeInterval ti = dt.getTimeInterval(); - - Date start = ti.getStartTime(); - Date end = ti.getStopTime(); - - if (end == null) { - logger.warn("TimeInterval has no stop time set!"); - - end = new Date(); - } - - Timerange t = new Timerange(ti.getStartTime(),ti.getStopTime()); + Date[] ti = prepareTimeInterval(dt); + Timerange t = new Timerange(ti[0], ti[1]); double w; double q; @@ -176,7 +168,7 @@ if (Double.isNaN(q)) { logger.warn("Cannot find Q for W: " + w); - addProblem("cannot.find.hist.q.for.w", w, start, end); + addProblem("cannot.find.hist.q.for.w", w, ti[0], ti[1]); continue; } } @@ -185,9 +177,7 @@ w = findValueForQ(dt, q); } - if (debug) { - logger.debug("Q=" + q + " | W=" + w); - } + logger.debug("Q=" + q + " | W=" + w); if (wqt == null) { wqt = new WQTimerange(name); @@ -212,8 +202,6 @@ List<HistoricalWQTimerange> wqts = new ArrayList<HistoricalWQTimerange>(values.length); - boolean debug = logger.isDebugEnabled(); - for (double value: values) { logger.debug("Prepare data plus diff for value: " + value); @@ -221,6 +209,7 @@ HistoricalWQTimerange wqt = null; double ref; + double diff; if (refTable != null && mode == MODE_W) { ref = findValueForW(refTable, value); @@ -233,45 +222,37 @@ } for (DischargeTable dt: dts) { - TimeInterval ti = dt.getTimeInterval(); - - Date start = ti.getStartTime(); - Date end = ti.getStopTime(); + Date[] ti = prepareTimeInterval(dt); - if (end == null) { - logger.warn("TimeInterval has no stop time set!"); - - end = new Date(); - } - - Timerange t = new Timerange(ti.getStartTime(),ti.getStopTime()); + Timerange t = new Timerange(ti[0] ,ti[1]); double w; double q; if (mode == MODE_W) { - w = value; - q = findValueForW(dt, w); + w = value; + q = findValueForW(dt, w); if (Double.isNaN(q)) { logger.warn("Cannot find Q for W: " + w); - addProblem("cannot.find.hist.q.for.w", w, start, end); + addProblem("cannot.find.hist.q.for.w", w, ti[0], ti[1]); continue; } + + diff = ref-q; } else { - q = value; - w = findValueForQ(dt, q); + q = value; + w = findValueForQ(dt, q); + diff = ref-w; } - if (debug) { - logger.debug("Q=" + q + " | W=" + w); - } + logger.debug("Q=" + q + " | W=" + w + " | Ref = " + ref); if (wqt == null) { wqt = new HistoricalWQTimerange(name); } - wqt.add(w, q, ref-value, t); + wqt.add(w, q, diff, t); } if (wqt != null) { @@ -284,6 +265,22 @@ } + protected Date[] prepareTimeInterval(DischargeTable dt) { + TimeInterval ti = dt.getTimeInterval(); + + Date start = ti.getStartTime(); + Date end = ti.getStopTime(); + + if (end == null) { + logger.warn("TimeInterval has no stop time set!"); + + end = new Date(); + } + + return new Date[] { start, end }; + } + + protected double findValueForW(DischargeTable dt, double w) { double[][] vs = DischargeTables.loadDischargeTableValues(dt,SCALE,true); return DischargeTables.getQForW(vs, w);