Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/ExtremeCalculation.java @ 5565:a44a3f997ec8
Cleanup whitespace. Removed unused variable.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Apr 2013 09:03:34 +0200 |
parents | 5b8919ef601d |
children |
rev | line source |
---|---|
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model.extreme; |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
3 import org.apache.commons.logging.Log; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
4 import org.apache.commons.logging.LogFactory; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
5 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
6 import org.apache.commons.math.MathException; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
7 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
8 import org.apache.commons.math.optimization.fitting.CurveFitter; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
9 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
10 import org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
11 |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.flys.artifacts.access.ExtremeAccess; |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
4355
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
14 import de.intevation.flys.artifacts.math.Linear; |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
15 //import de.intevation.flys.artifacts.math.Utils; |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
16 |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
17 import de.intevation.flys.artifacts.math.fitting.Function; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
18 import de.intevation.flys.artifacts.math.fitting.FunctionFactory; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
19 |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.flys.artifacts.model.Calculation; |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.flys.artifacts.model.CalculationResult; |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
22 import de.intevation.flys.artifacts.model.RangeWithValues; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
23 import de.intevation.flys.artifacts.model.RiverFactory; |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
24 import de.intevation.flys.artifacts.model.WQKms; |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
25 import de.intevation.flys.artifacts.model.WstValueTable; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
26 import de.intevation.flys.artifacts.model.WstValueTableFactory; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
27 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
28 import de.intevation.flys.model.River; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
29 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
30 import de.intevation.flys.utils.DoubleUtil; |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
31 import de.intevation.flys.utils.KMIndex; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
32 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
33 import gnu.trove.TDoubleArrayList; |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
34 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
35 import java.util.List; |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
37 import java.awt.geom.Line2D; |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
38 |
4040
363445873737
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3785
diff
changeset
|
39 /** Calculate extrapolated W. */ |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 public class ExtremeCalculation |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 extends Calculation |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 { |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
43 private static final Log log = |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
44 LogFactory.getLog(ExtremeCalculation.class); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
45 |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
46 protected String river; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
47 protected String function; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
48 protected double from; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
49 protected double to; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
50 protected double step; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
51 protected double percent; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
52 protected List<RangeWithValues> ranges; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
53 |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 public ExtremeCalculation() { |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 } |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 public ExtremeCalculation(ExtremeAccess access) { |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
58 String river = access.getRiver(); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
59 String function = access.getFunction(); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
60 Double from = access.getFrom(); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
61 Double to = access.getTo(); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
62 Double step = access.getStep(); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
63 Double percent = access.getPercent(); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
64 List<RangeWithValues> ranges = access.getRanges(); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
65 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
66 if (river == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
67 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
68 addProblem("extreme.no.river"); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
69 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
70 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
71 if (function == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
72 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
73 addProblem("extreme.no.function"); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
74 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
75 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
76 if (from == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
77 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
78 addProblem("extreme.no.from"); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
79 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
80 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
81 if (to == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
82 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
83 addProblem("extreme.no.to"); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
84 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
85 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
86 if (step == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
87 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
88 addProblem("extreme.no.step"); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
89 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
90 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
91 if (percent == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
92 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
93 addProblem("extreme.no.percent"); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
94 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
95 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
96 if (ranges == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
97 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
98 addProblem("extreme.no.ranges"); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
99 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
100 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
101 if (!hasProblems()) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
102 this.river = river; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
103 this.function = function; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
104 this.from = Math.min(from, to); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
105 this.to = Math.max(from, to); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
106 this.step = Math.max(0.001d, Math.abs(step)/1000d); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
107 this.percent = Math.max(0d, Math.min(100d, percent)); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
108 this.ranges = ranges; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
109 } |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 } |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 |
4059
c63f0b4ac1b4
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4040
diff
changeset
|
112 |
c63f0b4ac1b4
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4040
diff
changeset
|
113 /** Calculate an extreme curve (extrapolate). */ |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 public CalculationResult calculate() { |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
115 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
116 WstValueTable wst = null; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
117 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
118 River river = RiverFactory.getRiver(this.river); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
119 if (river == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
120 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
121 addProblem("extreme.no.such.river", this.river); |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 } |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
123 else { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
124 wst = WstValueTableFactory.getTable(river); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
125 if (wst == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
126 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
127 addProblem("extreme.no.wst.table"); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
128 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
129 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
130 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
131 Function function = |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
132 FunctionFactory.getInstance().getFunction(this.function); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
133 if (function == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
134 // TODO: i18n |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
135 addProblem("extreme.no.such.function", this.function); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
136 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
137 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
138 return hasProblems() |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
139 ? new CalculationResult(this) |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
140 : innerCalculate(wst, function); |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
141 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
142 |
4416
73200f5462fa
ExtremeCalculation: Doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4385
diff
changeset
|
143 |
73200f5462fa
ExtremeCalculation: Doc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4385
diff
changeset
|
144 /** Name of wqkms like W(5000,6000) */ |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
145 protected String wqkmsName(int i) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
146 StringBuilder sb = new StringBuilder("W("); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
147 boolean already = false; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
148 for (RangeWithValues r: ranges) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
149 double [] values = r.getValues(); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
150 if (i < values.length) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
151 if (already) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
152 sb.append(", "); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
153 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
154 else { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
155 already = true; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
156 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
157 // TODO: i18n |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
158 sb.append(values[i]); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
159 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
160 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
161 return sb.append(')').toString(); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
162 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
163 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
164 protected WQKms [] allocWQKms() { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
165 int max = 0; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
166 for (RangeWithValues r: ranges) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
167 double [] values = r.getValues(); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
168 if (values.length > max) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
169 max = values.length; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
170 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
171 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
172 WQKms [] wqkms = new WQKms[max]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
173 for (int i = 0; i < max; ++i) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
174 wqkms[i] = new WQKms(wqkmsName(i)); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
175 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
176 return wqkms; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
177 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
178 |
4059
c63f0b4ac1b4
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4040
diff
changeset
|
179 |
c63f0b4ac1b4
Documentation.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4040
diff
changeset
|
180 /** Calculate an extreme curve (extrapolate). */ |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
181 protected CalculationResult innerCalculate( |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
182 WstValueTable wst, |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
183 Function function |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
184 ) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
185 RangeWithValues range = null; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
186 |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
187 double [] chiSqr = { 0d }; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
188 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
189 KMIndex<Curve> curves = new KMIndex<Curve>(); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
190 WQKms [] wqkms = allocWQKms(); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
191 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
192 boolean debug = log.isDebugEnabled(); |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
193 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
194 from = DoubleUtil.round(from); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
195 to = DoubleUtil.round(to); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
196 |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
197 for (double km = from; km <= to; km = DoubleUtil.round(km+step)) { |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
198 |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
199 if (debug) { |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
200 log.debug("km: " + km); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
201 } |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
202 |
4417
d09dbff54e38
ExtremeCalculation: Resolve probably too nested break.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4416
diff
changeset
|
203 boolean foundRange = false; |
d09dbff54e38
ExtremeCalculation: Resolve probably too nested break.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4416
diff
changeset
|
204 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
205 if (range == null || !range.inside(km)) { |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
206 for (RangeWithValues r: ranges) { |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
207 if (r.inside(km)) { |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
208 range = r; |
4417
d09dbff54e38
ExtremeCalculation: Resolve probably too nested break.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4416
diff
changeset
|
209 foundRange = true; |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
210 break; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
211 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
212 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
213 // TODO: i18n |
4417
d09dbff54e38
ExtremeCalculation: Resolve probably too nested break.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4416
diff
changeset
|
214 if (!foundRange) { |
d09dbff54e38
ExtremeCalculation: Resolve probably too nested break.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4416
diff
changeset
|
215 addProblem(km, "extreme.no.range.inner"); |
d09dbff54e38
ExtremeCalculation: Resolve probably too nested break.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4416
diff
changeset
|
216 continue; |
d09dbff54e38
ExtremeCalculation: Resolve probably too nested break.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4416
diff
changeset
|
217 } |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
218 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
219 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
220 double [][] wqs = wst.interpolateTabulated(km); |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
221 if (wqs == null) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
222 // TODO: i18n |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
223 addProblem(km, "extreme.no.raw.data"); |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
224 continue; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
225 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
226 |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
227 // XXX: This should not be necessary for model data. |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
228 if (!DoubleUtil.isValid(wqs)) { |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
229 // TODO: i18n |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
230 addProblem(km, "extreme.invalid.data"); |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
231 continue; |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
232 } |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
233 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
234 double [][] fitWQs = extractPointsToFit(wqs); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
235 if (fitWQs == null) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
236 // TODO: i18n |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
237 addProblem(km, "extreme.too.less.points"); |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
238 continue; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
239 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
240 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
241 double [] coeffs = doFitting(function, fitWQs, chiSqr); |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
242 if (coeffs == null) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
243 // TODO: i18n |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
244 addProblem(km, "extreme.fitting.failed"); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
245 continue; |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
246 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
247 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
248 Curve curve = new Curve( |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
249 wqs[1], wqs[0], |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
250 function.getName(), |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
251 coeffs, |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
252 chiSqr[0]); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
253 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
254 curves.add(km, curve); |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
255 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
256 double [] values = range.getValues(); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
257 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
258 int V = Math.min(values.length, wqkms.length); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
259 for (int i = 0; i < V; ++i) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
260 double q = values[i]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
261 double w = curve.value(q); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
262 if (Double.isNaN(w)) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
263 // TODO: i18n |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
264 addProblem(km, "extreme.evaluate.failed", values[i]); |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
265 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
266 else { |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
267 wqkms[i].add(w, q, km); |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
268 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
269 } |
3785
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
270 } |
a5f65e8983be
Merged revisions 5501-5502,5504-5508,5511-5513,5516-5519 via svnmerge from
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
3775
diff
changeset
|
271 |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
272 ExtremeResult result = new ExtremeResult(curves, wqkms); |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
273 return new CalculationResult(result, this); |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
274 } |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
275 |
4355
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
276 protected double [] doFitting( |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
277 Function function, |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
278 double [][] wqs, |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
279 double [] chiSqr |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
280 ) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
281 LevenbergMarquardtOptimizer lmo = null; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
282 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
283 double [] coeffs = null; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
284 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
285 double [] ws = wqs[0]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
286 double [] qs = wqs[1]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
287 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
288 for (double tolerance = 1e-10; tolerance < 1e-3; tolerance *= 10d) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
289 lmo = new LevenbergMarquardtOptimizer(); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
290 lmo.setCostRelativeTolerance(tolerance); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
291 lmo.setOrthoTolerance(tolerance); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
292 lmo.setParRelativeTolerance(tolerance); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
293 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
294 CurveFitter cf = new CurveFitter(lmo); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
295 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
296 for (int i = 0; i < ws.length; ++i) { |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
297 cf.addObservedPoint(qs[i], ws[i]); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
298 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
299 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
300 try { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
301 coeffs = cf.fit(function, function.getInitialGuess()); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
302 break; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
303 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
304 catch (MathException me) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
305 if (log.isDebugEnabled()) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
306 log.debug("tolerance " + tolerance + " + failed."); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
307 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
308 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
309 } |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
310 if (coeffs != null) { |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
311 chiSqr[0] = lmo.getChiSquare(); |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
312 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
313 return coeffs; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
314 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
315 |
4355
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
316 protected double [][] extractPointsToFit(double [][] wqs) { |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
317 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
318 double [] ws = wqs[0]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
319 double [] qs = wqs[1]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
320 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
321 int N = Math.min(ws.length, qs.length); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
322 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
323 if (N < 2) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
324 log.warn("Too less points for fitting"); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
325 return null; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
326 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
327 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
328 double q2 = qs[N-1]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
329 double w2 = ws[N-1]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
330 double q1 = qs[N-2]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
331 double w1 = ws[N-2]; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
332 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
333 boolean ascending = w2 > w1; |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
334 |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
335 TDoubleArrayList ows = new TDoubleArrayList(); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
336 TDoubleArrayList oqs = new TDoubleArrayList(); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
337 |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
338 oqs.add(q2); oqs.add(q1); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
339 ows.add(w2); ows.add(w1); |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
340 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
341 int lastDir = -2; |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
342 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
343 for (int i = N-3; i >= 0; --i) { |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
344 double q = qs[i]; |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
345 double w = ws[i]; |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
346 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
347 if ((ascending && w > w1) || (!ascending && w < w1)) { |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
348 break; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
349 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
350 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
351 int dir = Line2D.relativeCCW(q2, w2, q1, w1, q, w); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
352 //int dir = Utils.relativeCCW(q2, w2, q1, w1, q, w); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
353 if (lastDir == -2) { |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
354 lastDir = dir; |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
355 } |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
356 else if (lastDir != dir) { |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
357 break; |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
358 } |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
359 |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
360 oqs.add(q); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
361 ows.add(w); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
362 w2 = w1; |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
363 q2 = q1; |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
364 w1 = w; |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
365 q1 = q; |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
366 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
367 |
4355
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
368 oqs.reverse(); |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
369 ows.reverse(); |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
370 |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
371 boolean debug = log.isDebugEnabled(); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
372 if (debug) { |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
373 log.debug("from table: " + N); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
374 log.debug("after trim: " + oqs.size()); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
375 } |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
376 |
4355
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
377 cutPercent(ows, oqs); |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
378 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
379 if (debug) { |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
380 log.debug("after percent cut: " + oqs.size()); |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
381 } |
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
382 |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
383 return new double [][] { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
384 ows.toNativeArray(), |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
385 oqs.toNativeArray() |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
386 }; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4059
diff
changeset
|
387 } |
4355
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
388 |
4385
10e277c2fe0f
Some fixes to make the calculation work.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4355
diff
changeset
|
389 |
4355
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
390 protected void cutPercent(TDoubleArrayList ws, TDoubleArrayList qs) { |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
391 int N = qs.size(); |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
392 if (percent <= 0d || N == 0) { |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
393 return; |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
394 } |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
395 |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
396 double minQ = qs.getQuick(0); |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
397 double maxQ = qs.getQuick(N-1); |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
398 double factor = Math.min(Math.max(0d, percent/100d), 1d); |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
399 double cutQ = Linear.weight(factor, minQ, maxQ); |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
400 int cutIndex = 0; |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
401 for (; cutIndex < N; ++cutIndex) { |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
402 double q = qs.getQuick(cutIndex); |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
403 if (minQ < maxQ) { |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
404 if (q > cutQ) { |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
405 break; |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
406 } |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
407 } |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
408 else { |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
409 if (q < cutQ) { |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
410 break; |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
411 } |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
412 } |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
413 } |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
414 ws.remove(0, cutIndex); |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
415 qs.remove(0, cutIndex); |
d095b4267772
Added missing percentage cut off in extreme calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4294
diff
changeset
|
416 } |
3775
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
417 } |
d52c4ca93ffb
More infrastructure stuff for the "Auslagerung extremer Wasserspiegellagen".
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
418 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |