Displaying differences for changeset
 
display as  

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

@@ -52,6 +52,7 @@
             model.setHighSystematicThreshold( inputPayload.getDouble( "high_systematic_threshold" ) );
             model.setLowOutlierThreshold( inputPayload.getDouble( "low_outlier_threshold" ) );
             model.setLowOutlierMethod( inputPayload.getString( "low_outlier_method" ) );
+            model.setFlowIntervals( inputPayload.getJSONArray( "flow_intervals", new JSONArray() ) );
             model.setPerceptionThresholds( inputPayload.getJSONArray( "perception_thresholds", new JSONArray() ) );
             model.setExecutable( e );
         }

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

@@ -62,6 +62,7 @@
     private double highSystematicThreshold = Double.NaN;
     private String lowOutlierMethod = "";
     private double lowOutlierThreshold = Double.NaN;
+    JSONArray flowIntervals = new JSONArray();
     JSONArray perceptionThresholds = new JSONArray();
     public Bulletin17CResults stationResult;
     public Bulletin17CResults weightedResult;
@@ -224,6 +225,10 @@
         this.lowOutlierThreshold = lowOutlierThreshold;
     }
     
+    public void setFlowIntervals( JSONArray flowIntervals ) {
+        this.flowIntervals = flowIntervals;
+    }
+    
     public void setPerceptionThresholds( JSONArray perceptionThresholds ) {
         this.perceptionThresholds = perceptionThresholds;
     }
@@ -338,8 +343,37 @@
                 String year = df.format( peakFlow[ 0 ] );
                 String rate = df.format( peakFlow[ 1 ] );
 
-                //write values to file
-                writer.println( "Q     " + year + "     " + rate + "\n" );
+                boolean simpleValue = false;
+                String lowerFlowInterval = null;
+                String upperFlowInterval = null;
+                if (this.flowIntervals.length() > 0) {
+                    for (int i=0; i<this.flowIntervals.length(); i++) {
+                        JSONObject singlePerceptionThreshold = (JSONObject) this.flowIntervals.get(i);
+                        double waterYear = Double.parseDouble(singlePerceptionThreshold.get("waterYear").toString());
+                        lowerFlowInterval = singlePerceptionThreshold.get("Ql").toString();
+                        upperFlowInterval = singlePerceptionThreshold.get("Qu").toString();
+                        if ( Double.compare(waterYear, peakFlow[0]) == 0 ){
+                            double dischargeRate = Double.parseDouble(rate);
+                            double lowerFlowIntervalNumber = Double.parseDouble(lowerFlowInterval);
+                            double upperFlowIntervalNumber = Double.parseDouble(upperFlowInterval);
+                            if ( Double.compare(lowerFlowIntervalNumber, upperFlowIntervalNumber) != 0 && 
+                                    Double.compare(lowerFlowIntervalNumber, dischargeRate) != 0){
+                                //If the upper and lower flow interval are the same
+                                //And the flow intervals match the discharge, then this is a simple one
+                                simpleValue = true;
+                            }
+                            break;
+                        }
+                    }
+                }
+
+                if (simpleValue){
+                    //write Gage Discharge (known) values to file
+                    writer.println( "Q     " + year + "     " + rate + "\n" );
+                } else {
+                    //write Flow Intervale values to file
+                    writer.println( "QINT     " + year + "     " + lowerFlowInterval + "     " + upperFlowInterval + "\n" );
+                }
             }
         }
         System.out.println( "Weighted spc file located at:\t" + path );