Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java @ 3022:705d2058b682
FixA: Store the referenced QW for each km, too.
flys-artifacts/trunk@4589 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 05 Jun 2012 14:56:57 +0000 |
parents | ab81ffd1343e |
children | c489f7e16c28 |
comparison
equal
deleted
inserted
replaced
3021:84a7314244b5 | 3022:705d2058b682 |
---|---|
29 | 29 |
30 QW create(double q, double w); | 30 QW create(double q, double w); |
31 | 31 |
32 } // interface QWFactory | 32 } // interface QWFactory |
33 | 33 |
34 public static final QWFactory QW_FACTORY = new QWFactory() { | |
35 @Override | |
36 public QW create(double q, double w) { | |
37 return new QW(q, w); | |
38 } | |
39 }; | |
40 | |
41 protected boolean checkOutliers; | |
34 protected Function function; | 42 protected Function function; |
35 protected QWFactory qwFactory; | 43 protected QWFactory qwFactory; |
36 protected double chiSqr; | 44 protected double chiSqr; |
37 protected double [] parameters; | 45 protected double [] parameters; |
38 protected ArrayList<QW> removed; | 46 protected ArrayList<QW> removed; |
47 protected QW [] referenced; | |
39 | 48 |
40 | 49 |
41 public Fitting() { | 50 public Fitting() { |
42 removed = new ArrayList<QW>(); | 51 removed = new ArrayList<QW>(); |
43 } | 52 } |
44 | 53 |
45 public Fitting(Function function) { | 54 public Fitting(Function function) { |
55 this(function, QW_FACTORY); | |
56 } | |
57 | |
58 public Fitting(Function function, QWFactory qwFactory) { | |
59 this(function, qwFactory, false); | |
60 } | |
61 | |
62 public Fitting( | |
63 Function function, | |
64 QWFactory qwFactory, | |
65 boolean checkOutliers | |
66 ) { | |
46 this(); | 67 this(); |
47 this.function = function; | 68 this.function = function; |
48 } | 69 this.qwFactory = qwFactory; |
49 | 70 this.checkOutliers = checkOutliers; |
50 public Fitting(Function function, QWFactory qwFactory) { | |
51 this(function); | |
52 this.qwFactory = qwFactory; | |
53 } | 71 } |
54 | 72 |
55 public Function getFunction() { | 73 public Function getFunction() { |
56 return function; | 74 return function; |
57 } | 75 } |
58 | 76 |
59 public void setFunction(Function function) { | 77 public void setFunction(Function function) { |
60 this.function = function; | 78 this.function = function; |
79 } | |
80 | |
81 public boolean getCheckOutliers() { | |
82 return checkOutliers; | |
83 } | |
84 | |
85 public void setCheckOutliers(boolean checkOutliers) { | |
86 this.checkOutliers = checkOutliers; | |
61 } | 87 } |
62 | 88 |
63 public double getChiSquare() { | 89 public double getChiSquare() { |
64 return chiSqr; | 90 return chiSqr; |
65 } | 91 } |
66 | 92 |
67 public void reset() { | 93 public void reset() { |
68 chiSqr = 0.0; | 94 chiSqr = 0.0; |
69 parameters = null; | 95 parameters = null; |
70 removed.clear(); | 96 removed.clear(); |
97 referenced = null; | |
71 } | 98 } |
72 | 99 |
73 public boolean hasOutliers() { | 100 public boolean hasOutliers() { |
74 return !removed.isEmpty(); | 101 return !removed.isEmpty(); |
75 } | 102 } |
78 return removed; | 105 return removed; |
79 } | 106 } |
80 | 107 |
81 public QW [] outliersToArray() { | 108 public QW [] outliersToArray() { |
82 return removed.toArray(new QW[removed.size()]); | 109 return removed.toArray(new QW[removed.size()]); |
110 } | |
111 | |
112 public QW [] referencedToArray() { | |
113 return referenced != null ? (QW [])referenced.clone() : null; | |
83 } | 114 } |
84 | 115 |
85 public double [] getParameters() { | 116 public double [] getParameters() { |
86 return parameters; | 117 return parameters; |
87 } | 118 } |
124 catch (MathException me) { | 155 catch (MathException me) { |
125 log.warn(me); | 156 log.warn(me); |
126 return false; | 157 return false; |
127 } | 158 } |
128 | 159 |
129 if (qwFactory == null) { | 160 if (!checkOutliers) { |
130 break; | 161 break; |
131 } | 162 } |
132 | 163 |
133 inputs.clear(); | 164 inputs.clear(); |
134 | 165 |
160 xs.remove(idx); | 191 xs.remove(idx); |
161 ys.remove(idx); | 192 ys.remove(idx); |
162 } | 193 } |
163 } | 194 } |
164 | 195 |
196 referenced = new QW[xs.size()]; | |
197 for (int i = 0; i < referenced.length; ++i) { | |
198 referenced[i] = qwFactory.create(xs.getQuick(i), ys.getQuick(i)); | |
199 } | |
200 | |
165 chiSqr = lmo.getChiSquare(); | 201 chiSqr = lmo.getChiSquare(); |
166 | 202 |
167 return true; | 203 return true; |
168 } | 204 } |
169 } | 205 } |