[PATCH] Sediment load: More on calculating epoch loads
Wald Commits
scm-commit at wald.intevation.org
Fri Jul 18 16:05:24 CEST 2014
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1405692321 -7200
# Node ID 555dc5a9b28291447f0c0051375249b0b284b096
# Parent d86cc6a17b7aa2e81d4cde6c337950a4f137b18c
Sediment load: More on calculating epoch loads.
diff -r d86cc6a17b7a -r 555dc5a9b282 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Fri Jul 18 15:37:26 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java Fri Jul 18 16:05:21 2014 +0200
@@ -185,8 +185,8 @@
int [] years = null;
int [][] epochs = null;
- double from = access.getUpperKM();
- double to = access.getLowerKM();
+ double from = access.getLowerKM();
+ double to = access.getUpperKM();
if (yearEpoch.equals("year")) {
years = access.getPeriod();
@@ -236,7 +236,6 @@
}
private CalculationResult calculateYears() {
- boolean isKmUp = isKmUp();
SedimentLoadData sld =
SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river);
if (sld == null) {
@@ -244,6 +243,7 @@
return error("minfo.sediment.load.no.data");
}
+ boolean isKmUp = isKmUp();
Set<Integer> missingFractions = new TreeSet<Integer>();
Not notEpochs = new Not(IsEpoch.INSTANCE);
@@ -267,15 +267,51 @@
continue;
}
// TODO: Generate result data set for calculation.
+ // TODO: Optionally transform units.
}
}
// TODO: Generate messages for missing fractions.
-
+ // TODO: Bundle sub results.
return null;
}
private CalculationResult calculateEpochs() {
- // TODO: Implement me!
+ SedimentLoadData sld =
+ SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river);
+ if (sld == null) {
+ // TODO: i18n
+ return error("minfo.sediment.load.no.data");
+ }
+
+ boolean isKmUp = isKmUp();
+ Set<Integer> missingFractions = new TreeSet<Integer>();
+
+ for (int [] epoch: epochs) {
+ Value.Filter filter = new And()
+ .add(IsEpoch.INSTANCE)
+ .add(new TimeRangeIntersects(epoch[0], epoch[1]));
+
+ double scale = 1.0/(Math.max(epoch[0], epoch[1]) - Math.min(epoch[0], epoch[1]) + 1);
+
+ Sum sum = new Sum(scale);
+
+ for (GrainFraction gf: GRAIN_FRACTIONS) {
+ double [][] result = sum(
+ sld, gf.getGrainFractions(), filter, sum, isKmUp,
+ missingFractions);
+
+ if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
+ // TODO: resolve i18n
+ addProblem("minfo.sediment.load.no.fractions",
+ gf.getDescription());
+ continue;
+ }
+ // TODO: Generate result data set for calculation.
+ // TODO: Optionally transform units.
+ }
+ }
+ // TODO: Generate messages for missing fractions.
+ // TODO: Bundle sub results.
return null;
}
More information about the Dive4Elements-commits
mailing list