@@ -13,7 +13,7 @@ |
import java.util.GregorianCalendar; |
|
/** |
-* Last Updated: 17-March-2016 |
+* Last Updated: 25-March-2016 |
* @author Tyler Wible |
* @since 29-June-2011 |
*/ |
@@ -93,7 +93,7 @@ |
statsSummaryTable[5][0] = "Upper Quartile [cfs]"; |
statsSummaryTable[6][0] = "Lower Quartile [cfs]"; |
statsSummaryTable[7][0] = "Median [cfs]"; |
- statsSummaryTable[8][0] = "Average [cfs]"; |
+ statsSummaryTable[8][0] = "Mean [cfs]"; |
statsSummaryTable[9][0] = "Standard Deviation [cfs]"; |
statsSummaryTable[10][0] = "Variance"; |
statsSummaryTable[11][0] = "Skewness"; |
@@ -110,7 +110,7 @@ |
statsSummaryTable[22][0] = "Dates of Maximum (7-day)"; |
statsSummaryTable[23][0] = "Minimum (7-day) [cfs]"; |
statsSummaryTable[24][0] = "Dates of Minimum (7-day)"; |
- statsSummaryTable[25][0] = "Minimum (7-day) / Annual Average [cfs]"; |
+ statsSummaryTable[25][0] = "Minimum (7-day) / Annual Mean [cfs]"; |
statsSummaryTable[26][0] = "Maximum (30-day) [cfs]"; |
statsSummaryTable[27][0] = "Dates of Maximum (30-day)"; |
statsSummaryTable[28][0] = "Minimum (30-day) [cfs]"; |
@@ -139,7 +139,7 @@ |
statsSummaryTable[51][0] = "Season " + seasonBegin + " to " + seasonEnd + " (Upper Quartile) [cfs]"; |
statsSummaryTable[52][0] = "Season " + seasonBegin + " to " + seasonEnd + " (Lower Quartile) [cfs]"; |
statsSummaryTable[53][0] = "Season " + seasonBegin + " to " + seasonEnd + " (Median) [cfs]"; |
- statsSummaryTable[54][0] = "Season " + seasonBegin + " to " + seasonEnd + " (Average) [cfs]"; |
+ statsSummaryTable[54][0] = "Season " + seasonBegin + " to " + seasonEnd + " (Mean) [cfs]"; |
statsSummaryTable[55][0] = "Season " + seasonBegin + " to " + seasonEnd + " (Standard Deviation) [cfs]"; |
statsSummaryTable[56][0] = "Season " + seasonBegin + " to " + seasonEnd + " (Variance)"; |
statsSummaryTable[57][0] = "Season " + seasonBegin + " to " + seasonEnd + " (Skewness)"; |
@@ -152,7 +152,7 @@ |
statsSummaryTable[62][0] = "January (Upper Quartile) [cfs]"; |
statsSummaryTable[63][0] = "January (Lower Quartile) [cfs]"; |
statsSummaryTable[64][0] = "January (Median) [cfs]"; |
- statsSummaryTable[65][0] = "January (Average) [cfs]"; |
+ statsSummaryTable[65][0] = "January (Mean) [cfs]"; |
statsSummaryTable[66][0] = "January (Standard Deviation) [cfs]"; |
statsSummaryTable[67][0] = "January (Variance)"; |
statsSummaryTable[68][0] = "January (Skewness)"; |
@@ -163,7 +163,7 @@ |
statsSummaryTable[73][0] = "February (Upper Quartile) [cfs]"; |
statsSummaryTable[74][0] = "February (Lower Quartile) [cfs]"; |
statsSummaryTable[75][0] = "February (Median) [cfs]"; |
- statsSummaryTable[76][0] = "February (Average) [cfs]"; |
+ statsSummaryTable[76][0] = "February (Mean) [cfs]"; |
statsSummaryTable[77][0] = "February (Standard Deviation) [cfs]"; |
statsSummaryTable[78][0] = "February (Variance)"; |
statsSummaryTable[79][0] = "February (Skewness)"; |
@@ -174,7 +174,7 @@ |
statsSummaryTable[84][0] = "March (Upper Quartile) [cfs]"; |
statsSummaryTable[85][0] = "March (Lower Quartile) [cfs]"; |
statsSummaryTable[86][0] = "March (Median) [cfs]"; |
- statsSummaryTable[87][0] = "March (Average) [cfs]"; |
+ statsSummaryTable[87][0] = "March (Mean) [cfs]"; |
statsSummaryTable[88][0] = "March (Standard Deviation) [cfs]"; |
statsSummaryTable[89][0] = "March (Variance)"; |
statsSummaryTable[90][0] = "March (Skewness)"; |
@@ -185,7 +185,7 @@ |
statsSummaryTable[95][0] = "April (Upper Quartile) [cfs]"; |
statsSummaryTable[96][0] = "April (Lower Quartile) [cfs]"; |
statsSummaryTable[97][0] = "April (Median) [cfs]"; |
- statsSummaryTable[98][0] = "April (Average) [cfs]"; |
+ statsSummaryTable[98][0] = "April (Mean) [cfs]"; |
statsSummaryTable[99][0] = "April (Standard Deviation) [cfs]"; |
statsSummaryTable[100][0] = "April (Variance)"; |
statsSummaryTable[101][0] = "April (Skewness)"; |
@@ -196,7 +196,7 @@ |
statsSummaryTable[106][0] = "May (Upper Quartile) [cfs]"; |
statsSummaryTable[107][0] = "May (Lower Quartile) [cfs]"; |
statsSummaryTable[108][0] = "May (Median) [cfs]"; |
- statsSummaryTable[109][0] = "May (Average) [cfs]"; |
+ statsSummaryTable[109][0] = "May (Mean) [cfs]"; |
statsSummaryTable[110][0] = "May (Standard Deviation) [cfs]"; |
statsSummaryTable[111][0] = "May (Variance)"; |
statsSummaryTable[112][0] = "May (Skewness)"; |
@@ -207,7 +207,7 @@ |
statsSummaryTable[117][0] = "June (Upper Quartile) [cfs]"; |
statsSummaryTable[118][0] = "June (Lower Quartile) [cfs]"; |
statsSummaryTable[119][0] = "June (Median) [cfs]"; |
- statsSummaryTable[120][0] = "June (Average) [cfs]"; |
+ statsSummaryTable[120][0] = "June (Mean) [cfs]"; |
statsSummaryTable[121][0] = "June (Standard Deviation) [cfs]"; |
statsSummaryTable[122][0] = "June (Variance)"; |
statsSummaryTable[123][0] = "June (Skewness)"; |
@@ -218,7 +218,7 @@ |
statsSummaryTable[128][0] = "July (Upper Quartile) [cfs]"; |
statsSummaryTable[129][0] = "July (Lower Quartile) [cfs]"; |
statsSummaryTable[130][0] = "July (Median) [cfs]"; |
- statsSummaryTable[131][0] = "July (Average) [cfs]"; |
+ statsSummaryTable[131][0] = "July (Mean) [cfs]"; |
statsSummaryTable[132][0] = "July (Standard Deviation) [cfs]"; |
statsSummaryTable[133][0] = "July (Variance)"; |
statsSummaryTable[134][0] = "July (Skewness)"; |
@@ -229,7 +229,7 @@ |
statsSummaryTable[139][0] = "August (Upper Quartile) [cfs]"; |
statsSummaryTable[140][0] = "August (Lower Quartile) [cfs]"; |
statsSummaryTable[141][0] = "August (Median) [cfs]"; |
- statsSummaryTable[142][0] = "August (Average) [cfs]"; |
+ statsSummaryTable[142][0] = "August (Mean) [cfs]"; |
statsSummaryTable[143][0] = "August (Standard Deviation) [cfs]"; |
statsSummaryTable[144][0] = "August (Variance)"; |
statsSummaryTable[145][0] = "August (Skewness)"; |
@@ -240,7 +240,7 @@ |
statsSummaryTable[150][0] = "September (Upper Quartile) [cfs]"; |
statsSummaryTable[151][0] = "September (Lower Quartile) [cfs]"; |
statsSummaryTable[152][0] = "September (Median) [cfs]"; |
- statsSummaryTable[153][0] = "September (Average) [cfs]"; |
+ statsSummaryTable[153][0] = "September (Mean) [cfs]"; |
statsSummaryTable[154][0] = "September (Standard Deviation) [cfs]"; |
statsSummaryTable[155][0] = "September (Variance)"; |
statsSummaryTable[156][0] = "September (Skewness)"; |
@@ -251,7 +251,7 @@ |
statsSummaryTable[161][0] = "October (Upper Quartile) [cfs]"; |
statsSummaryTable[162][0] = "October (Lower Quartile) [cfs]"; |
statsSummaryTable[163][0] = "October (Median) [cfs]"; |
- statsSummaryTable[164][0] = "October (Average) [cfs]"; |
+ statsSummaryTable[164][0] = "October (Mean) [cfs]"; |
statsSummaryTable[165][0] = "October (Standard Deviation) [cfs]"; |
statsSummaryTable[166][0] = "October (Variance)"; |
statsSummaryTable[167][0] = "October (Skewness)"; |
@@ -262,7 +262,7 @@ |
statsSummaryTable[172][0] = "November (Upper Quartile) [cfs]"; |
statsSummaryTable[173][0] = "November (Lower Quartile) [cfs]"; |
statsSummaryTable[174][0] = "November (Median) [cfs]"; |
- statsSummaryTable[175][0] = "November (Average) [cfs]"; |
+ statsSummaryTable[175][0] = "November (Mean) [cfs]"; |
statsSummaryTable[176][0] = "November (Standard Deviation) [cfs]"; |
statsSummaryTable[177][0] = "November (Variance)"; |
statsSummaryTable[178][0] = "November (Skewness)"; |
@@ -273,7 +273,7 @@ |
statsSummaryTable[183][0] = "December (Upper Quartile) [cfs]"; |
statsSummaryTable[184][0] = "December (Lower Quartile) [cfs]"; |
statsSummaryTable[185][0] = "December (Median) [cfs]"; |
- statsSummaryTable[186][0] = "December (Average) [cfs]"; |
+ statsSummaryTable[186][0] = "December (Mean) [cfs]"; |
statsSummaryTable[187][0] = "December (Standard Deviation) [cfs]"; |
statsSummaryTable[188][0] = "December (Variance)"; |
statsSummaryTable[189][0] = "December (Skewness)"; |
@@ -52,7 +52,7 @@ |
import org.jfree.ui.RectangleInsets; |
|
/** |
-* Last Updated: 21-March-2016 |
+* Last Updated: 28-March-2016 |
* @author Tyler Wible |
* @since 24-June-2011 |
*/ |
@@ -440,7 +440,6 @@ |
* @param showLine a boolean, if true lines will be shown on the graph, if false only shapes for the data |
* @param yAxisTitle the String label for the y axis of the graph |
* @param units the units of the current graph to be used in labeling for the legend |
- * @param medianTF if true then the median value will be plotted for period analyses, if false the mean (average) will be used |
*/ |
private void createTimeseriesGraph(String[][] sortedData, |
String[][] sortedData_user, |
@@ -451,12 +450,76 @@ |
Color color2, |
boolean showLine, |
String yAxisTitle, |
- String units, |
- boolean medianTF) throws ParseException { |
+ String units) throws ParseException, IOException { |
DoubleArray doubleArray = new DoubleArray(); |
Graphing graphing = new Graphing(); |
- DateFormat desiredDateFormat = doubleArray.getDateFormat("daily", false); |
- Date jfreeChartDateLimit = desiredDateFormat.parse("1900-01-01"); |
+ DateFormat periodDateFormat = doubleArray.getDateFormat("daily", false); |
+ Date jfreeChartDateLimit = periodDateFormat.parse("1900-01-01"); |
+ |
+ //Re-Format graphing data for output for use with JHighChart |
+ Date period1Begin_date = new Date(); |
+ Date period1End_date = new Date(); |
+ Date period2Begin_date = new Date(); |
+ Date period2End_date = new Date(); |
+ Date period3Begin_date = new Date(); |
+ Date period3End_date = new Date(); |
+ if(!period1Begin.isEmpty() && !period1End.isEmpty()){ |
+ period1Begin_date = periodDateFormat.parse(period1Begin); |
+ period1End_date = periodDateFormat.parse(period1End); |
+ } |
+ if(!period2Begin.isEmpty() && !period2End.isEmpty()){ |
+ period2Begin_date = periodDateFormat.parse(period2Begin); |
+ period2End_date = periodDateFormat.parse(period2End); |
+ } |
+ if(!period3Begin.isEmpty() && !period3End.isEmpty()){ |
+ period3Begin_date = periodDateFormat.parse(period3Begin); |
+ period3End_date = periodDateFormat.parse(period3End); |
+ } |
+ |
+ String[][] graphData = new String[sortedData.length][5]; |
+ DateFormat desiredDateFormat = doubleArray.getDateFormat(timeStep, false); |
+ for(int i=0; i<sortedData.length; i++){ |
+ Date newDate = desiredDateFormat.parse(sortedData[i][0]); |
+ graphData[i][0] = sortedData[i][0]; |
+ graphData[i][1] = sortedData[i][1]; |
+ |
+ //Period1 |
+ if(newDate.compareTo(period1Begin_date) >= 0 && newDate.compareTo(period1End_date) <= 0){ |
+ if(medianTF){ |
+ graphData[i][2] = String.valueOf(median_period1); |
+ }else{ |
+ graphData[i][2] = String.valueOf(mean_period1); |
+ } |
+ }else{ |
+ graphData[i][2] = "-1"; |
+ } |
+ |
+ //Period2 |
+ if(newDate.compareTo(period2Begin_date) >= 0 && newDate.compareTo(period2End_date) <= 0){ |
+ if(medianTF){ |
+ graphData[i][3] = String.valueOf(median_period2); |
+ }else{ |
+ graphData[i][3] = String.valueOf(mean_period2); |
+ } |
+ }else{ |
+ graphData[i][3] = "-1"; |
+ } |
+ |
+ //Period3 |
+ if(newDate.compareTo(period3Begin_date) >= 0 && newDate.compareTo(period3End_date) <= 0){ |
+ if(medianTF){ |
+ graphData[i][4] = String.valueOf(median_period3); |
+ }else{ |
+ graphData[i][4] = String.valueOf(mean_period3); |
+ } |
+ }else{ |
+ graphData[i][4] = "-1"; |
+ } |
+ } |
+ |
+ //Write output for JHighChart timeseries for use on eRAMS |
+ Arrays.sort(graphData, new cfa.DateComparator()); |
+ doubleArray.writeTimeSeries(mainFolder, graphData, timeStep, getTimeseriesOutput().getName(), false); |
|
//Create TimeSeries graph of merged data |
XYPlot plotTime = new XYPlot(); |
@@ -477,7 +540,7 @@ |
if(period1Data.length > 0){ |
len_period1 = String.valueOf(period1Data.length); |
double value = mean_period1; |
- String label = "Average"; |
+ String label = "Mean"; |
if(medianTF){ |
value = median_period1; |
label = "Median"; |
@@ -500,7 +563,7 @@ |
if(period2Data.length > 0){ |
len_period2 = String.valueOf(period2Data.length); |
double value = mean_period2; |
- String label = "Average"; |
+ String label = "Mean"; |
if(medianTF){ |
value = median_period2; |
label = "Median"; |
@@ -523,7 +586,7 @@ |
if(period3Data.length > 0){ |
len_period3 = String.valueOf(period3Data.length); |
double value = mean_period3; |
- String label = "Average"; |
+ String label = "Mean"; |
if(medianTF){ |
value = median_period3; |
label = "Median"; |
@@ -581,8 +644,27 @@ |
* Creates a boxplot of the timeseries data to be displayed next to a summary of the statistics of the timeseries data |
* @param yAxisTitle a String of the title for the Y axis of the boxplot |
*/ |
- private void createTimeseriesBoxplot(String[][] data, String yAxisTitle){ |
- Graphing graphing = new Graphing(); |
+ private void createTimeseriesBoxplot(String[][] data, String yAxisTitle) throws IOException{ |
+ DoubleArray doubleArray = new DoubleArray(); |
+ Graphing graphing = new Graphing(); |
+ |
+ //Prep. boxplot data for output function |
+ ArrayList<ArrayList<Double>> boxplotOutliers = new ArrayList<ArrayList<Double>>(); |
+ ArrayList<Double> outliers = new ArrayList<Double>();// Get daily outliers |
+ double IQR = upperQuartile - lowerQuartile;// Find IQR |
+ for (int i = 0; i < data.length; i++){ |
+ double value = Double.parseDouble(data[i][1]); |
+ if(value < (lowerQuartile - 1.5 * IQR) || value > (upperQuartile + 1.5 * IQR)){ |
+ outliers.add(value); |
+ } |
+ } |
+ boxplotOutliers.add(outliers); |
+ double[][] boxplotData = {{max},{upperQuartile},{median},{lowerQuartile},{min}}; |
+ |
+ //Write output for JHighChart boxplot for use on eRAMS |
+ doubleArray.writeBoxplot(mainFolder, boxplotOutliers, boxplotData, getBoxplotOutput().getName()); |
+ |
+ |
//Create boxplot of the timeseries data |
XYPlot plot = new XYPlot(); |
|
@@ -632,7 +714,6 @@ |
|
//Creates 1.5 * Interquartile Range (IQR) lines |
//Create XYSeries for the min-max lines |
- double IQR = upperQuartile - lowerQuartile; |
double lowerLimit = lowerQuartile - 1.5*IQR; |
double upperLimit = upperQuartile + 1.5*IQR; |
if(lowerLimit < min){ |
@@ -658,17 +739,17 @@ |
|
//Calculate and create Outliers (# < lowerQuartile - 1.5*IQR or # > upperQuartile + 1.5*IQR) |
//Calculate and create Extreme Outliers (# < lowerQuartile - 3*IQR or # > upperQuartile + 3*IQR) |
- XYSeries outliers = new XYSeries("Outliers"); |
+ XYSeries outliers_XY = new XYSeries("Outliers"); |
XYSeries extremeOutliers = new XYSeries("Extreme Outliers"); |
for(int i=0; i<data.length; i++){ |
double value = Double.parseDouble(data[i][1]); |
//Lower outliers |
if(value < (lowerQuartile - 1.5*IQR) && value > (lowerQuartile - 3*IQR)){ |
- outliers.add(5, value); |
+ outliers_XY.add(5, value); |
} |
//Upper outliers |
if(value > (upperQuartile + 1.5*IQR) && value < (lowerQuartile + 3*IQR)){ |
- outliers.add(5, value); |
+ outliers_XY.add(5, value); |
} |
|
//Extreme Lower outliers |
@@ -682,11 +763,11 @@ |
} |
|
//Create outlier scatter |
- XYDataset outlier_scatter = new XYSeriesCollection(outliers); |
+ XYDataset outlier_scatter = new XYSeriesCollection(outliers_XY); |
XYItemRenderer renderer_outlier = new XYLineAndShapeRenderer(false, true); |
renderer_outlier.setSeriesShape(0, new Ellipse2D.Double(-2.0, 2.0, 4.0, 4.0)); |
renderer_outlier.setSeriesPaint(0, Color.darkGray); |
- if(outliers.isEmpty()){ |
+ if(outliers_XY.isEmpty()){ |
renderer_outlier.setSeriesVisibleInLegend(0, false); |
} |
plot.setDataset(3, outlier_scatter); |
@@ -908,9 +989,18 @@ |
* and long term average/median and user data and save the resulting graph to the specified location. |
* @param sortedData the String[][] containing sorted data for the time series |
* (column 1 = dates (yyyy-mm-dd), column 2 = value |
+ * @param period1Data the String[][] containing sorted data for the time series |
+ * contained by period1 (column 1 = dates (yyyy-mm-dd), column 2 = value |
+ * @param period2Data the String[][] containing sorted data for the time series |
+ * contained by period1 (column 1 = dates (yyyy-mm-dd), column 2 = value |
+ * @param period3Data the String[][] containing sorted data for the time series |
+ * contained by period1 (column 1 = dates (yyyy-mm-dd), column 2 = value |
* @param yAxisTitle the String label for the y axis of the graph |
*/ |
private void createTimeseriesEnvelopeGraph(String[][] sortedData, |
+ String[][] period1Data, |
+ String[][] period2Data, |
+ String[][] period3Data, |
String yAxisTitle, |
boolean logYaxis_TF) throws IOException, ParseException { |
DoubleArray doubleArray = new DoubleArray(); |
@@ -919,19 +1009,26 @@ |
|
//Initialize variables |
DateFormat desiredDateFormat = doubleArray.getDateFormat("daily", false); |
- String[][] graphData = new String[366][2]; |
+ String[][] graphData = new String[366][6]; |
String[] dayList = new String[366]; |
int seriesIndex = 0; |
+ String periodTitle = "Mean"; |
+ if(medianTF){ periodTitle = "Median"; } |
|
//Plot each year and the long term average and the most recent year |
XYPlot plot = new XYPlot(); |
- String longTermSeriesName = "Average"; |
- if(medianTF) longTermSeriesName = "Median"; |
- TimeSeries average_TS = new TimeSeries(longTermSeriesName); |
+ TimeSeries median_TS = new TimeSeries("All Data: Median"); |
+ TimeSeries mean_TS = new TimeSeries("All Data: Mean"); |
+ TimeSeries period1_TS = new TimeSeries("Period 1: " + periodTitle); |
+ TimeSeries period2_TS = new TimeSeries("Period 2: " + periodTitle); |
+ TimeSeries period3_TS = new TimeSeries("Period 3: " + periodTitle); |
String currentDate_str = "2000-01-01"; |
if(waterYearTF) currentDate_str = "1999-10-01"; |
for(int j=1; j<=366; j++){ |
ArrayList<Double> dateData = new ArrayList<Double>(); |
+ ArrayList<Double> dateData_period1 = new ArrayList<Double>(); |
+ ArrayList<Double> dateData_period2 = new ArrayList<Double>(); |
+ ArrayList<Double> dateData_period3 = new ArrayList<Double>(); |
dayList[j-1] = String.valueOf(j); |
|
for(int i=0; i<sortedData.length; i++){ |
@@ -940,21 +1037,93 @@ |
dateData.add(Double.parseDouble(sortedData[i][1])); |
} |
} |
+ for(int i=0; i<period1Data.length; i++){ |
+ String month_day = period1Data[i][0].substring(5); |
+ if(month_day.equalsIgnoreCase(currentDate_str.substring(5))){ |
+ dateData_period1.add(Double.parseDouble(period1Data[i][1])); |
+ } |
+ } |
+ for(int i=0; i<period2Data.length; i++){ |
+ String month_day = period2Data[i][0].substring(5); |
+ if(month_day.equalsIgnoreCase(currentDate_str.substring(5))){ |
+ dateData_period2.add(Double.parseDouble(period2Data[i][1])); |
+ } |
+ } |
+ for(int i=0; i<period3Data.length; i++){ |
+ String month_day = period3Data[i][0].substring(5); |
+ if(month_day.equalsIgnoreCase(currentDate_str.substring(5))){ |
+ dateData_period3.add(Double.parseDouble(period3Data[i][1])); |
+ } |
+ } |
+ |
//Calculate average/median |
- double dayValue = doubleMath.meanArithmetic(dateData); |
- if(medianTF){ |
- dayValue = doubleMath.median(dateData); |
+ double dayValue_median = doubleMath.median(dateData); |
+ double dayValue_mean = doubleMath.meanArithmetic(dateData); |
+ Day currentDay = new Day(desiredDateFormat.parse(currentDate_str)); |
+ median_TS.add(currentDay, dayValue_median); |
+ mean_TS.add(currentDay, dayValue_mean); |
+ graphData[j-1][0] = currentDate_str; |
+ graphData[j-1][1] = String.valueOf(dayValue_median); |
+ graphData[j-1][2] = String.valueOf(dayValue_mean); |
+ |
+ //Check for period 1 data |
+ double dayValue_period1 = -1; |
+ if(!dateData_period1.isEmpty()){ |
+ if(medianTF){ |
+ dayValue_period1 = doubleMath.median(dateData_period1); |
+ }else{ |
+ dayValue_period1 = doubleMath.meanArithmetic(dateData_period1); |
+ } |
+ period1_TS.add(currentDay, dayValue_period1); |
} |
- Date currentDate = desiredDateFormat.parse(currentDate_str); |
- average_TS.add(new Day(currentDate), dayValue); |
- graphData[j-1][0] = String.valueOf(j); |
- graphData[j-1][1] = String.valueOf(dayValue); |
+ graphData[j-1][3] = String.valueOf(dayValue_period1); |
+ |
+ //Check for period 2 data |
+ double dayValue_period2 = -1; |
+ if(!dateData_period2.isEmpty()){ |
+ if(medianTF){ |
+ dayValue_period2 = doubleMath.median(dateData_period2); |
+ }else{ |
+ dayValue_period2 = doubleMath.meanArithmetic(dateData_period2); |
+ } |
+ period2_TS.add(currentDay, dayValue_period2); |
+ } |
+ graphData[j-1][4] = String.valueOf(dayValue_period2); |
+ |
+ //Check for period 3 data |
+ double dayValue_period3 = -1; |
+ if(!dateData_period3.isEmpty()){ |
+ if(medianTF){ |
+ dayValue_period3 = doubleMath.median(dateData_period3); |
+ }else{ |
+ dayValue_period3 = doubleMath.meanArithmetic(dateData_period3); |
+ } |
+ period3_TS.add(currentDay, dayValue_period3); |
+ } |
+ graphData[j-1][5] = String.valueOf(dayValue_period3); |
+ |
+ //Move to the next day |
currentDate_str = doubleArray.getDay(currentDate_str, 1); |
} |
|
//Create renderer, and axis for timeseries graph |
- graphing.addTimeseriesData(plot, average_TS, true, Color.gray, false, false, true, true, seriesIndex); |
+ plot = graphing.addTimeseriesData(plot, median_TS, true, Color.gray, false, false, true, true, seriesIndex); |
seriesIndex++; |
+ plot = graphing.addTimeseriesData(plot, mean_TS, true, Color.black, false, false, true, true, seriesIndex); |
+ seriesIndex++; |
+ if(!period1_TS.isEmpty()){ |
+ plot = graphing.addTimeseriesData(plot, period1_TS, true, Color.red, false, false, true, true, seriesIndex); |
+ seriesIndex++; |
+ } |
+ if(!period2_TS.isEmpty()){ |
+ plot = graphing.addTimeseriesData(plot, period2_TS, true, new Color(255, 135, 0), false, false, true, true, seriesIndex); |
+ seriesIndex++; |
+ } |
+ if(!period3_TS.isEmpty()){ |
+ plot = graphing.addTimeseriesData(plot, period3_TS, true, Color.green, false, false, true, true, seriesIndex); |
+ seriesIndex++; |
+ } |
+ int recentYear = seriesIndex; |
seriesIndex++;//Increase series so the most recent month can be plotted second |
|
//Calculate Flow statistics for each year in time period |
@@ -1037,7 +1206,6 @@ |
} |
currentDate_str = doubleArray.getDay(currentDate_str, 1); |
} |
- graphData = doubleArray.appendcolumn_Matrix(graphData, dayList);//Add list of days (aka x points) |
graphData = doubleArray.appendcolumn_Matrix(graphData, partialDayData);//Add day values (aka y points) |
|
//Check to stop looping |
@@ -1064,11 +1232,11 @@ |
|
//Re-add the most recent year to the graph so it renders on top |
TimeSeries finalYear_TS = graphing.createTimeSeriesFromData(mostRecentYearData, String.valueOf(finalYear), "daily"); |
- plot = graphing.addTimeseriesData(plot, finalYear_TS, true, Color.red, false, false, true, true, 1); |
+ plot = graphing.addTimeseriesData(plot, finalYear_TS, true, Color.cyan, false, false, true, true, recentYear); |
|
//Output monthly boxplot and timeseries data for use with JHighCharts |
if(rasterTF || envelopeTF){ |
- doubleArray.writeXYseries(mainFolder, graphData, getTimeseriesEnvelopeOutput().getName()); |
+ doubleArray.writeTimeSeries(mainFolder, graphData, "daily", getTimeseriesEnvelopeOutput().getName(), false); |
} |
|
//Check if the user desires a raster graph |
@@ -1484,7 +1652,7 @@ |
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); |
|
//Set extra plot preferences |
- graphing.setCategoryAxisPreferences(plot); |
+ plot = graphing.setCategoryAxisPreferences(plot); |
|
//Create the chart with the plot |
String graphTitle = "Histogram for " + database + " Station: " + stationID + "; " + stationName; |
@@ -1898,7 +2066,7 @@ |
if(wqTest.equalsIgnoreCase("flow")){ |
//Create Envelope Graph |
if(envelopeTF || rasterTF){ |
- createTimeseriesEnvelopeGraph(sortedData_combined, yAxisTitle, true); |
+ createTimeseriesEnvelopeGraph(sortedData_combined, period1Data, period2Data, period3Data, yAxisTitle, true); |
} |
|
//Calculate Hydrologic Indicators of Alteration |
@@ -1982,92 +2150,11 @@ |
CalculateStatistics(seasonalData, "seasonal"); |
|
//Graph the timeseries data |
- createTimeseriesGraph(sortedData_combined, sortedData_user, period1Data, period2Data, period3Data, color, color2, showLine, yAxisTitle, graphUnits, medianTF); |
+ createTimeseriesGraph(sortedData_combined, sortedData_user, period1Data, period2Data, period3Data, color, color2, showLine, yAxisTitle, graphUnits); |
createTimeseriesBoxplot(sortedData_combined, yAxisTitle); |
createTimeseriesHistogram(sortedData_combined, sortedData_user, period1Data, period2Data, period3Data, color, yAxisTitle); |
createTimeseriesCDF(sortedData_combined, sortedData_user, period1Data, period2Data, period3Data, color, color2, yAxisTitle); |
|
- //Re-Format graphing data for output for use with JHighChart |
- DateFormat periodDateFormat = doubleArray.getDateFormat("daily", false); |
- Date period1Begin_date = new Date(); |
- Date period1End_date = new Date(); |
- Date period2Begin_date = new Date(); |
- Date period2End_date = new Date(); |
- Date period3Begin_date = new Date(); |
- Date period3End_date = new Date(); |
- if(!period1Begin.isEmpty() && !period1End.isEmpty()){ |
- period1Begin_date = periodDateFormat.parse(period1Begin); |
- period1End_date = periodDateFormat.parse(period1End); |
- } |
- if(!period2Begin.isEmpty() && !period2End.isEmpty()){ |
- period2Begin_date = periodDateFormat.parse(period2Begin); |
- period2End_date = periodDateFormat.parse(period2End); |
- } |
- if(!period3Begin.isEmpty() && !period3End.isEmpty()){ |
- period3Begin_date = periodDateFormat.parse(period3Begin); |
- period3End_date = periodDateFormat.parse(period3End); |
- } |
- |
- String[][] graphData = new String[sortedData_combined.length][5]; |
- DateFormat desiredDateFormat = doubleArray.getDateFormat(timeStep, false); |
- for(int i=0; i<sortedData_combined.length; i++){ |
- Date newDate = desiredDateFormat.parse(sortedData_combined[i][0]); |
- graphData[i][0] = sortedData_combined[i][0]; |
- graphData[i][1] = sortedData_combined[i][1]; |
- |
- //Period1 |
- if(newDate.compareTo(period1Begin_date) >= 0 && newDate.compareTo(period1End_date) <= 0){ |
- if(medianTF){ |
- graphData[i][2] = String.valueOf(median_period1); |
- }else{ |
- graphData[i][2] = String.valueOf(mean_period1); |
- } |
- }else{ |
- graphData[i][2] = "-1"; |
- } |
- |
- //Period2 |
- if(newDate.compareTo(period2Begin_date) >= 0 && newDate.compareTo(period2End_date) <= 0){ |
- if(medianTF){ |
- graphData[i][3] = String.valueOf(median_period2); |
- }else{ |
- graphData[i][3] = String.valueOf(mean_period2); |
- } |
- }else{ |
- graphData[i][3] = "-1"; |
- } |
- |
- //Period3 |
- if(newDate.compareTo(period3Begin_date) >= 0 && newDate.compareTo(period3End_date) <= 0){ |
- if(medianTF){ |
- graphData[i][4] = String.valueOf(median_period3); |
- }else{ |
- graphData[i][4] = String.valueOf(mean_period3); |
- } |
- }else{ |
- graphData[i][4] = "-1"; |
- } |
- } |
- |
- //Prep. boxplot data for output function |
- ArrayList<ArrayList<Double>> boxplotOutliers = new ArrayList<ArrayList<Double>>(); |
- ArrayList<Double> outliers = new ArrayList<Double>();// Get daily outliers |
- double IQR = upperQuartile - lowerQuartile;// Find IQR |
- for (int i = 0; i < sortedData_combined.length; i++){ |
- double value = Double.parseDouble(sortedData_combined[i][1]); |
- if(value < (lowerQuartile - 1.5 * IQR) || value > (upperQuartile + 1.5 * IQR)){ |
- outliers.add(value); |
- } |
- } |
- boxplotOutliers.add(outliers); |
- double[][] boxplotData = {{max},{upperQuartile},{median},{lowerQuartile},{min}}; |
- |
- //Write output for JHighChart boxplot and timeseries for use on eRAMS |
- //output for JHighChart's monthly boxplot is performed during the JFreeChart graphing of monthly boxplot |
- Arrays.sort(graphData, new cfa.DateComparator()); |
- doubleArray.writeTimeSeries(mainFolder, graphData, timeStep, getTimeseriesOutput().getName(), false); |
- doubleArray.writeBoxplot(mainFolder, boxplotOutliers, boxplotData, getBoxplotOutput().getName()); |
- |
//Get today's date for the source reference |
DateFormat sourceDateFormat = doubleArray.getDateFormat("15-min", false); |
String today = sourceDateFormat.format(new Date()); |