Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java @ 8713:6b68777aaeab
(issue1448) Remove obsolete code for OfficalEpoch "Calculation"
This is handled through datacage recommendations as this was never
an actual calculation.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Fri, 24 Apr 2015 17:54:12 +0200 |
parents | 73a4c3c202e5 |
children | 8dbb969091c5 |
comparison
equal
deleted
inserted
replaced
8712:582e970115b6 | 8713:6b68777aaeab |
---|---|
20 import org.apache.log4j.Logger; | 20 import org.apache.log4j.Logger; |
21 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Value; | 21 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Value; |
22 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Station; | 22 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Station; |
23 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.And; | 23 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.And; |
24 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsEpoch; | 24 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsEpoch; |
25 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsOfficial; | |
26 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.Not; | 25 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.Not; |
27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.SQTimeInterval; | 26 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.SQTimeInterval; |
28 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.TimeRangeIntersects; | 27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.TimeRangeIntersects; |
29 import org.dive4elements.river.utils.DoubleUtil; | 28 import org.dive4elements.river.utils.DoubleUtil; |
30 | 29 |
176 Integer sqTiId = access.getSQTiId(); | 175 Integer sqTiId = access.getSQTiId(); |
177 | 176 |
178 if (yearEpoch.equals("year")) { | 177 if (yearEpoch.equals("year")) { |
179 years = access.getYears(); | 178 years = access.getYears(); |
180 } | 179 } |
181 else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) { | 180 else if (yearEpoch.equals("epoch")) { |
182 epochs = access.getEpochs(); | 181 epochs = access.getEpochs(); |
183 } | 182 } |
184 else { | 183 else { |
185 addProblem("minfo.missing.year_epoch"); | 184 addProblem("minfo.missing.year_epoch"); |
186 } | 185 } |
215 } | 214 } |
216 | 215 |
217 private CalculationResult internalCalculate() { | 216 private CalculationResult internalCalculate() { |
218 if ("year".equals(yearEpoch)) return calculateYears(); | 217 if ("year".equals(yearEpoch)) return calculateYears(); |
219 if ("epoch".equals(yearEpoch)) return calculateEpochs(); | 218 if ("epoch".equals(yearEpoch)) return calculateEpochs(); |
220 if ("off_epoch".equals(yearEpoch)) return calculateOffEpochs(); | |
221 | 219 |
222 // TODO: i18n | 220 // TODO: i18n |
223 return error("minfo.sedimentload.unknown.calc.mode"); | 221 return error("minfo.sedimentload.unknown.calc.mode"); |
224 } | 222 } |
225 | 223 |
334 ls.getDescription(), period); | 332 ls.getDescription(), period); |
335 } | 333 } |
336 } | 334 } |
337 | 335 |
338 } | 336 } |
339 return new CalculationResult(sldr, this); | |
340 } | |
341 | |
342 private CalculationResult calculateOffEpochs() { | |
343 SedimentLoadData sld = | |
344 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river); | |
345 if (sld == null) { | |
346 return error("minfo.sedimentload.no.data"); | |
347 } | |
348 | |
349 SedimentLoadDataResult sldr = new SedimentLoadDataResult(); | |
350 | |
351 SedimentDensity sd = getSedimentDensity(); | |
352 | |
353 Set<Integer> missingFractions = new TreeSet<Integer>(); | |
354 | |
355 for (int [] epoch: epochs) { | |
356 Value.Filter filter = new And(IsOfficial.INSTANCE) | |
357 .add(new TimeRangeIntersects(epoch[0], epoch[1])); | |
358 | |
359 int year = Math.min(epoch[0], epoch[1]); | |
360 | |
361 String period = Integer.toString(epoch[0]) + " - " + | |
362 Integer.toString(epoch[1]); | |
363 | |
364 Sum sum = new Sum(); | |
365 | |
366 for (LoadSum ls: LOAD_SUMS) { | |
367 double [][] result = sum( | |
368 sld, ls.getGrainFractions(), ls.getStationType(), | |
369 filter, sum); | |
370 | |
371 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) { | |
372 addProblem("sedimentload.missing.fraction." + | |
373 ls.getDescription(), period); | |
374 continue; | |
375 } | |
376 | |
377 transformT2M3(sd, year, result); | |
378 SedimentLoadDataResult.Fraction sldrf = | |
379 new SedimentLoadDataResult.Fraction(ls.getDescription(), result, period); | |
380 sldr.addFraction(sldrf); | |
381 } | |
382 } | |
383 // TODO: Generate messages for missing fractions. | |
384 return new CalculationResult(sldr, this); | 337 return new CalculationResult(sldr, this); |
385 } | 338 } |
386 | 339 |
387 private final boolean inM3() { | 340 private final boolean inM3() { |
388 return unit.equals("m3_per_a"); | 341 return unit.equals("m3_per_a"); |