Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java @ 8057:555dc5a9b282
Sediment load: More on calculating epoch loads.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 18 Jul 2014 16:05:21 +0200 |
parents | cd35b76f1ef8 |
children | 25feef564d09 |
comparison
equal
deleted
inserted
replaced
8056:d86cc6a17b7a | 8057:555dc5a9b282 |
---|---|
183 String unit = access.getUnit(); | 183 String unit = access.getUnit(); |
184 | 184 |
185 int [] years = null; | 185 int [] years = null; |
186 int [][] epochs = null; | 186 int [][] epochs = null; |
187 | 187 |
188 double from = access.getUpperKM(); | 188 double from = access.getLowerKM(); |
189 double to = access.getLowerKM(); | 189 double to = access.getUpperKM(); |
190 | 190 |
191 if (yearEpoch.equals("year")) { | 191 if (yearEpoch.equals("year")) { |
192 years = access.getPeriod(); | 192 years = access.getPeriod(); |
193 } | 193 } |
194 else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) { | 194 else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) { |
234 // TODO: i18n | 234 // TODO: i18n |
235 return error("minfo.sediment.load.unknown.calc.mode"); | 235 return error("minfo.sediment.load.unknown.calc.mode"); |
236 } | 236 } |
237 | 237 |
238 private CalculationResult calculateYears() { | 238 private CalculationResult calculateYears() { |
239 boolean isKmUp = isKmUp(); | |
240 SedimentLoadData sld = | 239 SedimentLoadData sld = |
241 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river); | 240 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river); |
242 if (sld == null) { | 241 if (sld == null) { |
243 // TODO: i18n | 242 // TODO: i18n |
244 return error("minfo.sediment.load.no.data"); | 243 return error("minfo.sediment.load.no.data"); |
245 } | 244 } |
246 | 245 |
246 boolean isKmUp = isKmUp(); | |
247 Set<Integer> missingFractions = new TreeSet<Integer>(); | 247 Set<Integer> missingFractions = new TreeSet<Integer>(); |
248 | 248 |
249 Not notEpochs = new Not(IsEpoch.INSTANCE); | 249 Not notEpochs = new Not(IsEpoch.INSTANCE); |
250 | 250 |
251 Sum sum = new Sum(); | 251 Sum sum = new Sum(); |
265 addProblem("minfo.sediment.load.no.fractions", | 265 addProblem("minfo.sediment.load.no.fractions", |
266 gf.getDescription()); | 266 gf.getDescription()); |
267 continue; | 267 continue; |
268 } | 268 } |
269 // TODO: Generate result data set for calculation. | 269 // TODO: Generate result data set for calculation. |
270 // TODO: Optionally transform units. | |
270 } | 271 } |
271 } | 272 } |
272 // TODO: Generate messages for missing fractions. | 273 // TODO: Generate messages for missing fractions. |
273 | 274 // TODO: Bundle sub results. |
274 return null; | 275 return null; |
275 } | 276 } |
276 | 277 |
277 private CalculationResult calculateEpochs() { | 278 private CalculationResult calculateEpochs() { |
278 // TODO: Implement me! | 279 SedimentLoadData sld = |
280 SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river); | |
281 if (sld == null) { | |
282 // TODO: i18n | |
283 return error("minfo.sediment.load.no.data"); | |
284 } | |
285 | |
286 boolean isKmUp = isKmUp(); | |
287 Set<Integer> missingFractions = new TreeSet<Integer>(); | |
288 | |
289 for (int [] epoch: epochs) { | |
290 Value.Filter filter = new And() | |
291 .add(IsEpoch.INSTANCE) | |
292 .add(new TimeRangeIntersects(epoch[0], epoch[1])); | |
293 | |
294 double scale = 1.0/(Math.max(epoch[0], epoch[1]) - Math.min(epoch[0], epoch[1]) + 1); | |
295 | |
296 Sum sum = new Sum(scale); | |
297 | |
298 for (GrainFraction gf: GRAIN_FRACTIONS) { | |
299 double [][] result = sum( | |
300 sld, gf.getGrainFractions(), filter, sum, isKmUp, | |
301 missingFractions); | |
302 | |
303 if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) { | |
304 // TODO: resolve i18n | |
305 addProblem("minfo.sediment.load.no.fractions", | |
306 gf.getDescription()); | |
307 continue; | |
308 } | |
309 // TODO: Generate result data set for calculation. | |
310 // TODO: Optionally transform units. | |
311 } | |
312 } | |
313 // TODO: Generate messages for missing fractions. | |
314 // TODO: Bundle sub results. | |
279 return null; | 315 return null; |
280 } | 316 } |
281 | 317 |
282 private CalculationResult calculateOffEpochs() { | 318 private CalculationResult calculateOffEpochs() { |
283 // TODO: Implement me! | 319 // TODO: Implement me! |