# HG changeset patch # User Ingo Weinzierl # Date 1350309920 -7200 # Node ID 1d9c9a3493eae888240b039f25ad7de4a36e60d3 # Parent b6ba9bbb51225b133e6c1fe3222435bae81e3dea #904 Use the correct scale to convert discharge table values into [cm]. diff -r b6ba9bbb5122 -r 1d9c9a3493ea flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Mon Oct 15 14:52:57 2012 +0200 +++ b/flys-artifacts/ChangeLog Mon Oct 15 16:05:20 2012 +0200 @@ -1,3 +1,14 @@ +2012-10-15 Ingo Weinzierl + + flys/issue904 + + * src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java: + Defined two constants for converting discharge table values into [cm]. + + * src/main/java/de/intevation/flys/artifacts/model/Calculation6.java: + Use the new constants for value conversion for master discharge table + and historical discharge tables. + 2012-10-15 Ingo Weinzierl flys/issue548 diff -r b6ba9bbb5122 -r 1d9c9a3493ea flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java Mon Oct 15 14:52:57 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java Mon Oct 15 16:05:20 2012 +0200 @@ -164,7 +164,7 @@ if (mode == MODE_W) { w = value; - q = findValueForW(dt, w); + q = findValueForW(dt, w, DischargeTables.HISTORICAL_SCALE); if (Double.isNaN(q)) { logger.warn("Cannot find Q for W: " + w); @@ -212,7 +212,7 @@ double diff; if (refTable != null && mode == MODE_W) { - ref = findValueForW(refTable, value); + ref = findValueForW(refTable, value, DischargeTables.MASTER_SCALE); } else if (refTable != null) { ref = findValueForQ(refTable, value); @@ -230,7 +230,7 @@ if (mode == MODE_W) { w = value; - q = findValueForW(dt, w); + q = findValueForW(dt, w, DischargeTables.HISTORICAL_SCALE); if (Double.isNaN(q)) { logger.warn("Cannot find Q for W: " + w); @@ -281,8 +281,8 @@ } - protected double findValueForW(DischargeTable dt, double w) { - double[][] vs = DischargeTables.loadDischargeTableValues(dt, SCALE); + protected double findValueForW(DischargeTable dt, double w, double scale) { + double[][] vs = DischargeTables.loadDischargeTableValues(dt, scale); double [] qs = DischargeTables.getQsForW(vs, w); return qs.length == 0 ? Double.NaN : qs[0]; } diff -r b6ba9bbb5122 -r 1d9c9a3493ea flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java Mon Oct 15 14:52:57 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java Mon Oct 15 16:05:20 2012 +0200 @@ -26,7 +26,11 @@ /** Private logger. */ private static Logger log = Logger.getLogger(DischargeTables.class); - public static final double DEFAULT_SCALE = 100.0; + /** Scale to convert discharge table values of master table into [cm] */ + public static final double MASTER_SCALE = 100d; + + /** Scale to convert discharge table values of historical tables into [cm] */ + public static final double HISTORICAL_SCALE = 1d; public static final int MASTER = 0; @@ -71,7 +75,7 @@ } public double [][] getFirstTable() { - return getFirstTable(DEFAULT_SCALE); + return getFirstTable(MASTER_SCALE); } public double [][] getFirstTable(double scale) { @@ -83,7 +87,7 @@ } public Map getValues() { - return getValues(DEFAULT_SCALE); + return getValues(MASTER_SCALE); } public Map getValues(double scale) {