Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 385:478940d06876
Enabled the WINFO artifact to create duration curves - new OutGenerator, added methods for data computation.
flys-artifacts/trunk@1802 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 03 May 2011 12:05:32 +0000 |
parents | 5f55047a17e8 |
children | befedd7629d5 |
comparison
equal
deleted
inserted
replaced
384:88614ddfc1e3 | 385:478940d06876 |
---|---|
18 import de.intevation.artifactdatabase.state.StateEngine; | 18 import de.intevation.artifactdatabase.state.StateEngine; |
19 import de.intevation.artifactdatabase.transition.TransitionEngine; | 19 import de.intevation.artifactdatabase.transition.TransitionEngine; |
20 | 20 |
21 import de.intevation.artifacts.common.utils.XMLUtils; | 21 import de.intevation.artifacts.common.utils.XMLUtils; |
22 | 22 |
23 import de.intevation.flys.model.Gauge; | |
23 import de.intevation.flys.model.River; | 24 import de.intevation.flys.model.River; |
24 | 25 |
25 import de.intevation.flys.artifacts.states.DefaultState; | 26 import de.intevation.flys.artifacts.states.DefaultState; |
26 import de.intevation.flys.artifacts.context.FLYSContext; | 27 import de.intevation.flys.artifacts.context.FLYSContext; |
28 import de.intevation.flys.artifacts.model.MainValuesFactory; | |
29 import de.intevation.flys.artifacts.model.WQDay; | |
27 import de.intevation.flys.artifacts.model.WQKms; | 30 import de.intevation.flys.artifacts.model.WQKms; |
28 import de.intevation.flys.artifacts.model.WstValueTable; | 31 import de.intevation.flys.artifacts.model.WstValueTable; |
29 | 32 |
30 | 33 |
31 /** | 34 /** |
299 } | 302 } |
300 } | 303 } |
301 | 304 |
302 return wqkms; | 305 return wqkms; |
303 } | 306 } |
307 | |
308 | |
309 /** | |
310 * Returns the data that is computed by a duration curve computation. | |
311 * | |
312 * @return the data computed by a duration curve computation. | |
313 */ | |
314 public WQDay getDurationCurveData() | |
315 throws NullPointerException | |
316 { | |
317 logger.debug("WINFOArtifact.getDurationCurveData"); | |
318 | |
319 River r = getRiver(); | |
320 | |
321 if (r == null) { | |
322 throw new NullPointerException("Cannot determine river."); | |
323 } | |
324 | |
325 Gauge g = getGauge(); | |
326 | |
327 if (g == null) { | |
328 throw new NullPointerException("Cannot determine gauge."); | |
329 } | |
330 | |
331 double[] locations = getLocations(); | |
332 | |
333 if (locations == null) { | |
334 throw new NullPointerException("Cannot determine location."); | |
335 } | |
336 | |
337 WstValueTable wst = WstValueTable.getTable(r); | |
338 if (wst == null) { | |
339 throw new NullPointerException("No Wst found for selected river."); | |
340 } | |
341 | |
342 // TODO Introduce a caching mechanism here! | |
343 | |
344 return computeDurationCurveData(g, wst, locations[0]); | |
345 } | |
346 | |
347 | |
348 /** | |
349 * Computes the data used to create duration curves. | |
350 * | |
351 * @param gauge The selected gauge. | |
352 * @param location The selected location. | |
353 * | |
354 * @return the computed data. | |
355 */ | |
356 public static WQDay computeDurationCurveData( | |
357 Gauge gauge, | |
358 WstValueTable wst, | |
359 double location) | |
360 { | |
361 logger.info("WINFOArtifact.computeDurationCurveData"); | |
362 | |
363 Object[] obj = MainValuesFactory.getDurationCurveData(gauge); | |
364 | |
365 int[] days = (int[]) obj[0]; | |
366 double[] qs = (double[]) obj[1]; | |
367 | |
368 double[] interpolatedW = new double[qs.length]; | |
369 interpolatedW = wst.interpolateW(location, qs, interpolatedW); | |
370 | |
371 WQDay wqday = new WQDay(qs.length); | |
372 | |
373 for (int i = 0; i < days.length; i++) { | |
374 wqday.add(days[i], interpolatedW[i], qs[i]); | |
375 } | |
376 | |
377 return wqday; | |
378 } | |
304 } | 379 } |
305 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 380 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |