Displaying differences for changeset
 
display as  

src/java/cfa/guiTimeseries_Model.java

@@ -49,7 +49,7 @@
 import org.jfree.ui.RectangleInsets;
 
 /**
-* Last Updated: 8-January-2016
+* Last Updated: 11-January-2016
 * @author Tyler Wible
 * @since 24-June-2011
 */
@@ -58,7 +58,7 @@
     String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/Timeseries";
     String database = "USGS";//"CDWR";//"STORET";//"UserData";//
     String organizationName = "USGS";//"Co. Division of Water Resources";//"Colorado Dept. of Public Health & Environment";//
-    String stationID = "10328000";//"06764880";//"CLAGRECO";//"000028";//
+    String stationID = "06764880";//"CLAGRECO";//"000028";//
     String stationName = "South Platte River at Roscoe, Nebr.";//"Cache La Poudre Near Greeley";//"BIG THOMPSON R NEAR MOUTH";//
     String wqTest = "flow";//"00600 Total nitrogen, water, unfiltered, milligrams per liter -- mg/L";//"00625 Ammonia-nitrogen as N -- mg/L";//
     String beginDate = "";
@@ -78,6 +78,7 @@
     boolean medianTF = false;
     boolean envelopeTF = true;
     boolean rasterTF = true;
+    boolean rasterLogarithmicBinsTF = true;
     double highPercentile = 0.75;
     double lowPercentile = 0.25;
     boolean showMonthlyStatsTF = false;
@@ -551,6 +552,9 @@
     public void setRasterTF(boolean rasterTF) {
         this.rasterTF = rasterTF;
     }
+    public void setRasterLogarithmicBinsTF(boolean rasterLogarithmicBinsTF) {
+        this.rasterLogarithmicBinsTF = rasterLogarithmicBinsTF;
+    }
     public void setHighPercentile(double highPercentile) {
         this.highPercentile = highPercentile;
     }
@@ -1442,6 +1446,7 @@
         ArrayList<Double> tempData_dayOfYear = new ArrayList<Double>();
         ArrayList<Double> tempData_year = new ArrayList<Double>();
         ArrayList<Double> tempData_value = new ArrayList<Double>();
+        ArrayList<Double> tempData_noZeros = new ArrayList<Double>();
         double currentYear = Double.parseDouble(end.substring(0,4));
         for(int j=3; j< envelopePlotData[0].length; j=j+2){//skip the first 'average' data
             for(int i=0; i<366; i++){//day loop
@@ -1450,6 +1455,9 @@
                     tempData_dayOfYear.add((double) i+1);
                     tempData_year.add(currentYear);
                     tempData_value.add(value);
+                    if(value > 0){
+                        tempData_noZeros.add(value);
+                    }
                 }
             }
             currentYear--;
@@ -1460,16 +1468,31 @@
             rasterData[i][1] = tempData_year.get(i);
             rasterData[i][2] = tempData_value.get(i);
         }
+        double tempMin = doubleMath.min(tempData_value);
+        double tempMax = doubleMath.max(tempData_value);
         
         //Renderer
         XYZDataset xyzRasterData = new XYZArrayDataset(rasterData);
         XYBlockRenderer renderer = new XYBlockRenderer();
-        LookupPaintScale paintScale = new LookupPaintScale(doubleMath.min(tempData_value),doubleMath.max(tempData_value),Color.lightGray);
-        Paint [] contourColors = getFullRainBowScale();
-        double delta = (Math.log(doubleMath.max(tempData_value)) - Math.log(doubleMath.min(tempData_value) + 0.001))/(contourColors.length -1);
-        double value = Math.log(doubleMath.max(tempData_value));
+        LookupPaintScale paintScale = new LookupPaintScale(tempMin, tempMax, Color.lightGray);
+        Paint[] contourColors = getFullRainBowScale(170);
+        
+        //Color Scale
+        double value = tempMax;
+        double delta = (tempMax - tempMin)/(contourColors.length -1);
+        if(rasterLogarithmicBinsTF){
+            value = Math.log(tempMax);
+            delta = (Math.log(tempMax) - Math.log(tempMin))/(contourColors.length -1);
+            if(tempMin == 0){
+                delta = (Math.log(tempMax) - Math.log(doubleMath.min(tempData_noZeros)))/(contourColors.length -1);
+            }
+        }
         for(int i=0; i<contourColors.length; i++){
-            paintScale.add(Math.exp(value), contourColors[i]);
+            if(rasterLogarithmicBinsTF){
+                paintScale.add(Math.exp(value), contourColors[i]);
+            }else{
+                paintScale.add(value, contourColors[i]);
+            }
             value = value - delta;
         }
         paintScale.add(0, Color.blue);
