changeset 3091:179e38aa678d

Some fixing charts are generated now flys-artifacts/trunk@4690 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Mon, 18 Jun 2012 13:29:15 +0000
parents 22def36d37b7
children cc8e28f9ccdf
files flys-artifacts/ChangeLog flys-artifacts/doc/conf/themes.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixFacetUtils.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java
diffstat 7 files changed, 123 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Mon Jun 18 12:29:29 2012 +0000
+++ b/flys-artifacts/ChangeLog	Mon Jun 18 13:29:15 2012 +0000
@@ -1,3 +1,20 @@
+2012-06-18	Christian Lins <christian.lins@intevation.de>
+
+	* doc/conf/themes.xml:
+	  Add themes for fixing facets.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java:
+	  Use FixFacetUtils.getMaxQ() to retrieve max Q.
+	  Interpolate km values instead of strict binary search.
+
+	* src/main/java/de/intevation/flys/artifacts/model/fixings/FixFacetUtils.java:
+	  Added, contains static getMaxQ() method.
+
+	* src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveGenerator.java,
+	  src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java:
+	  Some issues fixed.
+
 2012-06-18  Ingo Weinzierl <ingo@intevation.de>
 
 	* doc/conf/themes.xml: Fixed broken color strings.
--- a/flys-artifacts/doc/conf/themes.xml	Mon Jun 18 12:29:29 2012 +0000
+++ b/flys-artifacts/doc/conf/themes.xml	Mon Jun 18 13:29:15 2012 +0000
@@ -931,7 +931,53 @@
             </fields>
         </theme>
 
-    </themegroup>
+        
+        <theme name="FixingSectorAverageWQ">
+            <inherits>
+                <inherit from="HiddenColorLines"/>
+                <inherit from="ColorPoints"/>
+            </inherits>
+            <fields>
+                <field name="pointcolor" type="Color" default="#0011FF"/>
+            </fields>
+        </theme>
+
+        <theme name="FixingAnalysisEventsWQ">
+            <inherits>
+                <inherit from="HiddenColorLines"/>
+                <inherit from="ColorPoints"/>
+            </inherits>
+            <fields>
+                <field name="pointcolor" type="Color" default="#0011FF"/>
+            </fields>
+        </theme>
+
+        <theme name="FixingReferenceEventsWQ">
+            <inherits>
+                <inherit from="HiddenColorLines"/>
+                <inherit from="ColorPoints"/>
+            </inherits>
+            <fields>
+                <field name="pointcolor" type="Color" default="#0011FF"/>
+            </fields>
+        </theme>
+
+        <theme name="FixingOutliers">
+            <inherits>
+                <inherit from="HiddenColorLines"/>
+                <inherit from="ColorPoints"/>
+            </inherits>
+            <fields>
+                <field name="pointcolor" type="Color" default="#0011FF"/>
+            </fields>
+        </theme>
+
+        <theme name="FixingWQCurve">
+            <inherits>
+            </inherits>
+        </theme>
+
+</themegroup>
 
     <themegroup name="default-2">
         <theme name="DischargeCurve">
@@ -2258,6 +2304,11 @@
         <mapping from="sq_a_measurement" to="SQMeasurements"/>
         <mapping from="sq_a_outlier" to="SQOutliers"/>
         <mapping from="sq_a_curve" to="SQCurve"/>
+        <mapping from="fix_sector_average_wq" to="FixingSectorAverageWQ"/>
+        <mapping from="fix_analysis_events_wq" to="FixingAnalysisEventsWQ"/>
+        <mapping from="fix_outlier" to="FixingOutlier"/>
+        <mapping from="fix_wq_curve" to="FixingWQCurve"/>
+        <mapping from="fix_reference_events_wq" to="FixingReferenceEventsWQ"/>
 
     </mappings>
 </themes>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java	Mon Jun 18 12:29:29 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java	Mon Jun 18 13:29:15 2012 +0000
@@ -31,7 +31,6 @@
     /** House logger. */
     private static Logger logger = Logger.getLogger(FixDerivateFacet.class);
 
