Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/extreme/Curve.java @ 9801:1d7a72a50183 3.2.x tip
Assume Compose V2, consistently
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 23 Nov 2023 10:14:13 +0100 |
parents | 0a5239a1e46e |
children |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4354
diff
changeset
|
9 package org.dive4elements.river.artifacts.model.extreme; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4354
diff
changeset
|
11 import org.dive4elements.river.artifacts.math.Function; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4354
diff
changeset
|
12 import org.dive4elements.river.artifacts.math.NaNFunction; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4354
diff
changeset
|
13 import org.dive4elements.river.artifacts.math.UnivariateRealFunctionFunction; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4354
diff
changeset
|
15 import org.dive4elements.river.artifacts.math.fitting.FunctionFactory; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import java.io.Serializable; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import java.lang.ref.SoftReference; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 import org.apache.commons.math.analysis.interpolation.SplineInterpolator; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 import org.apache.commons.math.exception.MathIllegalArgumentException; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
9726 | 25 import org.apache.logging.log4j.Logger; |
26 import org.apache.logging.log4j.LogManager; | |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 |
4311
5a28312aee99
Doc for WQFacet and Curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4307
diff
changeset
|
28 /** An extrapolating W/Q function/curve. */ |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 public class Curve |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 implements Serializable, Function |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 { |
9726 | 32 private static Logger log = LogManager.getLogger(Curve.class); |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
3737
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
34 protected double [] qs; |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
35 protected double [] ws; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 protected String function; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 protected double [] coeffs; |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
38 protected double chiSqr; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
4335
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
40 /** Suggested maximum value for q to input. */ |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
41 protected double suggestedMaxQ; |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
42 |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 // The spline is pretty heavy weight so cache it with a soft ref only. |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 protected transient SoftReference<Function> spline; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 protected transient Function extrapolation; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 public Curve() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 |
3737
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
50 public Curve( |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
51 double [] qs, |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
52 double [] ws, |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
53 String function, |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
54 double [] coeffs, |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
55 double chiSqr |
3737
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
56 ) { |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
57 this.qs = qs; |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
58 this.ws = ws; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 this.function = function; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 this.coeffs = coeffs; |
4335
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
61 this.suggestedMaxQ = Double.MAX_VALUE; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
3737
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
64 public double [] getQs() { |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
65 return qs; |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
66 } |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
67 |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
68 public double [] getWs() { |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
69 return ws; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 public String getFunction() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 return function; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 public double [] getCoeffs() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 return coeffs; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 |
4307
2e8e00026059
Curve: Tiny javadoc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4259
diff
changeset
|
80 |
4335
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
81 public void setSuggestedMaxQ(double newMaxQ) { |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
82 this.suggestedMaxQ = newMaxQ; |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
83 } |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
84 |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
85 |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
86 public double getSuggestedMaxQ() { |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
87 return this.suggestedMaxQ; |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
88 } |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
89 |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
90 |
4307
2e8e00026059
Curve: Tiny javadoc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4259
diff
changeset
|
91 /** Calculate value at given x. */ |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 @Override |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 public double value(double x) { |
4354
e0add97c432b
Circumvent NPE in Curve. issue flys/1019
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4335
diff
changeset
|
94 if (qs == null || x < qs[0]) return Double.NaN; |
3737
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
95 return (x <= qs[qs.length-1] |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 ? getSpline() |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 : getExtrapolation()).value(x); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 protected synchronized Function getExtrapolation() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 if (extrapolation == null) { |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4354
diff
changeset
|
102 org.dive4elements.river.artifacts.math.fitting.Function |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
103 f = FunctionFactory.getInstance().getFunction(function); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 extrapolation = f != null |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 ? f.instantiate(coeffs) |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 : NaNFunction.INSTANCE; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 return extrapolation; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
112 /** |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
113 * Gets the chiSqr for this instance. |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
114 * |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
115 * @return The chiSqr. |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
116 */ |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
117 public double getChiSqr() { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
118 return this.chiSqr; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
119 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
120 |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
121 /** |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
122 * Sets the chiSqr for this instance. |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
123 * |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
124 * @param chiSqr The chiSqr. |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
125 */ |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
126 public void setChiSqr(double chiSqr) { |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
127 this.chiSqr = chiSqr; |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
128 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
129 |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 protected synchronized Function getSpline() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 Function sp; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 if (spline != null) { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 if ((sp = spline.get()) != null) { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 return sp; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 } |
3742
467efea19d15
Added type safety.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3737
diff
changeset
|
137 spline = new SoftReference<Function>(sp = createSpline()); |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 return sp; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 protected Function createSpline() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 SplineInterpolator interpolator = new SplineInterpolator(); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 try { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 return new UnivariateRealFunctionFunction( |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 interpolator.interpolate(qs, ws)); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 catch (MathIllegalArgumentException miae) { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 log.debug("creation on spline failed", miae); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
149 return NaNFunction.INSTANCE; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
152 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
153 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |