@@ -399,17 +399,61 @@ |
writer.print( "LOTHRESH " + this.lowOutlierThreshold + "\n" ); //TODO: read in from json params |
} |
writer.print( "SKEWOPT STATION\n" ); |
- writer.print( "THRESHOLD " + startYear + " " + endYear + " 0 1.00E+010\n" ); //Just something to make it run for now. |
+ if (this.perceptionThresholds.length() > 0) { |
+ for (int i=0; i<this.perceptionThresholds.length(); i++) { |
+ JSONObject singlePerceptionThreshold = (JSONObject) this.perceptionThresholds.get(i); |
+ String startStr = (String) singlePerceptionThreshold.get("start_year"); |
+ String endStr = (String) singlePerceptionThreshold.get("end_year"); |
+ String lowerStr = (String) singlePerceptionThreshold.get("min"); |
+ String upperStr = (String) singlePerceptionThreshold.get("max"); |
+ if (upperStr.equalsIgnoreCase("inf")) { |
+ upperStr = "1.00E+010"; |
+ } |
+ writer.println( "THRESHOLD " + startStr + " " + endStr + " " + lowerStr + " " + upperStr + "\n" ); //Just something to make it run for now. |
+ } |
+ } else { |
+ writer.println( "THRESHOLD " + startYear + " " + endYear + " 0 1.00E+010\n" ); //Just something to make it run for now. |
+ } |
//TODO: writer.println("PCPT_TRESH "); |
|
+ //Then the peak flow values. |
for ( double[] peakFlow : peakFlows ) { |
//Convert values to strings to lop off decimal places. |
DecimalFormat df = new DecimalFormat( "#" ); |
String year = df.format( peakFlow[ 0 ] ); |
String rate = df.format( peakFlow[ 1 ] ); |
|
- //write values to file |
- writer.print( "Q " + year + " " + rate + "\n" ); |
+ boolean simpleValue = true; |
+ 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, dischargeRate) != 0 || |
+ Double.compare(upperFlowIntervalNumber, 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 = false; |
+ } |
+ 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" ); |
+ } |
} |
} |
|