@@ -55,6 +55,25 @@ |
String start = "?"; |
String end = "?"; |
String dataSource = "?"; |
+ double bflowStream_max = -1; |
+ double bflowStream_min = -1; |
+ double bflowStream_median = -1; |
+ double bflowStream_mean = -1; |
+ |
+ double bflow1_max = -1; |
+ double bflow1_min = -1; |
+ double bflow1_median = -1; |
+ double bflow1_mean = -1; |
+ |
+ double bflow2_max = -1; |
+ double bflow2_min = -1; |
+ double bflow2_median = -1; |
+ double bflow2_mean = -1; |
+ |
+ double bflow3_max = -1; |
+ double bflow3_min = -1; |
+ double bflow3_median = -1; |
+ double bflow3_mean = -1; |
|
//Gets |
public File getBaseflow_out() { |
@@ -82,6 +101,54 @@ |
public String getDataSource(){ |
return dataSource; |
} |
+ public String getBFLOWstream_Max(){ |
+ return String.valueOf(bflowStream_max); |
+ } |
+ public String getBFLOWstream_Min(){ |
+ return String.valueOf(bflowStream_min); |
+ } |
+ public String getBFLOWstream_Median(){ |
+ return String.valueOf(bflowStream_median); |
+ } |
+ public String getBFLOWstream_Mean(){ |
+ return String.valueOf(bflowStream_mean); |
+ } |
+ public String getBFLOWpass1_Max(){ |
+ return String.valueOf(bflow1_max); |
+ } |
+ public String getBFLOWpass1_Min(){ |
+ return String.valueOf(bflow1_min); |
+ } |
+ public String getBFLOWpass1_Median(){ |
+ return String.valueOf(bflow1_median); |
+ } |
+ public String getBFLOWpass1_Mean(){ |
+ return String.valueOf(bflow1_mean); |
+ } |
+ public String getBFLOWpass2_Max(){ |
+ return String.valueOf(bflow2_max); |
+ } |
+ public String getBFLOWpass2_Min(){ |
+ return String.valueOf(bflow2_min); |
+ } |
+ public String getBFLOWpass2_Median(){ |
+ return String.valueOf(bflow2_median); |
+ } |
+ public String getBFLOWpass2_Mean(){ |
+ return String.valueOf(bflow2_mean); |
+ } |
+ public String getBFLOWpass3_Max(){ |
+ return String.valueOf(bflow3_max); |
+ } |
+ public String getBFLOWpass3_Min(){ |
+ return String.valueOf(bflow3_min); |
+ } |
+ public String getBFLOWpass3_Median(){ |
+ return String.valueOf(bflow3_median); |
+ } |
+ public String getBFLOWpass3_Mean(){ |
+ return String.valueOf(bflow3_mean); |
+ } |
|
//Sets |
public void setMainFolder(String mainFolder) { |
@@ -212,13 +279,11 @@ |
* @throws IOException |
*/ |
private void graphBFLOWresults(String[][] sortedData_user) throws IOException{ |
- DoubleMath doubleMath = new DoubleMath(); |
Graphing graphing = new Graphing(); |
|
//Pull out results to be graphed |
String[][] baseFlowResults = readBFLOWresults(mainFolder); |
|
- |
//Create TimeSeries to graph of the stream flow, baseflow1, baseflow2, and baseflow3 |
TimeSeries streamflow_series = new TimeSeries("Streamflow"); |
TimeSeries baseflow1_series = new TimeSeries("Base-flow Pass 1"); |
@@ -228,23 +293,20 @@ |
TimeSeries baseflow1_series_user = new TimeSeries("Base-flow Pass 1 User Data"); |
TimeSeries baseflow2_series_user = new TimeSeries("Base-flow Pass 2 User Data"); |
TimeSeries baseflow3_series_user = new TimeSeries("Base-flow Pass 3 User Data"); |
- ArrayList<Double> baseflowPass1 = new ArrayList<Double>(); |
String[][] graphData = new String[baseFlowResults.length][5]; |
- int day = 1, month = 1, year = 1900, ctr = 0; |
- double d =1, m =1, y=1; |
+ int ctr = 0; |
for(int i=0; i < baseFlowResults.length; i++) { |
double streamFlow = Double.parseDouble(baseFlowResults[i][3]); |
double baseFlow1 = Double.parseDouble(baseFlowResults[i][4]); |
double baseFlow2 = Double.parseDouble(baseFlowResults[i][5]); |
double baseFlow3 = Double.parseDouble(baseFlowResults[i][6]); |
- baseflowPass1.add(baseFlow1); |
//Re-format date for graph |
- y = Double.parseDouble(baseFlowResults[i][0]); |
- m = Double.parseDouble(baseFlowResults[i][1]); |
- d = Double.parseDouble(baseFlowResults[i][2]); |
- year = (int)y; |
- month = (int)m; |
- day = (int)d; |
+ double y = Double.parseDouble(baseFlowResults[i][0]); |
+ double m = Double.parseDouble(baseFlowResults[i][1]); |
+ double d = Double.parseDouble(baseFlowResults[i][2]); |
+ int year = (int)y; |
+ int month = (int)m; |
+ int day = (int)d; |
if(year >= 1900){//artificial limit for JFreeCharts' "Day" class |
Day date = new Day(day,month,year);//day,month,year |
streamflow_series.add(date, streamFlow); |
@@ -286,7 +348,9 @@ |
} |
} |
} |
- double baseflowMax = doubleMath.max(baseflowPass1); |
+ |
+ //Save statistics of the baseflow |
+ calculateBFLOWstats(graphData); |
|
//Save results for graphing with JSHighcharts |
DoubleArray doubleArray = new DoubleArray(); |
@@ -316,7 +380,7 @@ |
|
//Define Y Axis |
ValueAxis rangeTime = new NumberAxis("Flow [cfs]"); |
- rangeTime.setRange(0, baseflowMax); |
+ rangeTime.setRange(0, bflow1_max); |
plotTime.setRangeAxis(0, rangeTime); |
|
//Define X Axis |
@@ -429,6 +493,45 @@ |
|
return resultArray; |
} |
+ private void calculateBFLOWstats(String[][] graphData){ |
+ DoubleMath doubleMath = new DoubleMath(); |
+ |
+ //Calculate the statistics for each baseflow filter pass |
+ this.bflowStream_max = doubleMath.max(getColumn(graphData,1)); |
+ this.bflowStream_min = doubleMath.min(getColumn(graphData,1)); |
+ this.bflowStream_median = doubleMath.Median(getColumn(graphData,1)); |
+ this.bflowStream_mean = doubleMath.Average(getColumn(graphData,1)); |
+ |
+ this.bflow1_max = doubleMath.max(getColumn(graphData,2)); |
+ this.bflow1_min = doubleMath.min(getColumn(graphData,2)); |
+ this.bflow1_median = doubleMath.Median(getColumn(graphData,2)); |
+ this.bflow1_mean = doubleMath.Average(getColumn(graphData,2)); |
+ |
+ this.bflow2_max = doubleMath.max(getColumn(graphData,3)); |
+ this.bflow2_min = doubleMath.min(getColumn(graphData,3)); |
+ this.bflow2_median = doubleMath.Median(getColumn(graphData,3)); |
+ this.bflow2_mean = doubleMath.Average(getColumn(graphData,3)); |
+ |
+ this.bflow3_max = doubleMath.max(getColumn(graphData,4)); |
+ this.bflow3_min = doubleMath.min(getColumn(graphData,4)); |
+ this.bflow3_median = doubleMath.Median(getColumn(graphData,4)); |
+ this.bflow3_mean = doubleMath.Average(getColumn(graphData,4)); |
+ } |
+ /** |
+ * Creates a double[] array of the elements in dataArray[all][column] |
+ * @param dataArray the string[][] data array |
+ * @param column the desired column from data array (zero based) |
+ * @return a double[] array of the elements in dataArray[all][column] |
+ */ |
+ private double[] getColumn(String[][] dataArray, int column){ |
+ //Gets the values of dataArray[all][column] in a double[] |
+ double[] currentElements = new double[dataArray.length]; |
+ |
+ for(int i=0; i<dataArray.length; i++){ |
+ currentElements[i] = Double.parseDouble(dataArray[i][column]); |
+ } |
+ return currentElements; |
+ } |
/** |
* Takes the input String[][] and reformats it to the desired input for |
* BFLOW (a two column tab delimited file) which is: the first column of |
@@ -26,7 +26,7 @@ |
import org.jfree.data.xy.XYSeriesCollection; |
|
/** |
-* Last Updated: 7-November-2014 |
+* Last Updated: 24-November-2014 |
* @author Tyler Wible |
* @since 12-June-2011 |
*/ |
@@ -289,11 +289,18 @@ |
m = Integer.parseInt(mString); |
n = Integer.parseInt(nString); |
} |
+ |
+ //Calculate the flow stats file |
FlowStatistics flowStats = new FlowStatistics(); |
Object[] returnValue = flowStats.calculateAllStatisticsSummaries(mainFolder, stationID, stationName, sortedData_combined, highPercentile, lowPercentile, m, n, true, |
seasonBegin, seasonEnd, period1Begin, period1End, period2Begin, period2End, period3Begin, period3End); |
double mQn = (Double) returnValue[0]; |
String MQNmessage = (String) returnValue[1]; |
+ if(!mQnHide){ |
+ this.lowFlowErrorMessage = MQNmessage; |
+ DoubleMath doubleMath = new DoubleMath(); |
+ this.mQnVal = doubleMath.round(mQn, 2); |
+ } |
this.start = sortedData_combined[0][0]; |
this.end = sortedData_combined[sortedData_combined.length - 1][0]; |
this.flowLen = String.valueOf(sortedData_combined.length); |
@@ -307,11 +314,6 @@ |
|
//Attach analysis summary to return object |
this.summaryParagraph = dynamicParagraph("Flow Duration Curve Overview: "); |
- DoubleMath doubleMath = new DoubleMath(); |
- if(!mQnHide){ |
- this.lowFlowErrorMessage = MQNmessage; |
- this.mQnVal = doubleMath.round(mQn, 2); |
- } |
} |
/** |
* Main graphing function for FDC analysis, plots the provided xyRanks as x,y points on a graph |
@@ -672,6 +674,8 @@ |
m = Integer.parseInt(mString); |
n = Integer.parseInt(nString); |
} |
+ |
+ //Calculate the flow stats file |
FlowStatistics flowStats = new FlowStatistics(); |
Object[] returnValue = flowStats.calculateAllStatisticsSummaries(mainFolder, stationID, stationName, sortedData_combined, highPercentile, lowPercentile, m, n, true, |
seasonBegin, seasonEnd, period1Begin, period1End, period2Begin, period2End, period3Begin, period3End); |
@@ -679,6 +683,14 @@ |
String MQNmessage = (String) returnValue[1]; |
//Also multiply the mQn flow value(cfs) by the conversion and water quality target |
mQn = mQn*conversion*wqTarget; |
+ if(!mQnHide){ |
+ if(!MQNmessage.equalsIgnoreCase("")){//if the MQNmessage is not blank add it to the dynamic summary |
+ this.lowFlowErrorMessage = MQNmessage; |
+ }else{ |
+ DoubleMath doubleMath = new DoubleMath(); |
+ this.mQnVal = doubleMath.round(mQn, 2); |
+ } |
+ } |
this.start = sortedData_combined[0][0]; |
this.end = sortedData_combined[sortedData_combined.length - 1][0]; |
this.flowLen = String.valueOf(sortedData_combined.length); |
@@ -699,14 +711,6 @@ |
this.wqLen = String.valueOf(totalCount); |
this.wqUnits = endUnits; |
this.summaryParagraph = dynamicParagraph(paragraphTitle); |
- DoubleMath doubleMath = new DoubleMath(); |
- if(!mQnHide){ |
- if(!MQNmessage.equalsIgnoreCase("")){//if the MQNmessage is not blank add it to the dynamic summary |
- this.lowFlowErrorMessage = MQNmessage; |
- }else{ |
- this.mQnVal = doubleMath.round(mQn, 2); |
- } |
- } |
} |
/** |
* Sub-graphing function to create combined-range graph |
@@ -1473,12 +1477,6 @@ |
Date currentDate = new Date(); |
endDate = desiredDateFormat.format(currentDate); |
} |
- |
- //If no specified season, create default |
- if(seasonBegin == null || seasonBegin.equalsIgnoreCase("") || seasonEnd == null || seasonEnd.equalsIgnoreCase("")){ |
- seasonBegin = "April"; |
- seasonEnd = "October"; |
- } |
|
//Determine which Duration Curve method to run, FDC or LDC |
if(modelType.equalsIgnoreCase("FDC")){ |
@@ -40,7 +40,7 @@ |
import org.jfree.data.xy.XYSeriesCollection; |
|
/** |
-* Last Updated: 4-September-2014 |
+* Last Updated: 24-November-2014 |
* @author Tyler Wible |
* @since 24-June-2011 |
*/ |
@@ -56,8 +56,6 @@ |
String endDate = ""; |
String timeStep = "Daily";//"Yearly";//"Monthly";// |
String method = "Max";//"Min";//"Average";//"Total";// |
- double highPercentile = 0.75; |
- double lowPercentile = 0.25; |
int numBins = 10; |
boolean logarithmicTF = true; |
String seasonBegin = "06-01";//"MM-dd" |
@@ -69,6 +67,8 @@ |
String period3Begin = ""; |
String period3End = ""; |
boolean medianTF = false; |
+ double highPercentile = 0.75; |
+ double lowPercentile = 0.25; |
String userData = "";//"Date\tFlow\n1999-04-29\t8.3\n1999-05-09\t60.2\n1999-05-29\t20.1";// |
boolean mergeDatasets = false;//true;// |
String mergeMethod = "user";//"public";//"max";//"average";//"min";// |
@@ -374,12 +374,6 @@ |
public void setMethod(String method) { |
this.method = method; |
} |
- public void setHighPercentile(double highPercentile) { |
- this.highPercentile = highPercentile; |
- } |
- public void setLowPercentile(double lowPercentile) { |
- this.lowPercentile = lowPercentile; |
- } |
public void setNumberOfBins(int numBins) { |
this.numBins = numBins; |
} |
@@ -413,6 +407,12 @@ |
public void setMedianTF(boolean medianTF) { |
this.medianTF = medianTF; |
} |
+ public void setHighPercentile(double highPercentile) { |
+ this.highPercentile = highPercentile; |
+ } |
+ public void setLowPercentile(double lowPercentile) { |
+ this.lowPercentile = lowPercentile; |
+ } |
public void setUserData(String userData) { |
this.userData = userData; |
} |
@@ -69,6 +69,26 @@ |
result.put(JSONUtils.data("baseflow_summary", baseflowSummary)); |
result.put(JSONUtils.data("baseflow_results", model.getBaseflow_out().getName())); |
result.put(JSONUtils.data("graph", model.getGraph())); |
+ //Get BFLOW stream flow stats |
+ result.put(JSONUtils.data("streamflow_max", model.getBFLOWstream_Max())); |
+ result.put(JSONUtils.data("streamflow_min", model.getBFLOWstream_Min())); |
+ result.put(JSONUtils.data("streamflow_median", model.getBFLOWstream_Median())); |
+ result.put(JSONUtils.data("streamflow_mean", model.getBFLOWstream_Mean())); |
+ //Get BFLOW pass 1 stats |
+ result.put(JSONUtils.data("bflowPass1_max", model.getBFLOWpass1_Max())); |
+ result.put(JSONUtils.data("bflowPass1_min", model.getBFLOWpass1_Min())); |
+ result.put(JSONUtils.data("bflowPass1_median", model.getBFLOWpass1_Median())); |
+ result.put(JSONUtils.data("bflowPass1_mean", model.getBFLOWpass1_Mean())); |
+ //Get BFLOW pass 2 stats |
+ result.put(JSONUtils.data("bflowPass2_max", model.getBFLOWpass2_Max())); |
+ result.put(JSONUtils.data("bflowPass2_min", model.getBFLOWpass2_Min())); |
+ result.put(JSONUtils.data("bflowPass2_median", model.getBFLOWpass2_Median())); |
+ result.put(JSONUtils.data("bflowPass2_mean", model.getBFLOWpass2_Mean())); |
+ //Get BFLOW pass 3 stats |
+ result.put(JSONUtils.data("bflowPass3_max", model.getBFLOWpass3_Max())); |
+ result.put(JSONUtils.data("bflowPass3_min", model.getBFLOWpass3_Min())); |
+ result.put(JSONUtils.data("bflowPass3_median", model.getBFLOWpass3_Median())); |
+ result.put(JSONUtils.data("bflowPass3_mean", model.getBFLOWpass3_Mean())); |
|
//Get result files for JSHighCharts |
String graphDataFiles = model.getTimeseriesOutput().getName(); |