@@ -6,7 +6,7 @@ |
import java.util.Calendar; |
|
/** |
-* Last Updated: 30-January-2015 |
+* Last Updated: 2-February-2015 |
* @author Tyler Wible |
* @since 16-December-2014 |
*/ |
@@ -137,6 +137,9 @@ |
//Pull data |
String[][] data_jan = doubleArray.getSeasonalData(data_all, "01-01", "01-31"); |
String[][] data_feb = doubleArray.getSeasonalData(data_all, "02-01", "02-28"); |
+ if(m == 30){ |
+ data_feb = doubleArray.getSeasonalData(data_all, "02-01", "03-03"); |
+ } |
String[][] data_mar = doubleArray.getSeasonalData(data_all, "03-01", "03-31"); |
String[][] data_apr = doubleArray.getSeasonalData(data_all, "04-01", "04-30"); |
String[][] data_may = doubleArray.getSeasonalData(data_all, "05-01", "05-31"); |
@@ -399,28 +402,50 @@ |
* @throws ParseException |
*/ |
public String CDPHE_REG31(String[][] flowData) throws IOException, ParseException{ |
+ DoubleArray doubleArray = new DoubleArray(); |
+ DoubleMath doubleMath = new DoubleMath(); |
+ |
+ ArrayList<Integer> monthlyRowIndex = new ArrayList<Integer>(); |
+ monthlyRowIndex.add(1); |
+ monthlyRowIndex.add(2); |
+ monthlyRowIndex.add(3); |
+ monthlyRowIndex.add(4); |
+ monthlyRowIndex.add(5); |
+ monthlyRowIndex.add(6); |
+ monthlyRowIndex.add(7); |
+ monthlyRowIndex.add(8); |
+ monthlyRowIndex.add(9); |
+ monthlyRowIndex.add(10); |
+ monthlyRowIndex.add(11); |
+ monthlyRowIndex.add(12); |
+ |
//Calculate acute biologically based low flows (1-day 3-year) |
System.out.println("Calcualting Reg. 31 1E3 Acute Monthly Low Flows..."); |
- double[] monthlyBiologically_1day = CDPHE_Biological(flowData, 1, 3, 120, 5); |
+ double[] monthlyBiological_1day = CDPHE_Biological(flowData, 1, 3, 120, 5); |
+ double monlyBiological_1day_min = doubleMath.min(doubleArray.getRows(monthlyBiological_1day, monthlyRowIndex)); |
|
//Calculate chronic biologically based low flows (7-day 3-year) |
System.out.println("Calcualting Reg. 31 7E3 Chronic Monthly Low Flows..."); |
- double[] monthlyBiologically_7day = CDPHE_Biological(flowData, 7, 3, 120, 5); |
+ double[] monthlyBiological_7day = CDPHE_Biological(flowData, 7, 3, 120, 5); |
+ double monlyBiological_7day_min = doubleMath.min(doubleArray.getRows(monthlyBiological_7day, monthlyRowIndex)); |
|
//Calculate chronic biologically based low flows (30-day 3-year) |
System.out.println("Calcualting Reg. 31 30E3 Chronic Monthly Low Flows..."); |
- double[] monthlyBiologically_30day = CDPHE_Biological(flowData, 30, 3, 120, 5); |
+ double[] monthlyBiological_30day = CDPHE_Biological(flowData, 30, 3, 120, 5); |
+ double monlyBiological_30day_min = doubleMath.min(doubleArray.getRows(monthlyBiological_30day, monthlyRowIndex)); |
|
//Calculate annual median of data with a 5-year return period |
System.out.println("Calcualting Reg. 31 1E5 Annual Median of Daily Average Flows..."); |
double median_R_yearFlow = annualMedianReturnPeriod(flowData, 5); |
+ median_R_yearFlow = doubleMath.round(median_R_yearFlow, 3); |
|
//Format the results into a summary table |
String summaryTable = "Month\t1E3 Acute Monthly Low Flows\t7E3 Chronic Monthly Low Flows\t30E3 Chronic Monthly Low Flows"; |
- String[] months = {"Entire Record", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; |
+ String[] months = {"Entire Record", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "Lowest Monthly Flow"}; |
for(int i=0; i<13; i++){ |
- summaryTable = summaryTable + "\r\n" + months[i] + "\t" + monthlyBiologically_1day[i] + "\t" + monthlyBiologically_7day[i] + "\t" + monthlyBiologically_30day[i]; |
+ summaryTable = summaryTable + "\r\n" + months[i] + "\t" + monthlyBiological_1day[i] + "\t" + monthlyBiological_7day[i] + "\t" + monthlyBiological_30day[i]; |
} |
+ summaryTable = summaryTable + "\r\n" + months[13] + "\t" + monlyBiological_1day_min + "\t" + monlyBiological_7day_min + "\t" + monlyBiological_30day_min; |
summaryTable = summaryTable + "\r\n" + median_R_yearFlow; |
|
return summaryTable; |
@@ -438,8 +463,10 @@ |
while(moreYears){ |
//Get current year's data and calculate it's statistics |
String[][] partialData = doubleArray.getYearsData(flowData, currentYear); |
- double[] flowOnlyData = convertSecondColumn(partialData); |
- medianFlows.add(doubleMath.Median(flowOnlyData)); |
+ if(partialData.length > 0){ |
+ double[] flowOnlyData = convertSecondColumn(partialData); |
+ medianFlows.add(doubleMath.Median(flowOnlyData)); |
+ } |
|
int nextYear = Integer.parseInt(currentYear) + 1; |
if(finalYear.compareToIgnoreCase(String.valueOf(nextYear)) >= 0){ |
@@ -450,7 +477,7 @@ |
} |
|
//Calculate return period of data |
- double median_RyearFlow = doubleArray.calculateReturnPeriod(medianFlows, R); |
+ double median_RyearFlow = doubleArray.calculateLowFlowReturnPeriod(medianFlows, R); |
return median_RyearFlow; |
} |
} |
@@ -49,7 +49,7 @@ |
} |
} |
/** |
-* Last Updated: 29-January-2015 |
+* Last Updated: 2-February-2015 |
* @author Tyler Wible |
* @since 21-June-2012 |
*/ |
@@ -899,14 +899,12 @@ |
return SeasonalData; |
} |
/** |
- * Calculate the flow associated with the n-year return period from the set of annual data |
+ * Calculate the flow associated with the n-year return period from the set of annual low flow data |
* @param nYearFlows a list of annual flow values (aka one value per year) |
* @param n the n-year return period for the desired flow |
* @return |
*/ |
- public double calculateReturnPeriod(ArrayList<Double> nYearFlows, int n){ |
- DoubleArray doubleArray = new DoubleArray(); |
- |
+ public double calculateLowFlowReturnPeriod(ArrayList<Double> nYearFlows, double n){ |
//Remove non-values |
int ctr = 0; |
for(int i=0; i<nYearFlows.size(); i++){ |
@@ -925,19 +923,14 @@ |
} |
|
//Get ranks for remaining annual data |
- double[][] nYearRanks = doubleArray.weibullPlottingPosition(nYearData); |
+ double[][] nYearRanks = weibullPlottingPosition(nYearData); |
+ double[] nYearNonExceedance = getColumn(nYearRanks,0); |
+ double[] nYearValues = getColumn(nYearRanks,1); |
|
//Find the "n" recurrence interval and return its corresponding flow as the n-year Flow |
- double n_yearFlow = 0; |
- double target = (double) n/10; |
- for(int i=0; i<(nYearRanks.length - 1); i++){ |
- if(n < nYearRanks[i][0] && n > nYearRanks[i+1][0]){ |
- //Linear interpolation for flow value for "n" recurrence interval |
- n_yearFlow = ((target - nYearRanks[i+1][0])/(nYearRanks[i][0] - nYearRanks[i+1][0]))*(nYearRanks[i][1] - nYearRanks[i+1][1]) + nYearRanks[i+1][1]; |
- }else if(n == nYearRanks[i][0]){ |
- n_yearFlow = nYearRanks[i][1]; |
- } |
- } |
+ DoubleMath doubleMath = new DoubleMath(); |
+ double target = (1-(1.0/n)) * 100.0;//nonexceedance = (1 - [exceedance = (1/return period)]) * 100 //to get range of 0-100 |
+ double n_yearFlow = doubleMath.linearInterpolation(nYearNonExceedance, nYearValues, target); |
return n_yearFlow; |
} |
/** |