comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java @ 4798:39885bdfc6fc

Added calculation of the "Umhuellende" to calculation of "W fuer ungleichwertige Abfluesse". This is done by figuring out the WST columns that imfold the data and then do simple "gleichwertige" calculations from the start of the interval. This is too much because only the Qs are needed for the "Umhuellende".
author Sascha L. Teichmann <teichmann@intevation.de>
date Sun, 13 Jan 2013 16:18:28 +0100
parents 22790758b132
children e3532c7850b9
comparison
equal deleted inserted replaced
4797:43e69af28b3c 4798:39885bdfc6fc
9 9
10 import de.intevation.flys.model.River; 10 import de.intevation.flys.model.River;
11 11
12 import de.intevation.flys.utils.DoubleUtil; 12 import de.intevation.flys.utils.DoubleUtil;
13 13
14 import java.util.ArrayList;
14 import java.util.Arrays; 15 import java.util.Arrays;
15 import java.util.List; 16 import java.util.List;
16 17
17 import org.apache.log4j.Logger; 18 import org.apache.log4j.Logger;
18 19
226 // name the curves 227 // name the curves
227 for (int i = 0; i < results.length; ++i) { 228 for (int i = 0; i < results.length; ++i) {
228 results[i].setName(createName(i)); 229 results[i].setName(createName(i));
229 } 230 }
230 231
232 // Generate the "Umhuellende".
233 results = generateInfolding(table, results, from, to, step);
234
231 return new CalculationResult(results, this); 235 return new CalculationResult(results, this);
236 }
237
238 protected WQKms [] generateInfolding(
239 WstValueTable wst,
240 WQKms [] results,
241 double from,
242 double to,
243 double step
244 ) {
245 WstValueTable.Column [] columns = wst.getColumns();
246
247 InfoldingColumns ic = new InfoldingColumns(columns);
248 ic.markInfoldingColumns(results);
249
250 List<WQKms> infoldings = new ArrayList<WQKms>();
251
252 boolean [] infoldingColumns = ic.getInfoldingColumns();
253 for (int i = 0; i < infoldingColumns.length; ++i) {
254 if (infoldingColumns[i]) {
255 continue;
256 }
257 double q = columns[i].getQRangeTree().findQ(from);
258 if (Double.isNaN(q)) {
259 addProblem(from, "cannot.find.q");
260 continue;
261 }
262 double [] kms = DoubleUtil.explode(from, to, step);
263 double [] oqs = new double[kms.length];
264 double [] ows = new double[kms.length];
265 boolean success =
266 wst.interpolate(q, from, kms, ows, oqs, this) != null;
267
268 if (success) {
269 // TODO: generate a better name. I18N.
270 String name = "Umh\u00fcllende " + columns[i].getName();
271 WQKms wqkms = new WQKms(kms, oqs, ows, name);
272 infoldings.add(wqkms);
273 }
274 }
275
276 int N = infoldings.size();
277 if (N > 0) {
278 WQKms [] newResults = new WQKms[results.length + N];
279 System.arraycopy(results, 0, newResults, 0, results.length);
280 for (int i = 0; i < N; ++i) {
281 newResults[i+results.length] = infoldings.get(i);
282 }
283 results = newResults;
284 }
285
286 return results;
232 } 287 }
233 288
234 protected String createName(int index) { 289 protected String createName(int index) {
235 // TODO: i18n 290 // TODO: i18n
236 StringBuilder sb = new StringBuilder(isQ ? "Q" : "W"); 291 StringBuilder sb = new StringBuilder(isQ ? "Q" : "W");

http://dive4elements.wald.intevation.org