# HG changeset patch # User Sascha L. Teichmann # Date 1339682596 0 # Node ID 0ace00c0c12a450ca3e66e29944a33e4f899c894 # Parent 0d3dd823006458424332828ba405a5eba1343cc9 FixA: Improved W/Q facet code flys-artifacts/trunk@4664 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 0d3dd8230064 -r 0ace00c0c12a flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Thu Jun 14 13:46:07 2012 +0000 +++ b/flys-artifacts/ChangeLog Thu Jun 14 14:03:16 2012 +0000 @@ -1,3 +1,14 @@ +2012-06-14 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java: + Added more debug output. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java: + Interpolate the coeffs for the function to be drawn. + + * src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java: + Made code more robust for none existing data. + 2012-06-14 Ingo Weinzierl * src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added @@ -29,8 +40,8 @@ 2012-06-11 Sascha L. Teichmann - * src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java: - Use binary search again. + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixAvSectorFacet.java: + Use binary search again. 2012-06-11 Sascha L. Teichmann diff -r 0d3dd8230064 -r 0ace00c0c12a flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java Thu Jun 14 13:46:07 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java Thu Jun 14 14:03:16 2012 +0000 @@ -145,6 +145,7 @@ } if (xs.size() < 2) { + log.warn("Too less points."); return false; } diff -r 0d3dd8230064 -r 0ace00c0c12a flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java Thu Jun 14 13:46:07 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java Thu Jun 14 14:03:16 2012 +0000 @@ -75,23 +75,19 @@ Parameters params = result.getParameters(); String[] columnNames = params.getColumnNames(); - for(String columnName : columnNames) { - logger.debug("FixWQCurveFacet.getData: columnName = '" + columnName + "'"); + + String[] paramNames = ff.getParameterNames(); + + double [] coeffs = params.interpolate("km", km, paramNames); + + if (coeffs == null) { + return null; } - int row = params.binarySearch("km", km, Math.pow(10, -4)); - if(row < 0) { - row = -row - 1; - logger.debug("getData: no direct hit in params.binarySearch"); - } - String[] paramNames = ff.getParameterNames(); - int[] paramInd = params.columnIndices(paramNames); - double[] coeffs = new double[paramNames.length]; - params.get(row, paramInd, coeffs); de.intevation.flys.artifacts.math.Function mf = ff.instantiate(coeffs); - double maxQ = getMaxQ(result, km); + double maxQ = getMaxQ(params, km); logger.debug("getData: maxQ = " + maxQ); FixFunction fix = new FixFunction( @@ -109,47 +105,13 @@ } - protected double getMaxQ(FixResult result, double km) { - double maxQ = 0; - - KMIndex kmQWRef = result.getReferenced(); - - KMIndex.Entry qwEntry = kmQWRef.binarySearch(km); - if(qwEntry != null) { - QW[] qwRef = qwEntry.getValue(); - if (qwRef != null) { - for (int i = 0; i < qwRef.length; i++) { - if (qwRef[i].getQ() > maxQ) { - maxQ = qwRef[i].getQ(); - } - } - } - } else { - logger.debug("getMaxQ: qwEntry is null, that's odd..."); + protected double getMaxQ(Parameters params, double km) { + double [] maxQ = params.interpolate("km", km, new String[] { "max_q" }); + if (maxQ == null) { + return 1000; } - - KMIndex kmQWDAna = result.getAnalysisPeriods(); - KMIndex.Entry periodsEntry = kmQWDAna.binarySearch(km); - - if(periodsEntry != null) { - AnalysisPeriod[] periods = kmQWDAna.binarySearch(km).getValue(); - if(periods != null) { - for (int i = 0; i < periods.length; i++) { - QWD[] qwdAna = periods[i].getQWDs(); - if (qwdAna != null) { - for (int j = 0; j < qwdAna.length; j++) { - if (qwdAna[j].getQ() > maxQ) { - maxQ = qwdAna[j].getQ(); - } - } - } - } - } - } else { - logger.debug("getMaxQ: periodsEntry is null, that's odd..."); - } - //return maxQ; - return 1000; //FIXME replace by parameters.interpolate("q_max")... + double mQ = Math.min(10000, Math.abs(maxQ[0])); + return mQ + 0.05*mQ; } /** diff -r 0d3dd8230064 -r 0ace00c0c12a flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Thu Jun 14 13:46:07 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Thu Jun 14 14:03:16 2012 +0000 @@ -136,6 +136,11 @@ logger.debug("doWQCurveOut"); FixFunction func = (FixFunction)aaf.getData(context); + + if (func == null) { + return; + } + if(func.getMaxQ() > 0) { XYSeries series = DatasetUtilities.sampleFunction2DToSeries( new Function2DAdapter(func.getFunction()),