Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/extreme/Curve.java @ 4357:11cf29eb002c
FacetTypes: New type: exreme_wq_curve_base (for the Stuetz-Q-Poits).
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 02 Nov 2012 11:58:11 +0100 |
parents | e0add97c432b |
children |
rev | line source |
---|---|
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.model.extreme; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import de.intevation.flys.artifacts.math.Function; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 import de.intevation.flys.artifacts.math.NaNFunction; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import de.intevation.flys.artifacts.math.UnivariateRealFunctionFunction; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 import de.intevation.flys.artifacts.math.fitting.FunctionFactory; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 import java.io.Serializable; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import java.lang.ref.SoftReference; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 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
|
14 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 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
|
16 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import org.apache.log4j.Logger; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
4311
5a28312aee99
Doc for WQFacet and Curve.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4307
diff
changeset
|
19 /** 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
|
20 public class Curve |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 implements Serializable, Function |
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 private static Logger log = Logger.getLogger(Curve.class); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
3737
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
25 protected double [] qs; |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
26 protected double [] ws; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 protected String function; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 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
|
29 protected double chiSqr; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 |
4335
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
31 /** 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
|
32 protected double suggestedMaxQ; |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
33 |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 // 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
|
35 protected transient SoftReference<Function> spline; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 protected transient Function extrapolation; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 public Curve() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 |
3737
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
41 public Curve( |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
42 double [] qs, |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
43 double [] ws, |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
44 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
|
45 double [] coeffs, |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
46 double chiSqr |
3737
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
47 ) { |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
48 this.qs = qs; |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
49 this.ws = ws; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 this.function = function; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 this.coeffs = coeffs; |
4335
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
52 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
|
53 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
3737
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
55 public double [] getQs() { |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
56 return qs; |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
57 } |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
58 |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
59 public double [] getWs() { |
976be312a84c
Simplified code for extreme curves.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3733
diff
changeset
|
60 return ws; |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
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 public String getFunction() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 return function; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 public double [] getCoeffs() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 return coeffs; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 |
4307
2e8e00026059
Curve: Tiny javadoc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4259
diff
changeset
|
71 |
4335
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
72 public void setSuggestedMaxQ(double newMaxQ) { |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
73 this.suggestedMaxQ = newMaxQ; |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
74 } |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
75 |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
76 |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
77 public double getSuggestedMaxQ() { |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
78 return this.suggestedMaxQ; |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
79 } |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
80 |
5948de9788d5
Curve: Added field, getter and setter for suggestedMaxQ .
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4311
diff
changeset
|
81 |
4307
2e8e00026059
Curve: Tiny javadoc.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4259
diff
changeset
|
82 /** 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
|
83 @Override |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 public double value(double x) { |
4354
e0add97c432b
Circumvent NPE in Curve. issue flys/1019
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4335
diff
changeset
|
85 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
|
86 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
|
87 ? getSpline() |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 : getExtrapolation()).value(x); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 protected synchronized Function getExtrapolation() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 if (extrapolation == null) { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 de.intevation.flys.artifacts.math.fitting.Function |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 f = FunctionFactory.getInstance().getFunction(function); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 extrapolation = f != null |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 ? f.instantiate(coeffs) |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 : NaNFunction.INSTANCE; |
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 return extrapolation; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 |
4259
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
103 /** |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
104 * 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
|
105 * |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
106 * @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
|
107 */ |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
108 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
|
109 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
|
110 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
111 |
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 * 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
|
114 * |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
115 * @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
|
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 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
|
118 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
|
119 } |
5cc9453456a7
First complete but untested version of the 'Auslagerung extremer Wasserspiegellagen' calculation.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3742
diff
changeset
|
120 |
3733
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 protected synchronized Function getSpline() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 Function sp; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 if (spline != null) { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 if ((sp = spline.get()) != null) { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 return sp; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 } |
3742
467efea19d15
Added type safety.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3737
diff
changeset
|
128 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
|
129 return sp; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 protected Function createSpline() { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 SplineInterpolator interpolator = new SplineInterpolator(); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 try { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 return new UnivariateRealFunctionFunction( |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 interpolator.interpolate(qs, ws)); |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 catch (MathIllegalArgumentException miae) { |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 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
|
140 return NaNFunction.INSTANCE; |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 } |
893b2477208f
Some first models needed for the extreme waterlevels.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |