Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java @ 3022:705d2058b682
FixA: Store the referenced QW for each km, too.
flys-artifacts/trunk@4589 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 05 Jun 2012 14:56:57 +0000 |
parents | ab81ffd1343e |
children | c489f7e16c28 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java Tue Jun 05 13:56:55 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/Fitting.java Tue Jun 05 14:56:57 2012 +0000 @@ -31,11 +31,20 @@ } // interface QWFactory + public static final QWFactory QW_FACTORY = new QWFactory() { + @Override + public QW create(double q, double w) { + return new QW(q, w); + } + }; + + protected boolean checkOutliers; protected Function function; protected QWFactory qwFactory; protected double chiSqr; protected double [] parameters; protected ArrayList<QW> removed; + protected QW [] referenced; public Fitting() { @@ -43,13 +52,22 @@ } public Fitting(Function function) { - this(); - this.function = function; + this(function, QW_FACTORY); } public Fitting(Function function, QWFactory qwFactory) { - this(function); - this.qwFactory = qwFactory; + this(function, qwFactory, false); + } + + public Fitting( + Function function, + QWFactory qwFactory, + boolean checkOutliers + ) { + this(); + this.function = function; + this.qwFactory = qwFactory; + this.checkOutliers = checkOutliers; } public Function getFunction() { @@ -60,6 +78,14 @@ this.function = function; } + public boolean getCheckOutliers() { + return checkOutliers; + } + + public void setCheckOutliers(boolean checkOutliers) { + this.checkOutliers = checkOutliers; + } + public double getChiSquare() { return chiSqr; } @@ -68,6 +94,7 @@ chiSqr = 0.0; parameters = null; removed.clear(); + referenced = null; } public boolean hasOutliers() { @@ -82,6 +109,10 @@ return removed.toArray(new QW[removed.size()]); } + public QW [] referencedToArray() { + return referenced != null ? (QW [])referenced.clone() : null; + } + public double [] getParameters() { return parameters; } @@ -126,7 +157,7 @@ return false; } - if (qwFactory == null) { + if (!checkOutliers) { break; } @@ -162,6 +193,11 @@ } } + referenced = new QW[xs.size()]; + for (int i = 0; i < referenced.length; ++i) { + referenced[i] = qwFactory.create(xs.getQuick(i), ys.getQuick(i)); + } + chiSqr = lmo.getChiSquare(); return true;