-    private double maxQ;
 
     /** Trivial Constructor. */
     public FixDerivateFacet() {
@@ -75,29 +74,19 @@
             Function.Derivative fd = ff.getDerivative();
 
             Parameters params = result.getParameters();
-            
-            // Determine maxQ
-            double[] maxQs = params
-                .interpolate("km", currentKm, new String [] { "max_q" });
-            if(maxQs != null) {
-                maxQ = maxQs[0];
+            double maxQ = FixFacetUtils.getMaxQ(params, currentKm);
+
+            String[] paramNames = ff.getParameterNames();
+
+            double[] coeffs = params.interpolate("km", currentKm, paramNames);
+            if(coeffs == null) {
+                logger.warn("getData: coeffs == null");
+                return null;
             }
-            
-            int row = params.binarySearch("km", currentKm, 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 =
                 fd.instantiate(coeffs);
 
-            double maxQ = getMaxQ(result, currentKm);
-
             FixFunction fix = new FixFunction(
                 "",
                 ff.getDescription(),
@@ -113,10 +102,6 @@
     }
 
 
-    protected double getMaxQ(FixResult result, double km) {
-        return maxQ;
-    }
-
     /**
      * Create a deep copy of this Facet.
      * @return a deep copy.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixFacetUtils.java	Mon Jun 18 13:29:15 2012 +0000
@@ -0,0 +1,16 @@
+package de.intevation.flys.artifacts.model.fixings;
+
+import de.intevation.flys.artifacts.model.Parameters;
+
+final class FixFacetUtils {
+
+    public static double getMaxQ(Parameters params, double km) {
+        double [] maxQ = params.interpolate("km", km, new String[] { "max_q" });
+        if (maxQ == null) {
+            return 1000;
+        }
+        double mQ = Math.min(10000, Math.abs(maxQ[0]));
+        return mQ + 0.05*mQ;
+    }
+
+}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java	Mon Jun 18 12:29:29 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixWQCurveFacet.java	Mon Jun 18 13:29:15 2012 +0000
@@ -14,6 +14,8 @@
 import de.intevation.flys.artifacts.model.FacetTypes;
 import de.intevation.flys.artifacts.model.Parameters;
 
+import de.intevation.flys.artifacts.model.fixings.FixFacetUtils;
+
 import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
 
 import org.apache.log4j.Logger;
@@ -90,8 +92,7 @@
             de.intevation.flys.artifacts.math.Function mf =
                 ff.instantiate(coeffs);
 
-            double maxQ = getMaxQ(params, currentKm);
-
+            double maxQ = FixFacetUtils.getMaxQ(params, currentKm);
             logger.debug("getData: maxQ = " + maxQ);
 
             FixFunction fix = new FixFunction(
@@ -108,16 +109,6 @@
         }
     }
 
-
-    public static double getMaxQ(Parameters params, double km) {
-        double [] maxQ = params.interpolate("km", km, new String[] { "max_q" });
-        if (maxQ == null) {
-            return 1000;
-        }
-        double mQ = Math.min(10000, Math.abs(maxQ[0]));
-        return mQ + 0.05*mQ;
-    }
-
     /**
      * Create a deep copy of this Facet.
      * @return a deep copy.
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveGenerator.java	Mon Jun 18 12:29:29 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveGenerator.java	Mon Jun 18 13:29:15 2012 +0000
@@ -70,19 +70,22 @@
         FixDerivateFacet facet = (FixDerivateFacet)aaf.getFacet();
         FixFunction func = (FixFunction)facet.getData(
             aaf.getArtifact(), context);
-        
-        double maxQ = func.getMaxQ();
-        maxQ = Math.min(2000.0, Math.abs(maxQ));
-        maxQ += maxQ * 0.05;
+
+        if(func != null) {        
+            double maxQ = func.getMaxQ();
         
-        if(maxQ > 0) {
-            XYSeries series = DatasetUtilities.sampleFunction2DToSeries(
-                new Function2DAdapter(func.getFunction()),
-                0,              // start
-                maxQ, // end
-                500,            // number of samples
-                aaf.getFacetDescription());
-            addAxisSeries(series, 0, visible);
+            if(maxQ > 0) {
+                XYSeries series = DatasetUtilities.sampleFunction2DToSeries(
+                    new Function2DAdapter(func.getFunction()),
+                    0,              // start
+                    maxQ, // end
+                    500,            // number of samples
+                    aaf.getFacetDescription());
+                addAxisSeries(series, 0, visible);
+            }
+        }
+        else {
+            logger.debug("doOut: func == null");
         }
     }
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Mon Jun 18 12:29:29 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java	Mon Jun 18 13:29:15 2012 +0000
@@ -72,9 +72,6 @@
         else if(FIX_ANALYSIS_EVENTS_WQ.equals(name)) {
             doAnalysisEventsOut(aaf, doc, visible);
         }
-        else if(FIX_ANALYSIS_PERIODS_WQ.equals(name)) {
-            doAnalysisPeriodsOut(aaf, doc, visible);
-        }
         else if(FIX_REFERENCE_EVENTS_WQ.equals(name)) {
             doReferenceEventsOut(aaf, doc, visible);
         }
@@ -90,16 +87,25 @@
         }
     }
 
+    /** Add sector average points to chart */
     protected void doSectorAverageOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
         logger.debug("doSectorAverageOut");
 
         QWD[] qwds = (QWD[])aaf.getData(context);
 
         if(qwds != null) {
-            // TODO
+            XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), doc);
+            for(QW qw : qwds) {
+                if(qw != null) {
+                    series.add(qw.getQ(), qw.getW());
+                }
+            }
+
+            addAxisSeries(series, 0, visible);
         }
     }
 
+    /** Add analysis event points to chart */
     protected void doAnalysisEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
        logger.debug("doAnalysisEventsOut");
 
@@ -114,16 +120,10 @@
         }
     }
 
-    protected void doAnalysisPeriodsOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
-       logger.debug("doAnalysisPeriodsOut");
-
-       DateRange[] dateRanges = (DateRange[])aaf.getData(context);
-       //TODO What to do with Date ranges?
-    }
-
+    /** Add reference event points to chart */
     protected void doReferenceEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) {
        logger.debug("doReferenceEventsOut");
-
+       
        QW[] qws = (QW[])aaf.getData(context);
        addQWSeries(qws, aaf, doc, visible);
     }
@@ -141,8 +141,6 @@
         }
         
         double maxQ = func.getMaxQ();
-        maxQ = Math.min(2000.0, Math.abs(maxQ));
-        maxQ += maxQ * 0.05;
 
         if(maxQ > 0) {
             XYSeries series = DatasetUtilities.sampleFunction2DToSeries(

http://dive4elements.wald.intevation.org