# HG changeset patch # User Sascha L. Teichmann # Date 1339582784 0 # Node ID ee653971fa8449eba4495c2e54cc3ddcb2bea7d5 # Parent 478e8d9d88ba9fd9490de4a3dd1d17d62edae605 FixA: Figure out max Q during fitting. flys-artifacts/trunk@4649 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 478e8d9d88ba -r ee653971fa84 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Jun 13 09:28:39 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Jun 13 10:19:44 2012 +0000 @@ -1,3 +1,20 @@ +2012-06-11 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/AnalysisPeriod.java: + Max Q is store in column "max_q" in Parameters now. So function can be plotted + bewtween calculated kms, too. + For function sampling use something like this.: + + double [] maxQ = parameters.interpolate("km", 42.3", new String [] { "max_q" }); + double maxSampleQ = 10000d; + + if (maxQ != null) { + maxSampleQ = Math.min(2000d, Math.abs(maxQ[0])); + maxSampleQ += 0.05*maxSampleQ; + } + 2012-06-13 Christian Lins * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: diff -r 478e8d9d88ba -r ee653971fa84 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/AnalysisPeriod.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/AnalysisPeriod.java Wed Jun 13 09:28:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/AnalysisPeriod.java Wed Jun 13 10:19:44 2012 +0000 @@ -57,5 +57,24 @@ public QWD getQSectorAverage(int i) { return qSectorAverages[i]; } + + public double getMaxQ() { + double maxQ = -Double.MAX_VALUE; + if (qwds != null) { + for (QWD qwd: qwds) { + if (qwd.getQ() > maxQ) { + maxQ = qwd.getQ(); + } + } + } + if (qSectorAverages != null) { + for (QWD qwd: qSectorAverages) { + if (qwd != null && qwd.getQ() > maxQ) { + maxQ = qwd.getQ(); + } + } + } + return maxQ; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 478e8d9d88ba -r ee653971fa84 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 Wed Jun 13 09:28:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java Wed Jun 13 10:19:44 2012 +0000 @@ -113,6 +113,18 @@ return referenced != null ? (QW [])referenced.clone() : null; } + public double getMaxQ() { + double maxQ = -Double.MAX_VALUE; + if (referenced != null) { + for (QW qw: referenced) { + if (qw.getQ() > maxQ) { + maxQ = qw.getQ(); + } + } + } + return maxQ; + } + public double [] getParameters() { return parameters; } diff -r 478e8d9d88ba -r ee653971fa84 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java Wed Jun 13 09:28:39 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java Wed Jun 13 10:19:44 2012 +0000 @@ -207,6 +207,7 @@ int kmIndex = results.columnIndex("km"); int chiSqrIndex = results.columnIndex("chi_sqr"); + int maxQIndex = results.columnIndex("max_q"); int [] parameterIndices = results.columnIndices(parameterNames); int numFailed = 0; @@ -240,6 +241,7 @@ results.set(row, kmIndex, km); results.set(row, chiSqrIndex, fitting.getChiSquare()); + results.set(row, maxQIndex, fitting.getMaxQ()); invalid |= results.set( row, parameterIndices, fitting.getParameters()); } @@ -309,6 +311,7 @@ Range range = new Range(from, to); int kmIndex = parameters.columnIndex("km"); + int maxQIndex = parameters.columnIndex("max_q"); ColumnCache cc = new ColumnCache(); @@ -427,6 +430,19 @@ periodResults.add(periodResult); } + double maxQ = -Double.MAX_VALUE; + for (AnalysisPeriod ap: periodResults) { + double q = ap.getMaxQ(); + if (q > maxQ) { + maxQ = q; + } + } + + double oldMaxQ = parameters.get(row, maxQIndex); + if (oldMaxQ < maxQ) { + parameters.set(row, maxQIndex, maxQ); + } + results.add(km, periodResults.toArray( new AnalysisPeriod[periodResults.size()])); } @@ -559,10 +575,11 @@ } protected static String [] createColumnNames(String [] parameters) { - String [] result = new String[parameters.length + 2]; + String [] result = new String[parameters.length + 3]; result[0] = "km"; result[1] = "chi_sqr"; - System.arraycopy(parameters, 0, result, 2, parameters.length); + result[2] = "max_q"; + System.arraycopy(parameters, 0, result, 3, parameters.length); return result; } }