Displaying differences for changeset
 
display as  

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

@@ -110,8 +110,8 @@
      * @return returns a String[][] containing the a summary table of the return periods and flows for the graph and data used
      * @throws IOException 
      */
-    public String[][] b17(double[][] datain, 
-                          double gg,
+    public Object[] b17(double[][] datain, 
+                          Double gg,
                           double MSEGbar,
                           String directory,
                           String database,
@@ -317,7 +317,7 @@
         //double[][] hp = (double[][]) historicalArray[3];  //hp = historical plot with outliers removed    (Jeff)
         skews = DoubleArray.appendcolumn(skews, G);//    skews = [skews G];
 
-        if(Math.abs(G - gg) > 0.5){
+        if(!gg.isNaN() &&  Math.abs(G - gg) > 0.5){
             //Notify user more weight should be given to station skew    (Jeff)
             System.out.println("\nThere is a large discrepency (> 0.5) between the calculated station skew (G = " + G + ") and the generalized skew (GG = " + gg + ").");
             System.out.println("More weight should be given to the Station skew.\n");
@@ -430,7 +430,14 @@
 
         double MSEG = Math.pow(10, A-B*(Math.log10(H/10)));  //10^(A-B*log10(H/10));
         //Weighted Skew calculation    (Jeff)
-        double GW = (MSEGbar*GS + MSEG*gg)/(MSEGbar + MSEG);
+        double GW = Double.NaN;
+        if (gg.isNaN()){
+            // If no generalized skew is provided, assume we are performing these calculations with station skew
+            GW = G;
+        } else {
+            // assume we are performing these calculations with weighted general skew
+            GW = (MSEGbar*GS + MSEG*gg)/(MSEGbar + MSEG);
+        }
         //Adopted skew (i.e. round skew to nearest tenth    (Jeff)
         double GD = GW;  //GD = round(GW*10)/10;
         skews = DoubleArray.appendcolumn(skews, GD);//    skews = [skews GD];
@@ -531,8 +538,9 @@
         pplot(pp, K, dataout, GD, directory, database, stationId, stationName, showLargeFloods, plotref, plottype);
 
         //Assemble a summary of return periods and flow values    (Tyler)
-        String[][] summaryTableWeightedGenSkew = probFreqData(dataout);
-        return summaryTableWeightedGenSkew;
+        String[][] summaryTable = probFreqData(dataout);
+        Object[] returnArray = {summaryTable, GW};
+        return returnArray;
     }
     /**
      * stationStats:  used to calculate Station Statistics Skew and Standard Deviation

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

@@ -60,7 +60,10 @@
         resultPayload.put("skewErrorMessage", model.getSkewErrorMessage());
         String output = FileUtils.readFileToString(model.getOutputWeightedGenSkew(), "UTF-8");
         resultPayload.put("output", output);
-        resultPayload.put("floodSummary_weightedGenSkew", model.getOutputWeightedGenSkew());
+        resultPayload.put("weightedGenSkew", model.getWeightedGenSkew());
+        String output_stationSkew = FileUtils.readFileToString(model.getOutputStationSkew(), "UTF-8");
+        resultPayload.put("output_stationSkew", output_stationSkew);
+        resultPayload.put("stationSkew", model.getStationSkew());
         resultPayload.put("graph", model.getGraph());
     }
 }

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

@@ -41,15 +41,20 @@
     String end = "?";
     String dataSource = "?";
     String skewErrorMessage = "?";
+    double stationSkew = Double.NaN;
+    double weightedGenSkew = Double.NaN;
     
     //Gets
     public File getOutputWeightedGenSkew(){ return new File(directory, "flood_summary.txt"); }
+    public File getOutputStationSkew(){ return new File(directory, "flood_summary_stationskew.txt"); }
     public String getGraph(){ return "flood_graph.jpg"; }
     public String getLen(){ return len; }
     public String getStart(){ return start; }
     public String getEnd(){ return end; }
     public String getDataSource(){ return dataSource; }
     public String getSkewErrorMessage(){ return skewErrorMessage; }
+    public String getStationSkew(){ return String.valueOf(stationSkew); }
+    public String getWeightedGenSkew(){ return String.valueOf(weightedGenSkew); }
     
     //Sets
     public void setDirectory(String directory_str){ directory = directory_str; }
@@ -152,7 +157,12 @@
             
             //Run Bulletin 17 function and return graph
             Bulletin17B bulletin17B = new Bulletin17B();
-            String[][] dataSummaryWeightedGenSkew = bulletin17B.b17(peakFlowData_combined, gg, MSERbar, directory, database, stationId, stationName, showLargeFloods, plotref, plottype);
+            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];
+            Object[] returnArrayWeightedGenSkew = bulletin17B.b17(peakFlowData_combined, gg, MSERbar, directory, database, stationId, stationName, showLargeFloods, plotref, plottype);
+            String[][] dataSummaryWeightedGenSkew = (String[][]) returnArrayWeightedGenSkew[0];
+            weightedGenSkew = (double) returnArrayWeightedGenSkew[1];
             len = String.valueOf(peakFlowData_combined.length);
             start = String.valueOf(peakFlowData_combined[0][0]);
             end = String.valueOf(peakFlowData_combined[peakFlowData_combined.length - 1][0]);
@@ -160,6 +170,7 @@
 
             //Write out the data summary to be displayed with the graph
             writeSummary(dataSummaryWeightedGenSkew, getOutputWeightedGenSkew().getName());
+            writeSummary(dataSummaryStationSkew, getOutputStationSkew().getName());
             
         }else{
             throw new IOException("Error: Flood analysis method specified is not 'B17'");