Mercurial > dive4elements > river
changeset 744:b385577bcaca
WQ: Added a method to guess is increasing.
flys-artifacts/trunk@2246 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 27 Jun 2011 09:17:41 +0000 |
parents | e95e6df97e55 |
children | f959faaa7c4a |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java |
diffstat | 2 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Mon Jun 27 07:45:32 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon Jun 27 09:17:41 2011 +0000 @@ -1,3 +1,11 @@ +2011-06-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/model/WQ.java(guessWaterIncreasing): + Added a method to guess based on a given factor of the size (default 0.05) + if the water levels are increasing. Needed to determine in which direction + the water level curve should be orientated. Based on random to avoid + running over large dataset each time a diagram is generated. + 2011-06-27 Ingo Weinzierl <ingo@intevation.de> flys/issue177 (WINFO: Abflusskurven am Pegel verursachen ein Hängen des Servers)
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java Mon Jun 27 07:45:32 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WQ.java Mon Jun 27 09:17:41 2011 +0000 @@ -2,6 +2,8 @@ import gnu.trove.TDoubleArrayList; +import java.util.Random; + public class WQ extends NamedObject { @@ -103,5 +105,29 @@ public void removeNaNs() { removeNaNs(new TDoubleArrayList [] { w, q }); } + + public boolean guessWaterIncreasing() { + return guessWaterIncreasing(0.05f); + } + + public boolean guessWaterIncreasing(float factor) { + + int N = w.size(); + int samples = (int)(factor*N) + 1; + + int up = 0; + + Random rand = new Random(); + + for (int i = 0; i < samples; ++i) { + int pos = rand.nextInt(N-1) + 1; + double w1 = w.getQuick(pos-1); + double w2 = w.getQuick(pos); + if (w2 > w1) ++up; + } + + return up > samples/2; + } + } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :