Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java @ 8131:fae48b3c09d1
Add period to sedimentloaddataresult fraction
Period is the validity of the result. It is either a single
year or a range of years (epoch). As this is only used for
presentation purposes the type is a string so that years
and epochs need not be handled differently.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 25 Aug 2014 19:59:14 +0200 |
parents | bbad52b073a4 |
children | 52504fc2cd58 |
comparison
equal
deleted
inserted
replaced
8130:bbad52b073a4 | 8131:fae48b3c09d1 |
---|---|
254 SedimentDensity sd = getSedimentDensity(); | 254 SedimentDensity sd = getSedimentDensity(); |
255 | 255 |
256 for (int year: years) { | 256 for (int year: years) { |
257 Value.Filter filter = new And(notEpochs) | 257 Value.Filter filter = new And(notEpochs) |
258 .add(new TimeRangeIntersects(year)); | 258 .add(new TimeRangeIntersects(year)); |
259 String period = Integer.toString(year); | |
259 | 260 |
260 for (GrainFraction gf: GRAIN_FRACTIONS) { | 261 for (GrainFraction gf: GRAIN_FRACTIONS) { |
261 double [][] result = sum( | 262 double [][] result = sum( |
262 sld, gf.getGrainFractions(), filter, sum, isKmUp, | 263 sld, gf.getGrainFractions(), filter, sum, isKmUp, |
263 missingFractions); | 264 missingFractions); |
270 } | 271 } |
271 | 272 |
272 transformT2M3(sd, year, result); | 273 transformT2M3(sd, year, result); |
273 | 274 |
274 SedimentLoadDataResult.Fraction sldrf = | 275 SedimentLoadDataResult.Fraction sldrf = |
275 new SedimentLoadDataResult.Fraction(gf.getDescription(), result); | 276 new SedimentLoadDataResult.Fraction(gf.getDescription(), result, period); |
276 | 277 |
277 sldr.addFraction(sldrf); | 278 sldr.addFraction(sldrf); |
278 } | 279 } |
279 } | 280 } |
280 // TODO: Generate messages for missing fractions. | 281 // TODO: Generate messages for missing fractions. |
304 List<double [][]> results = new ArrayList<double [][]>(); | 305 List<double [][]> results = new ArrayList<double [][]>(); |
305 | 306 |
306 int min = Math.min(epoch[0], epoch[1]); | 307 int min = Math.min(epoch[0], epoch[1]); |
307 int max = Math.max(epoch[0], epoch[1]); | 308 int max = Math.max(epoch[0], epoch[1]); |
308 | 309 |
310 String period = Integer.toString(epoch[0]) + " - " + | |
311 Integer.toString(epoch[1]); | |
309 for (int year = min; year <= max; ++year) { | 312 for (int year = min; year <= max; ++year) { |
310 Value.Filter filter = new And(notEpochs) | 313 Value.Filter filter = new And(notEpochs) |
311 .add(new TimeRangeIntersects(year)); | 314 .add(new TimeRangeIntersects(year)); |
312 | 315 |
313 Sum sum = new Sum(); | 316 Sum sum = new Sum(); |
330 } | 333 } |
331 | 334 |
332 double [][] result = average(results); | 335 double [][] result = average(results); |
333 // TODO: Optionally transform units. | 336 // TODO: Optionally transform units. |
334 SedimentLoadDataResult.Fraction sldrf = | 337 SedimentLoadDataResult.Fraction sldrf = |
335 new SedimentLoadDataResult.Fraction("TODO: nice description", result); | 338 new SedimentLoadDataResult.Fraction("TODO: nice description", result, period); |
336 sldr.addFraction(sldrf); | 339 sldr.addFraction(sldrf); |
337 } | 340 } |
338 // TODO: Generate messages for missing fractions. | 341 // TODO: Generate messages for missing fractions. |
339 return new CalculationResult(sldr, this); | 342 return new CalculationResult(sldr, this); |
340 } | 343 } |
358 Value.Filter filter = new And(IsOfficial.INSTANCE) | 361 Value.Filter filter = new And(IsOfficial.INSTANCE) |
359 .add(new TimeRangeIntersects(epoch[0], epoch[1])); | 362 .add(new TimeRangeIntersects(epoch[0], epoch[1])); |
360 | 363 |
361 int year = Math.min(epoch[0], epoch[1]); | 364 int year = Math.min(epoch[0], epoch[1]); |
362 | 365 |
366 String period = Integer.toString(epoch[0]) + " - " + | |
367 Integer.toString(epoch[1]); | |
368 | |
363 Sum sum = new Sum(); | 369 Sum sum = new Sum(); |
364 | 370 |
365 for (GrainFraction gf: GRAIN_FRACTIONS) { | 371 for (GrainFraction gf: GRAIN_FRACTIONS) { |
366 double [][] result = sum( | 372 double [][] result = sum( |
367 sld, gf.getGrainFractions(), filter, sum, isKmUp, | 373 sld, gf.getGrainFractions(), filter, sum, isKmUp, |
373 gf.getDescription()); | 379 gf.getDescription()); |
374 continue; | 380 continue; |
375 } | 381 } |
376 transformT2M3(sd, year, result); | 382 transformT2M3(sd, year, result); |
377 SedimentLoadDataResult.Fraction sldrf = | 383 SedimentLoadDataResult.Fraction sldrf = |
378 new SedimentLoadDataResult.Fraction(gf.getDescription(), result); | 384 new SedimentLoadDataResult.Fraction(gf.getDescription(), result, period); |
379 sldr.addFraction(sldrf); | 385 sldr.addFraction(sldrf); |
380 } | 386 } |
381 } | 387 } |
382 // TODO: Generate messages for missing fractions. | 388 // TODO: Generate messages for missing fractions. |
383 return new CalculationResult(sldr, this); | 389 return new CalculationResult(sldr, this); |