@@ -10,12 +10,9 @@ |
import csip.annotations.VersionInfo; |
import csip.api.server.Executable; |
import java.io.File; |
-import java.io.IOException; |
import javax.ws.rs.Path; |
-import m.cfa.baseflow.guiBaseflow_Model; |
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") |
@@ -55,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.setPerceptionThresholds( inputPayload.getJSONArray( "perception_thresholds", new JSONArray() ) ); |
model.setExecutable( e ); |
} |
|
@@ -17,6 +17,8 @@ |
import java.util.Date; |
import java.util.Scanner; |
import org.codehaus.jettison.json.JSONArray; |
+import org.codehaus.jettison.json.JSONException; |
+import org.codehaus.jettison.json.JSONObject; |
|
/** |
* Last Updated: 9-April-2019 |
@@ -60,6 +62,7 @@ |
private double highSystematicThreshold = Double.NaN; |
private String lowOutlierMethod = ""; |
private double lowOutlierThreshold = Double.NaN; |
+ JSONArray perceptionThresholds = new JSONArray(); |
public Bulletin17CResults stationResult; |
public Bulletin17CResults weightedResult; |
|
@@ -220,6 +223,10 @@ |
public void setLowOutlierThreshold( double lowOutlierThreshold ) { |
this.lowOutlierThreshold = lowOutlierThreshold; |
} |
+ |
+ public void setPerceptionThresholds( JSONArray perceptionThresholds ) { |
+ this.perceptionThresholds = perceptionThresholds; |
+ } |
|
public void setExecutable( Executable e ) { |
c17Exe = e; |
@@ -278,7 +285,7 @@ |
* line of the text file |
* @throws IOException |
*/ |
- private void writeC17inputFiles( double[][] peakFlows ) throws IOException { |
+ private void writeC17inputFiles( double[][] peakFlows ) throws IOException, JSONException { |
//Fix Start and End year to match the USGS data file. |
String startYear = new DecimalFormat( "#" ).format( peakFlows[ 0 ][ 0 ] ); |
String endYear = new DecimalFormat( "#" ).format( peakFlows[ peakFlows.length - 1 ][ 0 ] ); |
@@ -308,7 +315,21 @@ |
writer.println( "LOTHRESH " + this.lowOutlierThreshold + "\n" ); //TODO: read in from json params |
} |
writer.println( "SKEWOPT WEIGHTED\n" ); //TODO: Run model twice, once with weighted, once with station |
- writer.println( "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. |
+ } |
|
//Then the peak flow values. |
for ( double[] peakFlow : peakFlows ) { |