Displaying differences for changeset
 
display as  

src/java/m/cfa/flood/Bulletin17B.java

@@ -17,6 +17,9 @@
 import java.util.Comparator;
 import java.util.Iterator;
 import org.apache.commons.math.ArgumentOutsideDomainException;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
 import org.jfree.chart.ChartUtilities;
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.annotations.XYAnnotation;
@@ -119,7 +122,7 @@
                           String stationName, 
                           boolean showLargeFloods, 
                           boolean plotref, 
-                          boolean plottype) throws IOException{
+                          boolean plottype) throws IOException, JSONException{
         //Note that a number of lines/formulas are commented out after non-commented formulas
         //The comment formulas are the original Matlab code lines written by Jeff Burkey
         //The non-commented part that comes first is the Java equivalent as written by Tyler Wible
@@ -165,6 +168,9 @@
         double xl = 0, ql = 0, xh = 0, qh = 0;
         double[][] datafilter = new double[0][0];
 
+        
+        JSONArray highOutlierList = new JSONArray ();
+        JSONArray lowOutlierList = new JSONArray ();
         if(G >= -.40 && G <= 0.40){
             //Estimate outliers thresholds on full record
             //Per Appendix 4, one-sided 10-percent KNtable  (Jeff)
@@ -187,6 +193,10 @@
             for(int i=0; i<datain.length; i++){
                 if(datain[i][1] < ql){
                     QLcnt++;
+                    JSONObject low = new JSONObject();
+                    low.put("year", datain[i][0]);
+                    low.put("peak flow", datain[i][1]);
+                    lowOutlierList.put(low);
                 }
             }
             //Matlab code:  [G N S Xmean] = stationStats(datafilter);
@@ -203,6 +213,10 @@
             for(int i=0; i<datain.length; i++){
                 if(datain[i][1] > qh){
                     QHcnt++;
+                    JSONObject high = new JSONObject();
+                    high.put("year", datain[i][0]);
+                    high.put("peak flow", datain[i][1]);
+                    highOutlierList.put(high);
                 }
             }
 
@@ -230,6 +244,10 @@
             for(int i=0; i<datain.length; i++){
                 if(datain[i][1] < ql){
                     QLcnt++;
+                    JSONObject low = new JSONObject();
+                    low.put("year", datain[i][0]);
+                    low.put("peak flow", datain[i][1]);
+                    lowOutlierList.put(low);
                 }
             }
             //Matlab code:  [G N S Xmean] = stationStats(datafilter);
@@ -246,6 +264,10 @@
             for(int i=0; i<datain.length; i++){
                 if(datain[i][1] > qh){
                     QHcnt++;
+                    JSONObject high = new JSONObject();
+                    high.put("year", datain[i][0]);
+                    high.put("peak flow", datain[i][1]);
+                    highOutlierList.put(high);
                 }
             }
         }else if(G < -0.40){
@@ -266,6 +288,10 @@
             for(int i=0; i<datain.length; i++){
                 if(datain[i][1] < ql){
                     QLcnt++;
+                    JSONObject low = new JSONObject();
+                    low.put("year", datain[i][0]);
+                    low.put("peak flow", datain[i][1]);
+                    lowOutlierList.put(low);
                 }
             }
             //Matlab code:  [G N S Xmean] = stationStats(datafilter);
@@ -289,6 +315,10 @@
             for(int i=0; i<datain.length; i++){
                 if(datain[i][1] > qh){
                     QHcnt++;
+                    JSONObject high = new JSONObject();
+                    high.put("year", datain[i][0]);
+                    high.put("peak flow", datain[i][1]);
+                    highOutlierList.put(high);
                 }
             }
         }
@@ -539,7 +569,7 @@
 
         //Assemble a summary of return periods and flow values    (Tyler)
         String[][] summaryTable = probFreqData(dataout);
-        Object[] returnArray = {summaryTable, GW};
+        Object[] returnArray = {summaryTable, GW, lowOutlierList, highOutlierList};
         return returnArray;
     }
     /**

src/java/m/cfa/flood/V1_0.java

@@ -9,6 +9,8 @@
 import java.io.File;
 import javax.ws.rs.Path;
 import org.apache.commons.io.FileUtils;
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONObject;
 
 @Name("flood")
 @Description("Time Series: Flood Frequency Analysis")
@@ -65,5 +67,11 @@
         resultPayload.put("output_station_skew", output_stationSkew);
         resultPayload.put("station_skew", model.getStationSkew());
         resultPayload.put("graph", model.getGraph());
+        
+        //Arrays
+        resultPayload.put("lowOutliers_station_skew", model.getLowOutliersStationSkew());
+        resultPayload.put("highOutliers_station_skew", model.getHighOutliersStationSkew());
+        resultPayload.put("lowOutliers_weighted_generalized_skew", model.getLowOutliersWeightedGenSkew());
+        resultPayload.put("highOutliers_weighted_generalized_skew", model.getHighOutliersWeightedGenSkew());
     }
 }

src/java/m/cfa/flood/guiFlood_Model.java

@@ -11,6 +11,7 @@
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import org.codehaus.jettison.json.JSONArray;
 
 /**
 * Last Updated: 9-April-2019
@@ -43,6 +44,10 @@
     String skewErrorMessage = "?";
     double stationSkew = Double.NaN;
     double weightedGenSkew = Double.NaN;
+    JSONArray lowOutliersStationSkew = new JSONArray();
+    JSONArray highOutliersStationSkew = new JSONArray();
+    JSONArray lowOutliersWeightedGenSkew = new JSONArray();
+    JSONArray highOutliersWeightedGenSkew = new JSONArray();
     
     //Gets
     public File getOutputWeightedGenSkew(){ return new File(directory, "flood_summary.txt"); }
@@ -55,6 +60,10 @@
     public String getSkewErrorMessage(){ return skewErrorMessage; }
     public String getStationSkew(){ return String.valueOf(stationSkew); }
     public String getWeightedGenSkew(){ return String.valueOf(weightedGenSkew); }
+    public JSONArray getLowOutliersStationSkew(){ return lowOutliersStationSkew; }
+    public JSONArray getHighOutliersStationSkew(){ return highOutliersStationSkew; }
+    public JSONArray getLowOutliersWeightedGenSkew(){ return lowOutliersWeightedGenSkew; }
+    public JSONArray getHighOutliersWeightedGenSkew(){ return highOutliersWeightedGenSkew; }
     
     //Sets
     public void setDirectory(String directory_str){ directory = directory_str; }
@@ -160,9 +169,13 @@
             Object[] returnArrayStationSkew = bulletin17B.b17(peakFlowData_combined, Double.NaN, MSERbar, directory, database, stationId, stationName, showLargeFloods, plotref, plottype);
             String[][] dataSummaryStationSkew = (String[][]) returnArrayStationSkew[0];
             stationSkew = (double) returnArrayStationSkew[1];
+            lowOutliersStationSkew = (JSONArray) returnArrayStationSkew[2];
+            highOutliersStationSkew = (JSONArray) returnArrayStationSkew[3];
             Object[] returnArrayWeightedGenSkew = bulletin17B.b17(peakFlowData_combined, gg, MSERbar, directory, database, stationId, stationName, showLargeFloods, plotref, plottype);
             String[][] dataSummaryWeightedGenSkew = (String[][]) returnArrayWeightedGenSkew[0];
             weightedGenSkew = (double) returnArrayWeightedGenSkew[1];
+            lowOutliersWeightedGenSkew = (JSONArray) returnArrayStationSkew[2];
+            highOutliersWeightedGenSkew = (JSONArray) returnArrayStationSkew[3];
             len = String.valueOf(peakFlowData_combined.length);
             start = String.valueOf(peakFlowData_combined[0][0]);
             end = String.valueOf(peakFlowData_combined[peakFlowData_combined.length - 1][0]);