Mercurial > dive4elements > river
changeset 3736:da1969b05292
WST tables: Added interpolation of tabulated values only.
flys-artifacts/trunk@5411 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 09 Sep 2012 15:29:06 +0000 |
parents | f48396deca91 |
children | 976be312a84c |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/Linear.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java |
diffstat | 3 files changed, 54 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Sun Sep 09 13:07:06 2012 +0000 +++ b/flys-artifacts/ChangeLog Sun Sep 09 15:29:06 2012 +0000 @@ -1,3 +1,12 @@ +2012-09-09 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/math/Linear.java: + Added a vectorwise weighting. + + src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java: + Added methods to interpolate tabulated values only. + Need in "Auslagerung extremer Wasserspiegellagen". + 2012-09-09 Christian Lins <christian.lins@intevation.de> * doc/conf/second-themes.xml,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/Linear.java Sun Sep 09 13:07:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/math/Linear.java Sun Sep 09 15:29:06 2012 +0000 @@ -64,5 +64,15 @@ //return (1.0-factor)*a + factor*b; return a + factor*(b-a); } + + public static final void weight( + double factor, + double [] a, double [] b, double [] c + ) { + int N = Math.min(Math.min(a.length, b.length), c.length); + for (int i = 0; i < N; ++i) { + c[i] = weight(factor, a[i], b[i]); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Sun Sep 09 13:07:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WstValueTable.java Sun Sep 09 15:29:06 2012 +0000 @@ -1217,5 +1217,40 @@ double q2 = columns[index ].getQRangeTree().findQ(km); return Linear.weight(weight, q1, q2); } + + public double [][] interpolateTabulated(double km) { + return interpolateTabulated(km, new double[2][columns.length]); + } + + public double [][] interpolateTabulated(double km, double [][] result) { + + int rowIndex = Collections.binarySearch(rows, new Row(km)); + + if (rowIndex >= 0) { + // Direct hit -> copy ws. + Row row = rows.get(rowIndex); + System.arraycopy( + row.ws, 0, result[0], 0, + Math.min(row.ws.length, result[0].length)); + } + else { + rowIndex = -rowIndex -1; + if (rowIndex < 1 || rowIndex >= rows.size()) { + // Out of bounds. + return null; + } + // Interpolate ws. + Row r1 = rows.get(rowIndex-1); + Row r2 = rows.get(rowIndex); + double factor = Linear.factor(km, r1.km, r2.km); + Linear.weight(factor, r1.ws, r2.ws, result[0]); + } + + double [] qs = result[1]; + for (int i = Math.min(qs.length, columns.length)-1; i >= 0; --i) { + qs[i] = columns[i].getQRangeTree().findQ(km); + } + return result; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :