Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.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 | ce796f1db30e |
children | fa5d5b48028a |
comparison
equal
deleted
inserted
replaced
3021:84a7314244b5 | 3022:705d2058b682 |
---|---|
167 double [] kms = DoubleUtil.explode(from, to, step / 1000.0); | 167 double [] kms = DoubleUtil.explode(from, to, step / 1000.0); |
168 | 168 |
169 final double [] qs = new double[eventColumns.size()]; | 169 final double [] qs = new double[eventColumns.size()]; |
170 final double [] ws = new double[qs.length]; | 170 final double [] ws = new double[qs.length]; |
171 | 171 |
172 // Depending on preprocessing we need to find the outliers. | 172 Fitting.QWFactory qwFactory = new Fitting.QWFactory() { |
173 Fitting.QWFactory qwFactory = !preprocessing | 173 @Override |
174 ? null // No outliers | 174 public QW create(double q, double w) { |
175 : new Fitting.QWFactory() { | 175 // Check all the event columns for close match |
176 @Override | 176 // and take the description and the date from meta. |
177 public QW create(double q, double w) { | 177 for (int i = 0; i < qs.length; ++i) { |
178 // Check all the event columns for close match | 178 if (Math.abs(qs[i]-q) < EPSILON |
179 // and take the description and the date from meta. | 179 && Math.abs(ws[i]-w) < EPSILON) { |
180 for (int i = 0; i < qs.length; ++i) { | 180 Column column = eventColumns.get(i); |
181 if (Math.abs(qs[i]-q) < EPSILON | 181 return new QW( |
182 && Math.abs(ws[i]-w) < EPSILON) { | 182 q, w, |
183 Column column = eventColumns.get(i); | 183 column.getDescription(), |
184 return new QW( | 184 column.getDate()); |
185 q, w, | |
186 column.getDescription(), | |
187 column.getDate()); | |
188 } | |
189 } | 185 } |
190 log.warn("cannot find column for (" + q + ", " + w + ")"); | |
191 return new QW(q, w); | |
192 } | 186 } |
193 }; | 187 log.warn("cannot find column for (" + q + ", " + w + ")"); |
194 | 188 return new QW(q, w); |
195 Fitting fitting = new Fitting(func, qwFactory); | 189 } |
190 }; | |
191 | |
192 Fitting fitting = new Fitting(func, qwFactory, preprocessing); | |
196 | 193 |
197 String [] parameterNames = func.getParameterNames(); | 194 String [] parameterNames = func.getParameterNames(); |
198 | 195 |
199 Parameters results = | 196 Parameters results = |
200 new Parameters(createColumnNames(parameterNames)); | 197 new Parameters(createColumnNames(parameterNames)); |
203 | 200 |
204 if (debug) { | 201 if (debug) { |
205 log.debug("number of kms: " + kms.length); | 202 log.debug("number of kms: " + kms.length); |
206 } | 203 } |
207 | 204 |
208 KMIndex<QW []> outliers = new KMIndex<QW []>(); | 205 KMIndex<QW []> outliers = new KMIndex<QW []>(); |
206 KMIndex<QW []> referenced = new KMIndex<QW []>(kms.length); | |
209 | 207 |
210 int kmIndex = results.columnIndex("km"); | 208 int kmIndex = results.columnIndex("km"); |
211 int chiSqrIndex = results.columnIndex("chi_sqr"); | 209 int chiSqrIndex = results.columnIndex("chi_sqr"); |
212 int [] parameterIndices = results.columnIndices(parameterNames); | 210 int [] parameterIndices = results.columnIndices(parameterNames); |
213 | 211 |
230 // TODO: i18n | 228 // TODO: i18n |
231 addProblem(km, "fix.fitting.failed"); | 229 addProblem(km, "fix.fitting.failed"); |
232 continue; | 230 continue; |
233 } | 231 } |
234 | 232 |
233 referenced.add(km, fitting.referencedToArray()); | |
234 | |
235 if (fitting.hasOutliers()) { | 235 if (fitting.hasOutliers()) { |
236 outliers.add(km, fitting.outliersToArray()); | 236 outliers.add(km, fitting.outliersToArray()); |
237 } | 237 } |
238 | 238 |
239 int row = results.newRow(); | 239 int row = results.newRow(); |
257 | 257 |
258 KMIndex<AnalysisPeriod []> analysisPeriods = | 258 KMIndex<AnalysisPeriod []> analysisPeriods = |
259 calculateAnalysisPeriods(func, results, overview); | 259 calculateAnalysisPeriods(func, results, overview); |
260 | 260 |
261 outliers.sort(); | 261 outliers.sort(); |
262 referenced.sort(); | |
262 analysisPeriods.sort(); | 263 analysisPeriods.sort(); |
263 | 264 |
264 FixResult fr = new FixResult(results, analysisPeriods, outliers); | 265 FixResult fr = new FixResult( |
266 results, | |
267 referenced, outliers, | |
268 analysisPeriods); | |
265 | 269 |
266 return new CalculationResult(fr, this); | 270 return new CalculationResult(fr, this); |
267 } | 271 } |
268 | 272 |
269 | 273 |