@@ -1491,7 +1514,7 @@
         plot.setRangeAxis(0, rangeAxis);
         
         //Create X Axis
-        ValueAxis domainAxis = new NumberAxis("Day of Year");
+        ValueAxis domainAxis = new NumberAxis("Day of Calendar Year");
         domainAxis.setLowerMargin(0.0);
         domainAxis.setUpperMargin(0.0);
         plot.setDomainAxis(0, domainAxis);
@@ -1504,7 +1527,10 @@
         JFreeChart chart = new JFreeChart(graphTitle, graphing.titleFont, plot, false);
         
         //Add scale/legend
-        LogarithmicAxis scaleAxis = new LogarithmicAxis(zAxisTitle);//NumberAxis scaleAxis = new NumberAxis("Scale");
+        NumberAxis scaleAxis = new NumberAxis(zAxisTitle);
+        if(rasterLogarithmicBinsTF){
+            scaleAxis = new LogarithmicAxis(zAxisTitle);
+        }
         scaleAxis.setAxisLinePaint(Color.white);
         scaleAxis.setTickMarkPaint(Color.white);
         scaleAxis.setTickLabelFont(graphing.masterFont);
@@ -1566,7 +1592,7 @@
             return data[item][2];
         }
    }
-    private static Paint[] getFullRainBowScale(){
+    private static Paint[] getFullRainBowScale(double colorValue){
         // minimum of about 200 to not have perceptible steps in color scale
         // whether or not perceptible color gradients show depend upon the
         // legend size and the monitor settings
@@ -1576,7 +1602,8 @@
         // but don't go all of the way around the wheel, or the first color
         // will repeat.  The 60 value is about a minimum of 40, or the
         // red color will repeat.  Too large a value, and there will be no magenta.
-        float x = (float) (1./(ncolor + 170.));
+//        float x = (float) (1./(ncolor + 170.));
+        float x = (float) (1./(ncolor + colorValue));
         for (int i=0; i < rainbow.length; i++){
             rainbow[i] = new Color( Color.HSBtoRGB((i)*x,1.0F,1.0F));
         }

src/java/m/cfa/Timeseries_V1_0.java

@@ -41,6 +41,7 @@
         model.setMedianTF(getBooleanParam("medianTF"));
         model.setEnvelopeTF(getBooleanParam("envelopeTF"));
         model.setRasterTF(getBooleanParam("rasterTF"));
+        model.setRasterLogarithmicBinsTF(getBooleanParam("rasterLogarithmicBinsTF"));
         model.setHighPercentile(getDoubleParam("highPercentile"));
         model.setLowPercentile(getDoubleParam("lowPercentile"));
         model.setShowMonthlyStatsTF(getBooleanParam("showMonthlyStatsTF"));

src/java/m/cfa/Timeseries_V1_0Req.json

@@ -104,12 +104,17 @@
     {
       "name": "envelopeTF",
       "description": "If true and wq_test='flow', an envelope grpah will be generated, otherwise it will not be generated.",
-      "value": true
+      "value": false
     },
     {
       "name": "rasterTF",
       "description": "If true and wq_test='flow', a raster grpah (or pixel plot)(will be generated, otherwise it will not be generated.",
-      "value": true
+      "value": false
+    },
+    {
+      "name": "rasterLogarithmicBinsTF",
+      "description": "If true, the raster graph will use a logarithmic color scale otherwise it will use an arithmetic color scale. Only used if rasterTF is True and wq_test='flow'.",
+      "value": false
     },
     {
       "name": "highPercentile",