# HG changeset patch # User Raimund Renkert # Date 1358936081 -3600 # Node ID 9e25c75234858f7a267ba57b84c43982dfead94e # Parent 47c529e2be268551bb9da579c6437ff4f74999e6 Fixed calculation of effective width in MINFO SQ relation. * Get all (including empty datasets) from db. * Filter empty datasets when processing data of the same date. * Added debug outputs. diff -r 47c529e2be26 -r 9e25c7523485 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java Sun Jan 20 15:04:32 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Measurement.java Wed Jan 23 11:14:41 2013 +0100 @@ -1,5 +1,6 @@ package de.intevation.flys.artifacts.model.sq; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -181,6 +182,8 @@ sieveArray.adjust( eightValue/sieveArray.totalLoad(), newFourValue/sieveArray.totalLoad()); + log.debug("Adjusted loads: " + Arrays.toString(sieveArray.getLoads())); + log.debug("Adjusted norm loads:" + Arrays.toString(sieveArray.getNormLoads())); } protected SieveArray calculateSieveArray() { diff -r 47c529e2be26 -r 9e25c7523485 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java Sun Jan 20 15:04:32 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/MeasurementFactory.java Wed Jan 23 11:14:41 2013 +0100 @@ -102,7 +102,7 @@ "COALESCE(gs.RSIEB15, 0) + COALESCE(gs.RSIEB16, 0) +" + "COALESCE(gs.RSIEB17, 0) + COALESCE(gs.RSIEB18, 0) +" + "COALESCE(gs.RSIEB19, 0) + COALESCE(gs.RSIEB20, 0) +" + - "COALESCE(gs.RSIEB21, 0) + COALESCE(gs.REST, 0)) > 0 " + + "COALESCE(gs.RSIEB21, 0) + COALESCE(gs.REST, 0)) >= 0 " + "ORDER BY " + "m.DATUM, g.UFERABST, g.GLOTRECHTEID, gp.LFDNR"; @@ -309,7 +309,6 @@ List accumulated = new ArrayList(); for (Measurement m: measuments) { - Integer currentLR = (Integer)m.getData("GLOTRECHTEID"); boolean newDS = lastLR == null @@ -373,6 +372,9 @@ protected static Measurement processSameDate(List measurements) { int N = measurements.size(); + if (N > 0) { + log.debug("process same date for Q: " + measurements.get(0).Q()); + } if (N == 1) { Measurement current = measurements.get(0); double left = current.get("UFERABLINKS"); @@ -402,6 +404,7 @@ double distNext = next.get("UFERABST"); current.set("EFFWIDTH", 0.5*(distNext - distPrev)); } + log.debug("effective width: " + current.get("EFFWIDTH")); } } @@ -412,6 +415,9 @@ for (Measurement m: measurements) { SieveArray sa = m.getSieveArray(); + if (sa.totalLoad() < SieveArray.EPSILON) { + continue; + } double sandF = sa.sandNormFraction(); double coarseF = sa.coarseNormFraction(); double gravelF = sa.gravelNormFraction(); @@ -422,6 +428,11 @@ sumCoarseF += scale*coarseF; sumGravelF += scale*gravelF; sumNorm += scale; + log.debug("fractions - s: " + + sandF + " c: " + + coarseF + " g: " + + gravelF); + log.debug("scale: " + scale + " = " + effWidth + " * " + gt); } Map data = @@ -434,7 +445,7 @@ m.set("BL_S", sumNorm*sumSandF); m.set("BL_G", sumNorm*sumGravelF); m.set("BL_C", sumNorm*sumCoarseF); - + log.debug("BL_S: " + m.get("BL_S") + " BL_G: " + m.get("BL_G") + " BL_C: " + m.get("BL_C")); return m; } @@ -483,6 +494,7 @@ new HashMap(measuments.get(0).getData()); data.put("GTRIEB", sumGTrieb/N); + return new Measurement(data, accumulatedSieves); } } diff -r 47c529e2be26 -r 9e25c7523485 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SieveArray.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SieveArray.java Sun Jan 20 15:04:32 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SieveArray.java Wed Jan 23 11:14:41 2013 +0100 @@ -1,7 +1,14 @@ package de.intevation.flys.artifacts.model.sq; +import java.util.Arrays; + +import org.apache.log4j.Logger; + public class SieveArray { + private static final Logger log = + Logger.getLogger(SieveArray.class); + public static final double EPSILON = 1e-8; public static final double [] SIEVE_DIAMETERS = { @@ -49,6 +56,7 @@ for (int i = 0; i < normLoads.length; ++i) { normLoads[i] = total*loads[i]; } + log.debug("calculated norm loads: " + Arrays.toString(normLoads)); } public void adjust(double eight, double four) {