# HG changeset patch # User Sascha L. Teichmann # Date 1303234641 0 # Node ID b7c8df643dc45741d87094c7b4a59b36cdfab028 # Parent 67b3f54188aacfe0edfb127d8f3a1b5e2409aded Discharge table: we need a getQForW() and not a getWForQ(). flys-artifacts/trunk@1732 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 67b3f54188aa -r b7c8df643dc4 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Apr 19 14:48:28 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Apr 19 17:37:21 2011 +0000 @@ -1,3 +1,11 @@ +2011-04-19 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java: + We need a getQForW() method and not getWForQ() because when + doing a "Wasserstand/Wasserspiegellagen" calculation with given + w values these values need to be translated to q values with + the master discharge table. + 2011-04-19 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java: diff -r 67b3f54188aa -r b7c8df643dc4 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 Tue Apr 19 14:48:28 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/DischargeTables.java Tue Apr 19 17:37:21 2011 +0000 @@ -180,45 +180,41 @@ return values; } - public static boolean getWForQ( + public static double getQForW( double [][] values, - double q, + double w, double [] result ) { - int index = Arrays.binarySearch(values[1], q); + int index = Arrays.binarySearch(values[0], w); if (index >= 0) { - result[0] = values[1][index]; - return true; + return values[0][index]; } index = -index - 1; // insert position - if (index == 0 || index+1 >= values.length) { + if (index < 1 || index >= values.length) { // do not extraploate - return false; + return Double.NaN; } - double q1 = values[index ][0]; - double q2 = values[index+1][0]; - double w1 = values[index ][1]; - double w2 = values[index+1][1]; + double w1 = values[index-1][0]; + double w2 = values[index ][0]; + double q1 = values[index-1][1]; + double q2 = values[index ][1]; - // w1 = m*q1 + b - // w2 = m*q2 + b - // w2 - w1 = m*(q2 - q1) - // m = (w2 - w1)/(q2 - q1) # q2 != q1 - // b = w1 - m*q1 + // q1 = m*w1 + b + // q2 = m*w2 + b + // q2 - q1 = m*(w2 - w1) + // m = (q2 - q1)/(w2 - w1) # w2 != w1 + // b = q1 - m*w1 - if (q1 == q2) { - result[0] = 0.5*(w1 + w2); - } - else { - double m = (w2 - w1)/(q2 - q1); - double b = w1 - m*q1; - result[0] = q*m + b; + if (w1 == w2) { + return 0.5*(q1 + q2); } - return true; + double m = (q2 - q1)/(w2 - w1); + double b = q1 - m*w1; + return w*m + b; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :