[Dive4elements-commits] [PATCH 2 of 3] Use new state 'outlier mehtod selection' in SQ-relation
Wald Commits
scm-commit at wald.intevation.org
Mon Mar 25 12:41:14 CET 2013
# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1364211626 -3600
# Node ID aaf810d4ec8251419dfc5aba94cf9960c53788af
# Parent 5a55c5372fe16c4cef8e0516ccb2e0f0e98fb1a7
Use new state 'outlier mehtod selection' in SQ-relation.
The outlier method is no more configurable in conf.xml. The user can now select
the method in SQ-relation parameters.
diff -r 5a55c5372fe1 -r aaf810d4ec82 flys-artifacts/doc/conf/artifacts/minfo.xml
--- a/flys-artifacts/doc/conf/artifacts/minfo.xml Mon Mar 25 12:35:08 2013 +0100
+++ b/flys-artifacts/doc/conf/artifacts/minfo.xml Mon Mar 25 12:40:26 2013 +0100
@@ -127,7 +127,7 @@
<transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
<from state="state.minfo.sq.period"/>
- <to state="state.minfo.sq.outliers"/>
+ <to state="state.minfo.sq.outlier-method"/>
</transition>
<transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
@@ -189,10 +189,6 @@
</outputmodes>
</state>
- <state id="state.minfo.sq.outliers" description="state.minfo.sq.outliers" state="de.intevation.flys.artifacts.states.OutliersInput" helpText="help.state.minfo.sq.outliers">
- <data name="outliers" type="Double"/>
- </state>
-
<state id="state.minfo.bed.differences" description="state.minfo.bed.differences" state="de.intevation.flys.artifacts.states.minfo.DifferencesState" helpText="help.state.minfo.bed.differences">
<outputmodes>
<outputmode name="bed_difference_height_year" description="output.absolute_height" mime-type="image/png" type="chart">
@@ -252,16 +248,29 @@
<data name="load_diameter" type="options"/>
</state>
+ <state id="state.minfo.sq.outlier-method" description="state.minfo.sq.outlier-method" state="de.intevation.flys.artifacts.states.sq.OutlierMethod" helpText="help.state.minfo.sq.outliermethod">
+ <data name="outlier-method" type="String"/>
+ </state>
+
<transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
- <from state="state.minfo.sq.outliers"/>
- <to state="state.minfo.sq.relation"/>
+ <from state="state.minfo.sq.outlier-method"/>
+ <to state="state.minfo.sq.outliers"/>
</transition>
+ <state id="state.minfo.sq.outliers" description="state.minfo.sq.outliers" state="de.intevation.flys.artifacts.states.OutliersInput" helpText="help.state.minfo.sq.outliers">
+ <data name="outliers" type="Double"/>
+ </state>
+
<transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
<from state="state.minfo.bed.char_diameter"/>
<to state="state.minfo.bed.bed_quality"/>
</transition>
+ <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
+ <from state="state.minfo.sq.outliers"/>
+ <to state="state.minfo.sq.relation"/>
+ </transition>
+
<state id="state.minfo.sq.relation" description="state.minfo.sq.relation" state="de.intevation.flys.artifacts.states.SQRelation">
<outputmodes>
<outputmode name="sq_relation_a" description="output.sq_relation" type="chart">
diff -r 5a55c5372fe1 -r aaf810d4ec82 flys-artifacts/doc/conf/conf.xml
--- a/flys-artifacts/doc/conf/conf.xml Mon Mar 25 12:35:08 2013 +0100
+++ b/flys-artifacts/doc/conf/conf.xml Mon Mar 25 12:40:26 2013 +0100
@@ -401,11 +401,6 @@
<zoom-scale river="Elbe" range="500" radius="10" />
</zoom-scales>
- <minfo-sq>
- <!-- valid names: grubbs or std-dev -->
- <outlier-method name="grubbs"/>
- </minfo-sq>
-
<dgm-path>
/path/to/rivers/
</dgm-path>
diff -r 5a55c5372fe1 -r aaf810d4ec82 flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/SQRelationAccess.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/SQRelationAccess.java Mon Mar 25 12:35:08 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/SQRelationAccess.java Mon Mar 25 12:40:26 2013 +0100
@@ -18,6 +18,8 @@
protected Double outliers;
+ private String method;
+
public SQRelationAccess() {
}
@@ -60,5 +62,15 @@
}
return outliers;
}
+
+ public String getOutlierMethod() {
+ if (method == null) {
+ method = getString("outlier-method");
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("outlier-method: " + method);
+ }
+ return method;
+ }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 5a55c5372fe1 -r aaf810d4ec82 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Fitting.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Fitting.java Mon Mar 25 12:35:08 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Fitting.java Mon Mar 25 12:40:26 2013 +0100
@@ -124,7 +124,7 @@
return good;
}
- public boolean fit(List<SQ> sqs, Callback callback) {
+ public boolean fit(List<SQ> sqs, String method, Callback callback) {
sqs = onlyValid(sqs);
@@ -136,7 +136,7 @@
this.callback = callback;
try {
- Outlier.detectOutliers(this, sqs, stdDevFactor);
+ Outlier.detectOutliers(this, sqs, stdDevFactor, method);
}
catch (MathException me) {
log.warn(me);
diff -r 5a55c5372fe1 -r aaf810d4ec82 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Outlier.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Outlier.java Mon Mar 25 12:35:08 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Outlier.java Mon Mar 25 12:40:26 2013 +0100
@@ -19,7 +19,7 @@
private static final String OUTLIER_METHOD =
"/artifact-database/options/minfo-sq/outlier-method/@name";
- private static final String GRUBBS = "grubbs";
+ private static final String GRUBBS = "outlier.method.grubbs";
//private static final String STD_DEV = "std-dev";
@@ -39,14 +39,13 @@
public static void detectOutliers(
Callback callback,
List<SQ> sqs,
- double stdDevFactor
+ double stdDevFactor,
+ String method
)
throws MathException
{
boolean debug = log.isDebugEnabled();
- String method = Config.getStringXPath(OUTLIER_METHOD);
-
if (method == null) {
method = "std-dev";
}
diff -r 5a55c5372fe1 -r aaf810d4ec82 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java Mon Mar 25 12:35:08 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/SQRelationCalculation.java Mon Mar 25 12:40:26 2013 +0100
@@ -28,6 +28,7 @@
protected double location;
protected DateRange period;
protected double outliers;
+ private String method;
public SQRelationCalculation() {
}
@@ -38,6 +39,7 @@
Double location = access.getLocation();
DateRange period = access.getPeriod();
Double outliers = access.getOutliers();
+ String method = access.getOutlierMethod();
//river = "Rhein";
@@ -61,11 +63,17 @@
addProblem("sq.missing.outliers");
}
+ if (method == null) {
+ //TODO: i18n
+ addProblem("sq.missing.method");
+ }
+
if (!hasProblems()) {
this.river = river;
this.location = location;
this.period = period;
this.outliers = outliers;
+ this.method = method;
}
}
@@ -140,6 +148,7 @@
boolean success = new Fitting(function, outliers).fit(
sqs,
+ method,
new Fitting.Callback() {
@Override
public void afterIteration(
More information about the Dive4elements-commits
mailing list