@@ -7,14 +7,14 @@ |
import org.codehaus.jettison.json.JSONException; |
|
/** |
-* Last Updated: 13-September-2016 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible |
* @since 25-January-2014 |
*/ |
public class Data { |
/** |
* Main Data extraction for daily flow data from the various databases that this tool can access |
- * @param mainFolder the output file location (used by STORET Data extraction) |
+ * @param directory the output file location (used by STORET Data extraction) |
* @param resourceFile the csip resource file for the python driver for the storet rest call |
* @param database the database from which to extract daily flow data (USGS, UserData, STORET, or CDWR) |
* @param organizationID the organization which provided the data to the database (used by STORET Data extraction) |
@@ -27,7 +27,7 @@ |
* @throws InterruptedException |
* @throws Exception |
*/ |
- public static String[][] extractFlowData(String mainFolder, |
+ public static String[][] extractFlowData(String directory, |
File resourceFile, |
String database, |
String organizationID, |
@@ -64,7 +64,7 @@ |
|
}else if(database.equalsIgnoreCase("STORET")){ |
//Search STORET database using new rest service (fast) |
- flowData = STORET_Data.getSTORETdata(mainFolder, resourceFile, true, organizationID, stationID, "flow", beginDate, endDate); |
+ flowData = STORET_Data.getSTORETdata(directory, resourceFile, true, organizationID, stationID, "flow", beginDate, endDate); |
|
}else if(database.equalsIgnoreCase("CDWR")){ |
//Search for CDWR flow data |
@@ -86,7 +86,7 @@ |
} |
/** |
* Main Data extraction for water quality data from the various databases that this tool can access |
- * @param mainFolder the output file location (used by STORET Data extraction) |
+ * @param directory the output file location (used by STORET Data extraction) |
* @param resourceFile the csip resource file for the python driver for the storet rest call |
* @param database the database from which to extract water quality data (USGS, UserData, STORET, or CDWR) |
* @param organizationID the organization which provided the data to the database (used by STORET Data extraction) |
@@ -101,7 +101,7 @@ |
* @throws java.text.ParseException |
* @throws org.codehaus.jettison.json.JSONException |
*/ |
- public static Object[] extractWQdata(String mainFolder, |
+ public static Object[] extractWQdata(String directory, |
File resourceFile, |
String database, |
String organizationID, |
@@ -150,7 +150,7 @@ |
//String endLoadUnits = resultArray[4]; |
|
//Search STORET database using new rest service (fast) |
- wqData = STORET_Data.getSTORETdata(mainFolder, resourceFile, true, organizationID, stationID, wqTest, beginDate, endDate); |
+ wqData = STORET_Data.getSTORETdata(directory, resourceFile, true, organizationID, stationID, wqTest, beginDate, endDate); |
|
}else if(database.equalsIgnoreCase("CDWR")){ |
ArrayList<String> errorMessage = new ArrayList<>(); |
@@ -177,7 +177,7 @@ |
} |
/** |
* Main Data extraction for daily flow and water quality data from the various databases that this tool can access (used for LDC and LOADEST) |
- * @param mainFolder the output file location (used by STORET Data extraction) |
+ * @param directory the output file location (used by STORET Data extraction) |
* @param resourceFile the csip resource file for the python driver for the storet rest call |
* @param database the database from which to extract water quality data (USGS, UserData, STORET, or CDWR) |
* @param organizationID the organization which provided the data to the database (used by STORET Data extraction) |
@@ -193,7 +193,7 @@ |
* @throws java.text.ParseException |
* @throws org.codehaus.jettison.json.JSONException |
*/ |
- public static Object[] extractFlow_and_WQdata(String mainFolder, |
+ public static Object[] extractFlow_and_WQdata(String directory, |
File resourceFile, |
String database, |
String organizationID, |
@@ -240,8 +240,8 @@ |
|
}else if(database.equalsIgnoreCase("STORET")){ |
//Search STORET database using new rest service (fast) |
- flowData = STORET_Data.getSTORETdata(mainFolder, resourceFile, true, organizationID, stationID, "flow", beginDate, endDate); |
- wqData = STORET_Data.getSTORETdata(mainFolder, resourceFile, true, organizationID, stationID, wqTest, beginDate, endDate); |
+ flowData = STORET_Data.getSTORETdata(directory, resourceFile, true, organizationID, stationID, "flow", beginDate, endDate); |
+ wqData = STORET_Data.getSTORETdata(directory, resourceFile, true, organizationID, stationID, wqTest, beginDate, endDate); |
|
}else if(database.equalsIgnoreCase("UserData")){ |
ArrayList<String> errorMessage = new ArrayList<>(); |
@@ -267,7 +267,7 @@ |
} |
/** |
* Main Data extraction for flood flow data from the various databases that this tool can access |
- * @param mainFolder the output file location (used by STORET Data extraction) |
+ * @param directory the output file location (used by STORET Data extraction) |
* @param resourceFile the csip resource file for the python driver for the storet rest call |
* @param database the database from which to extract daily flow data (USGS, UserData, STORET, or CDWR) |
* @param organizationID the organization which provided the data to the database (used by STORET Data extraction) |
@@ -279,7 +279,7 @@ |
* @throws IOException |
* @throws Exception |
*/ |
- public static double[][] extractFloodData(String mainFolder, |
+ public static double[][] extractFloodData(String directory, |
File resourceFile, |
String database, |
String organizationID, |
@@ -308,7 +308,7 @@ |
|
}else if(database.equalsIgnoreCase("STORET")){ |
//Search STORET database using new rest service (fast) |
- String[][] flowData = STORET_Data.getSTORETdata(mainFolder, resourceFile, true, organizationID, stationID, "flow", beginDate, endDate); |
+ String[][] flowData = STORET_Data.getSTORETdata(directory, resourceFile, true, organizationID, stationID, "flow", beginDate, endDate); |
|
//Removed duplicate dates |
flowData = DoubleArray.removeDuplicateDates(flowData); |
@@ -348,7 +348,7 @@ |
} |
/** |
* Extracts 15 minute data from USGS and/or User data or hourly data from CDWR (as long as the date is formatted properly) returns an error otherwise |
- * @param mainFolder the output file location (used by STORET Data extraction) |
+ * @param directory the output file location (used by STORET Data extraction) |
* @param database the database from which to extract water quality data (USGS, UserData, STORET, or CDWR) |
* @param stationID the station ID for which flow and water quality data is desired |
* @param beginDate the begin date of desired flow and water quality data (yyyy-MM-dd) |
@@ -358,7 +358,7 @@ |
* @throws IOException |
* @throws Exception |
*/ |
- public static String[][] extractInstantaneousFlowData(String mainFolder, |
+ public static String[][] extractInstantaneousFlowData(String directory, |
String database, |
String stationID, |
String beginDate, |
@@ -33,13 +33,13 @@ |
import org.jfree.data.time.TimeSeries; |
|
/** |
- * Last Updated: 13-September-2016 |
+ * Last Updated: 31-May-2017 |
* @author Tyler Wible |
* @since 15-June-2012 |
*/ |
public class guiBaseflow_Model { |
//Inputs |
- String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/Baseflow";//"/od/projects/cfa/GUI_FlowAnalysis"; |
+ String directory = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/Baseflow";//"/od/projects/cfa/GUI_FlowAnalysis"; |
String database = "USGS";//"CDWR";//"STORET";//"CDSN";//"UserData";// |
String organizationID = "n/a";//"n/a";//"21COL001";//"CITYFTCO_WQX";//"n/a";// |
String stationID = "06741510";//"CLAGRECO";//"000028";//"1EFF";//"n/a";// |
@@ -80,10 +80,10 @@ |
double bflow3_mean = -1; |
|
//Gets |
- public File getBaseflow_out(){ return new File(mainFolder, "baseflow.out"); } |
- public File getBaseflow_dat(){ return new File(mainFolder, "baseflow.dat"); } |
+ public File getBaseflow_out(){ return new File(directory, "baseflow.out"); } |
+ public File getBaseflow_dat(){ return new File(directory, "baseflow.dat"); } |
public String getGraph() { return "baseflow_graph.jpg"; } |
- public File getTimeseriesOutput(){ return new File(mainFolder, "baseflow_timeseries.out"); }//for use with JSHighCharts |
+ public File getTimeseriesOutput(){ return new File(directory, "baseflow_timeseries.out"); }//for use with JSHighCharts |
public String getLen(){ return len; } |
public String getStart(){ return start; } |
public String getEnd(){ return end; } |
@@ -106,7 +106,7 @@ |
public String getBFLOWpass3_Mean(){ return String.valueOf(bflow3_mean); } |
|
//Sets |
- public void setMainFolder(String mainFolder_str){ mainFolder = mainFolder_str; } |
+ public void setDirectory(String directory_str){ directory = directory_str; } |
public void setDatabase(String database_str){ database = database_str; } |
public void setOrganizationID(String organizationID_str){ organizationID = organizationID_str; } |
public void setStationID(String stationID_str){ stationID = stationID_str; } |
@@ -174,7 +174,7 @@ |
*/ |
private void writeBFLOWinputFiles(String[][] dynamicSummary, int ndmin, int ndmax) throws IOException { |
//Write input data file for BFLOW |
- String path = mainFolder + File.separator + "baseflow.txt"; |
+ String path = directory + File.separator + "baseflow.txt"; |
FileWriter writer = new FileWriter(path, false); |
PrintWriter print_line = new PrintWriter(writer); |
print_line.printf("%s" + "\r\n", "Date Flow"); |
@@ -187,7 +187,7 @@ |
|
//Additionally write out the file "baseflow.lst" required for BFLOW to |
//know what files to run on |
- String path2 = mainFolder + File.separator + "file.lst"; |
+ String path2 = directory + File.separator + "file.lst"; |
FileWriter writer2 = new FileWriter(path2, false); |
PrintWriter print_line2 = new PrintWriter(writer2); |
print_line2.printf("%s" + "\r\n", "!!Input for baseflow program:"); |
@@ -207,7 +207,7 @@ |
*/ |
private void graphBFLOWresults(String[][] sortedData_user) throws IOException, ParseException{ |
//Pull out results to be graphed |
- String[][] baseFlowResults = readBFLOWresults(mainFolder); |
+ String[][] baseFlowResults = readBFLOWresults(directory); |
|
//Create TimeSeries to graph of the stream flow, baseflow1, baseflow2, and baseflow3 |
TimeSeries streamflow_series = new TimeSeries("Streamflow"); |
@@ -278,7 +278,7 @@ |
calculateBFLOWstats(graphData); |
|
//Save results for graphing with JSHighcharts |
- DoubleArray.writeTimeSeries(mainFolder, graphData, "Daily", getTimeseriesOutput().getName(), false); |
+ DoubleArray.writeTimeSeries(directory, graphData, "Daily", getTimeseriesOutput().getName(), false); |
|
//Graph the baseflow on a timeseries axis |
XYPlot plotTime = new XYPlot(); |
@@ -327,7 +327,7 @@ |
//Save resulting graph |
try { |
guiBaseflow_Model model = new guiBaseflow_Model(); |
- String path = mainFolder + File.separator + model.getGraph(); |
+ String path = directory + File.separator + model.getGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), parentChart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
|
@@ -338,7 +338,7 @@ |
} |
/** |
* Reads the output file of BFLOW and reformats it to be used in later functions |
- * @param path the file location of the output file |
+ * @param directory the file location of the output file |
* @param fileName the name of the output file |
* @return a String[][] of the results of the BFLOW analysis where: |
* the first column contains the year of the date, the second column the month, third column the day, |
@@ -346,9 +346,9 @@ |
* sixth column the 2nd baseflow analysis pass, and the seventh column the 3rd baseflow analysis pass |
* @throws IOException |
*/ |
- private String[][] readBFLOWresults(String path) throws IOException{ |
+ private String[][] readBFLOWresults(String directory) throws IOException{ |
//Open a reader for the results file |
- FileReader file_to_read = new FileReader(path + File.separator + "baseflow.out"); |
+ FileReader file_to_read = new FileReader(directory + File.separator + "baseflow.out"); |
BufferedReader reader = new BufferedReader(file_to_read); |
|
String currentLine; |
@@ -664,7 +664,7 @@ |
* @throws IOException |
*/ |
private void writeHYSEPinputFile(ArrayList<String> fileContents) throws IOException { |
- String path = mainFolder + File.separator + "hysep.gsd"; |
+ String path = directory + File.separator + "hysep.gsd"; |
FileWriter write = new FileWriter(path, false); |
PrintWriter print_line = new PrintWriter(write); |
|
@@ -680,8 +680,8 @@ |
*/ |
private void graphHYSEPresults() throws IOException, ParseException{ |
//Pull out results to be graphed |
- String[][] baseFlowResults = readHYSEPresults(mainFolder, ".bsf");//hysep.bsf |
- String[][] streamFlowResults = readHYSEPresults(mainFolder, ".sro");//hysep.sro |
+ String[][] baseFlowResults = readHYSEPresults(directory, ".bsf");//hysep.bsf |
+ String[][] streamFlowResults = readHYSEPresults(directory, ".sro");//hysep.sro |
|
|
//Create TimeSeries to graph of the stream flow, baseflow and total flow to be graphed |
@@ -728,7 +728,7 @@ |
} |
|
//Save results for graphing with JSHighcharts |
- DoubleArray.writeTimeSeries(mainFolder, graphData, "Daily", getTimeseriesOutput().getName(), false); |
+ DoubleArray.writeTimeSeries(directory, graphData, "Daily", getTimeseriesOutput().getName(), false); |
|
//Graph the baseflow on a timeseries axis |
XYPlot plotTime = new XYPlot(); |
@@ -760,7 +760,7 @@ |
|
//Save resulting graph |
try { |
- String path = mainFolder + "/baseflow_graph.jpg"; |
+ String path = directory + "/baseflow_graph.jpg"; |
ChartUtilities.saveChartAsJPEG(new File(path), parentChart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
|
@@ -771,16 +771,16 @@ |
} |
/** |
* Reads one of the WATSTORE formated output files of HYSEP and reformats it into a daily timeseries to be used in later functions |
- * @param mainFolder the file location of the output file |
+ * @param directory the file location of the output file |
* @param fileType the type of HYSEP output file being read (".bsf" for baseflow or ".sro" for stream flow) |
* @return a String[][] of the results of the HYSEOP analysis where: |
* the first column contains the year of the date, the second column the month, third column the day, |
* fourth column the values of the file (if the file is .bsf then baseflow values, if the file is .sro then streamflow values) |
* @throws IOException |
*/ |
- private String[][] readHYSEPresults(String mainFolder, String fileType) throws IOException{ |
+ private String[][] readHYSEPresults(String directory, String fileType) throws IOException{ |
//Open a reader for the results file |
- FileReader file_to_read = new FileReader(mainFolder + File.separator + "baseflow" + fileType); |
+ FileReader file_to_read = new FileReader(directory + File.separator + "baseflow" + fileType); |
BufferedReader reader = new BufferedReader(file_to_read); |
|
String currentLine; |
@@ -911,7 +911,7 @@ |
} |
|
//Check if any flow data exists |
- String[][] sortableData = Data.extractFlowData(mainFolder, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
+ String[][] sortableData = Data.extractFlowData(directory, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
|
//If the user wants the datasets (public and user) merged then retrieve the second dataset (user) |
String[][] sortableData_user = new String[0][0]; |
@@ -954,10 +954,10 @@ |
e.exec(); |
|
//Expected Output: "baseflow.dat" and "baseflow.out" |
- if (!new File(mainFolder, "baseflow.dat").exists()) { |
+ if (!new File(directory, "baseflow.dat").exists()) { |
throw new FileNotFoundException("baseflow.dat"); |
} |
- if (!new File(mainFolder, "baseflow.out").exists()) { |
+ if (!new File(directory, "baseflow.out").exists()) { |
throw new FileNotFoundException("baseflow.out"); |
} |
|
@@ -30,7 +30,7 @@ |
} |
} |
/** |
-* Last Updated: 13-September-2016 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible |
* @since 23-July-2012 |
*/ |
@@ -190,7 +190,7 @@ |
* is performed. If thetaString is not blank then an ARMA(p,q) model is performed where the |
* order q is determined by the number of theta values in thetaString. |
* <code>q = thetaString.split("\t").length</code>. |
- * @param mainFolder the file location to write out the error file if necessary |
+ * @param directory the file location to write out the error file if necessary |
* @param action if "optimize", this only optimizes the lambda and phi values for the model and |
* then reports these back to the user, if "all" then it generates data based on the calculated |
* phi values and finishes performing the drought analysis, if "useParameters" then it takes the |
@@ -209,7 +209,7 @@ |
* future predicted data (<code>double[][] predictedData = (double[][]) returnArray[3]</code>) |
* @throws IOException |
*/ |
- public Object[] AutoregressiveModel(String mainFolder, String action, String phiValues, String thetaValues, double[][] transformedData) throws IOException{ |
+ public Object[] AutoregressiveModel(String directory, String action, String phiValues, String thetaValues, double[][] transformedData) throws IOException{ |
Object[] returnArray = null; |
|
if(action.equalsIgnoreCase("optimizeModel")){ |
@@ -226,10 +226,10 @@ |
int ctr = 1; |
while(!increasing){ |
//Find the phi parameters of the AR(p) regression |
- String[] phiString = AR(mainFolder, ctr, transformedData); |
+ String[] phiString = AR(directory, ctr, transformedData); |
|
//Perform the AR(p) regression and calculated the AIC and BIC |
- double[] aicBIC = ARoptimize(mainFolder, phiString[0], transformedData); |
+ double[] aicBIC = ARoptimize(directory, phiString[0], transformedData); |
aic.add(aicBIC[0]);//the AIC value of the fitted AR(ctr) model |
bic.add(aicBIC[1]);//the BIC value of the fitted AR(ctr) model |
phi.add(phiString[0]);//The tab-delimited string of phi values for the fitted AR(ctr) model |
@@ -268,10 +268,10 @@ |
for(int pCtr=1; pCtr<=p; pCtr++){//Loop from 1 to 5 of ARMA p values |
for(int qCtr=1; qCtr<=q; qCtr++){//Loop from 1 to 3 of ARMA q values |
//Find the phi and theta parameters of the ARMA(p, q) regression |
- String[] coefficients = ARMA(mainFolder, pCtr, qCtr, transformedData); |
+ String[] coefficients = ARMA(directory, pCtr, qCtr, transformedData); |
|
//Perform the ARMA(p, q) regression and calculated the AIC and BIC |
- double[] aicBIC = ARMAoptimize(mainFolder, coefficients[0], coefficients[1], transformedData); |
+ double[] aicBIC = ARMAoptimize(directory, coefficients[0], coefficients[1], transformedData); |
results[ctr][0] = pCtr; |
results[ctr][1] = qCtr; |
results[ctr][2] = aicBIC[0];//the AIC value of the fitted ARMA(pCtr, qCtr) model |
@@ -305,24 +305,24 @@ |
if(thetaValues.equalsIgnoreCase("")){ |
//Perform AR(p) regression |
int p = Integer.parseInt(phiValues); |
- returnArray = AR(mainFolder, p, transformedData); |
+ returnArray = AR(directory, p, transformedData); |
}else{ |
//If there are provided theta values then it is an ARMA model |
//Perform ARMA(p, q) regression |
int p = Integer.parseInt(phiValues); |
int q = Integer.parseInt(thetaValues); |
- returnArray = ARMA(mainFolder, p, q, transformedData); |
+ returnArray = ARMA(directory, p, q, transformedData); |
} |
|
}else if(action.equalsIgnoreCase("useParameters") || action.equalsIgnoreCase("updateParameters")){ |
//If the parameters are provided, use them and finish the drought analysis |
if(thetaValues.equalsIgnoreCase("")){ |
//Perform the AR(p) regression and generate a new dataset |
- returnArray = AR(mainFolder, phiValues, transformedData); |
+ returnArray = AR(directory, phiValues, transformedData); |
}else{ |
//If there are provided theta values then it is an ARMA model |
//Perform the ARMA(p,q) regression and generate a new dataset |
- returnArray = ARMA(mainFolder, phiValues, thetaValues, transformedData); |
+ returnArray = ARMA(directory, phiValues, thetaValues, transformedData); |
} |
|
}else{ |
@@ -330,22 +330,22 @@ |
if(thetaValues.equalsIgnoreCase("")){ |
//Find the phi parameters of the AR(p) regression |
int p = Integer.parseInt(phiValues); |
- String[] phiString = AR(mainFolder, p, transformedData); |
+ String[] phiString = AR(directory, p, transformedData); |
|
//Perform the AR(p) regression and generate a new dataset |
- returnArray = AR(mainFolder, phiString[0], transformedData); |
+ returnArray = AR(directory, phiString[0], transformedData); |
}else{ |
//If there are provided theta values then it is an ARMA model |
//Find the phi and theta parameters of the ARMA(p, q) regression |
int p = Integer.parseInt(phiValues); |
int q = Integer.parseInt(thetaValues); |
- String[] parameterArray = ARMA(mainFolder, p, q, transformedData); |
+ String[] parameterArray = ARMA(directory, p, q, transformedData); |
String phiString = parameterArray[0]; |
String thetaString = parameterArray[1]; |
phiString = phiString.substring(0, phiString.length() - 3);//Remove the $$ at the end of this string |
|
//Perform the ARMA(p,q) regression and generate a new dataset |
- returnArray = ARMA(mainFolder, phiString, thetaString, transformedData); |
+ returnArray = ARMA(directory, phiString, thetaString, transformedData); |
} |
} |
|
@@ -353,13 +353,13 @@ |
} |
/** |
* Performs an Auto-Regressive, AR(p), model on the provided data. Returns a string containing tab-delimited phi values of the AR(p) model. |
- * @param mainFolder the file location to write out the error file if necessary |
+ * @param directory the file location to write out the error file if necessary |
* @param transformedData double array of data. Column1 = years, column2 = annual flow values |
* @param p the order of the AR model (if p = 1 an AR(1) model is performed, if p=2 AR(2), etc.) |
* @return a tab-delimited string containing p number of phi values for the AR(p) model |
* @throws IOException |
*/ |
- public String[] AR(String mainFolder, int p, double[][] transformedData) throws IOException{ |
+ public String[] AR(String directory, int p, double[][] transformedData) throws IOException{ |
//Error catch for available data vs. "p" order AR model |
int N = transformedData.length; |
if(N < (2*p + 1)){ |
@@ -424,14 +424,14 @@ |
/** |
* Performs an Auto-Regressive (AR(p)) model on the provided data. The order p is determined by the number of phi |
* values in phiString. p = phiString.split("\t").length; |
- * @param mainFolder the file location to write out the error file if necessary |
+ * @param directory the file location to write out the error file if necessary |
* @param phiString a string of the phi values for the AR(p) model separated by "\t" (ex. for AR(3) phiString = phi_1 \t phi_2 \tphi_3) |
* @param transformedData double array of data. Column1 = years, column2 = annual flow values |
* @return an Object[] with the first element being the partial dataset of provided transformedData (double[][]) |
* and the second element being the AR(p) generated data (double[][]) based on the provided phi values |
* @throws IOException |
*/ |
- public Object[] AR(String mainFolder, String phiString, double[][] transformedData) throws IOException{ |
+ public Object[] AR(String directory, String phiString, double[][] transformedData) throws IOException{ |
//Error catch for available data vs. "p" order AR model |
int N = transformedData.length; |
String[] phiValues = phiString.split("\t"); |
@@ -532,14 +532,14 @@ |
/** |
* Performs an Auto-Regressive (AR(p)) model on the provided data. The order p is determined by the number of phi |
* values in phiString. p = phiString.split("\t").length; |
- * @param mainFolder the file location to write out the error file if necessary |
+ * @param directory the file location to write out the error file if necessary |
* @param phiString a string of the phi values for the AR(p) model separated by "\t" (ex. for AR(3) phiString = phi_1 \t phi_2 \tphi_3) |
* @param transformedData double array of data. Column1 = years, column2 = annual flow values |
* @return an Object[] with the first element being the partial dataset of provided transformedData (double[][]) |
* and the second element being the AR(p) generated data (double[][]) based on the provided phi values |
* @throws IOException |
*/ |
- public double[] ARoptimize(String mainFolder, String phiString, double[][] transformedData) throws IOException{ |
+ public double[] ARoptimize(String directory, String phiString, double[][] transformedData) throws IOException{ |
//Error catch for available data vs. "p" order AR model |
int N = transformedData.length; |
String[] phiValues = phiString.split("\t"); |
@@ -614,7 +614,7 @@ |
* Perform an Auto-Regressive Moving Average ARMA(p,q) model on the provided annual timeseries data |
* by generating 500*(p + q + 2) sets of possible values for p and q. Then evaluates the best fit of |
* the generated models (mimimum SSE) and returns the phi and theta values of the best fit model. |
- * @param mainFolder the file location to write out the error file if necessary |
+ * @param directory the file location to write out the error file if necessary |
* @param p the number of lagged data sets used to develop the ARMA(p,q) model |
* @param q the number of error data sets used to develop the ARMA(p,q) model |
* @param transformedData double array of data. Column1 = years, column2 = flow values |
@@ -622,9 +622,9 @@ |
* and returnArray[1]= a tab-delimited string containing q number of theta values for the ARMA(p,q) model |
* @throws IOException |
*/ |
- public String[] ARMA(String mainFolder, Integer p, Integer q, double[][] transformedData) throws IOException{ |
+ public String[] ARMA(String directory, Integer p, Integer q, double[][] transformedData) throws IOException{ |
if((p.compareTo(1) == 0) && (q.compareTo(1) == 0)){ |
- String[] returnArray = ARMA11(mainFolder, transformedData); |
+ String[] returnArray = ARMA11(directory, transformedData); |
return returnArray; |
}else{ |
//Generate 500*(p+q+2) random sets of values for each phi and theta (between -1 and 1) |
@@ -660,7 +660,7 @@ |
} |
} |
|
- double[] aicBIC = ARMAoptimize(mainFolder, phiString, thetaString, transformedData); |
+ double[] aicBIC = ARMAoptimize(directory, phiString, thetaString, transformedData); |
phiTheta[i][0] = String.valueOf(aicBIC[1]);//the BIC value |
phiTheta[i][1] = phiString; |
phiTheta[i][2] = thetaString; |
@@ -677,7 +677,7 @@ |
} |
/** |
* Perform an Auto-Regressive Moving Average ARMA(p,q) model on the provided annual timeseries data |
- * @param mainFolder the file location to write out the error file if necessary |
+ * @param directory the file location to write out the error file if necessary |
* @param phiString a tab-delimited string containing the pre-calculated phi values (lagged data coefficients) of the fitted ARMA(p,q) model |
* @param thetaString a tab-delimited string containing the pre-calculated theta (error coefficients) values of the fitted ARMA(p,q) model |
* @param transformedData double array of data. Column1 = years, column2 = flow values |
@@ -685,7 +685,7 @@ |
* returnArray[1] is the value of Bayesian Information Criterion (BIC) between the calculated ARMA(p, q) model and the original data |
* @throws IOException |
*/ |
- public double[] ARMAoptimize(String mainFolder, String phiString, String thetaString, double[][] transformedData) throws IOException{ |
+ public double[] ARMAoptimize(String directory, String phiString, String thetaString, double[][] transformedData) throws IOException{ |
String[] phiValues = phiString.split("\t"); |
String[] thetaValues = thetaString.split("\t"); |
int p = phiValues.length; |
@@ -765,7 +765,7 @@ |
} |
/** |
* Perform an Auto-Regressive Moving Average ARMA(p,q) model on the provided annual timeseries data |
- * @param mainFolder the file location to write out the error file if necessary |
+ * @param directory the file location to write out the error file if necessary |
* @param phiString a tab-delimited string containing the pre-calculated phi values (lagged data coefficients) of the fitted ARMA(p,q) model |
* @param thetaString a tab-delimited string containing the pre-calculated theta (error coefficients) values of the fitted ARMA(p,q) model |
* @param transformedData double array of data. Column1 = years, column2 = flow values |
@@ -773,7 +773,7 @@ |
* and the second element being the ARMA(p, q) generated data (double[][]) based on the provided phi values (phiString) and theta values (thetaString) |
* @throws IOException |
*/ |
- public Object[] ARMA(String mainFolder, String phiString, String thetaString, double[][] transformedData) throws IOException{ |
+ public Object[] ARMA(String directory, String phiString, String thetaString, double[][] transformedData) throws IOException{ |
String[] phiValues = phiString.split("\t"); |
String[] thetaValues = thetaString.split("\t"); |
int p = phiValues.length; |
@@ -889,12 +889,12 @@ |
} |
/** |
* Perform an Auto-Regressive Moving Average, ARMA(1,1), model on the provided annual timeseries data |
- * @param mainFolder the file location to write out the error file if necessary |
+ * @param directory the file location to write out the error file if necessary |
* @param transformedData double array of data. Column1 = years, column2 = flow values |
* @return |
* @throws IOException |
*/ |
- public String[] ARMA11(String mainFolder, double[][] transformedData) throws IOException{ |
+ public String[] ARMA11(String directory, double[][] transformedData) throws IOException{ |
//Error catch for available data vs. "p" order AR model |
int N = transformedData.length; |
if(N < (2*1 + 1)){ |
@@ -51,13 +51,13 @@ |
import org.jfree.ui.TextAnchor; |
|
/** |
-* Last Updated: 13-September-2016 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible |
* @since 10-July-2012 |
*/ |
public class guiDrought_Model { |
//Inputs |
- String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/Drought"; |
+ String directory = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/Drought"; |
String database = "USGS";//"CDWR";//"STORET";//"CDSN";//"UserData";// |
String organizationID = "n/a";//"n/a";//"21COL001";//"CITYFTCO_WQX";//"n/a";// |
String stationID = "06752000";//"CLAGRECO";//"000028";//"1EFF";//"n/a";// |
@@ -80,7 +80,7 @@ |
String dataSource = "?"; |
|
//Gets |
- public File getResult(){ return new File(mainFolder, "drought_summary.txt"); } |
+ public File getResult(){ return new File(directory, "drought_summary.txt"); } |
public String getTimeseriesGraph(){ return "drought1_timeseries.jpg"; } |
public String getColumnChart(){ return "drought2_column.jpg"; } |
public String getFittedDataGraph(){ return "drought3_fitted.jpg"; } |
@@ -91,11 +91,11 @@ |
String[] graphs = {"optimize_drought_graph3.jpg", "optimize_drought_graph4.jpg"}; |
return graphs; |
} |
- public File getTimeseriesOutput(){ return new File(mainFolder, "drought1_timeseries.out"); }//for use with JSHighCharts |
- public File getColumnChartOutput(){ return new File(mainFolder, "drought2_column.outt"); }//for use with JSHighCharts |
- public File getFittedGraphOutput(){ return new File(mainFolder, "drought3_fitted.out"); }//for use with JSHighCharts |
- public File getProjectedGraphOutput(){ return new File(mainFolder, "drought4_projected.out"); }//for use with JSHighCharts |
- public File getRecurrenceGraphOutput(){ return new File(mainFolder, "drought5_recurrence.out"); } |
+ public File getTimeseriesOutput(){ return new File(directory, "drought1_timeseries.out"); }//for use with JSHighCharts |
+ public File getColumnChartOutput(){ return new File(directory, "drought2_column.outt"); }//for use with JSHighCharts |
+ public File getFittedGraphOutput(){ return new File(directory, "drought3_fitted.out"); }//for use with JSHighCharts |
+ public File getProjectedGraphOutput(){ return new File(directory, "drought4_projected.out"); }//for use with JSHighCharts |
+ public File getRecurrenceGraphOutput(){ return new File(directory, "drought5_recurrence.out"); } |
public String getLen(){ return len; } |
public String getStart(){ return start; } |
public String getEnd(){ return end; } |
@@ -107,7 +107,7 @@ |
|
|
//Sets |
- public void setMainFolder(String mainFolder_str){ mainFolder = mainFolder_str; } |
+ public void setDirectory(String directory_str){ directory = directory_str; } |
public void setDatabase(String database_str){ database = database_str; } |
public void setOrganizationID(String organizationID_str){ organizationID = organizationID_str; } |
public void setStationID(String stationID_str){ stationID = stationID_str; } |
@@ -191,13 +191,13 @@ |
double[][] fittedData = null; |
double[][] predictedData = null; |
String methodType = ""; |
- Object[] returnArray = autoRegression.AutoregressiveModel(mainFolder, action, phiValues, thetaValues, transformedData); |
+ Object[] returnArray = autoRegression.AutoregressiveModel(directory, action, phiValues, thetaValues, transformedData); |
if(action.equalsIgnoreCase("optimizeParameters")){ |
//Find the parameters of the regression only and report these back |
String[] stringArray = (String[]) returnArray; |
|
//Perform regression with data and graph the resulting data |
- Object[] dataArray = autoRegression.AutoregressiveModel(mainFolder, "useParameters", stringArray[0], stringArray[1], transformedData); |
+ Object[] dataArray = autoRegression.AutoregressiveModel(directory, "useParameters", stringArray[0], stringArray[1], transformedData); |
|
//Keep the data from the regression and graph it |
methodType = (String) dataArray[0]; |
@@ -451,7 +451,7 @@ |
} |
|
//Save results for graphing with JSHighcharts |
- DoubleArray.writeTimeSeries(mainFolder, graphData, "Yearly", getTimeseriesOutput().getName(), false); |
+ DoubleArray.writeTimeSeries(directory, graphData, "Yearly", getTimeseriesOutput().getName(), false); |
|
//Graph data |
XYPlot plotTime = new XYPlot(); |
@@ -481,7 +481,7 @@ |
|
//Save resulting graph for use later |
try{ |
- String path = mainFolder + File.separator + getTimeseriesGraph(); |
+ String path = directory + File.separator + getTimeseriesGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("Graph located at:\t" + path); |
}catch(IOException e){ |
@@ -520,7 +520,7 @@ |
} |
|
//Save results for graphing with JSHighcharts |
- DoubleArray.writeXYseries(mainFolder, graphData, getColumnChartOutput().getName()); |
+ DoubleArray.writeXYseries(directory, graphData, getColumnChartOutput().getName()); |
|
//Define axis and properties |
NumberAxis numberaxis = new NumberAxis("Annual Deficit/Surplus of Drought Limit (" + tempRounding + " acre-ft)"); |
@@ -553,7 +553,7 @@ |
|
//Save resulting graph for use later |
try{ |
- String path = mainFolder + File.separator + getColumnChart(); |
+ String path = directory + File.separator + getColumnChart(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("Graph located at:\t" + path); |
}catch(IOException e){ |
@@ -601,7 +601,7 @@ |
} |
|
//Save results for graphing with JSHighcharts |
- DoubleArray.writeXYseries(mainFolder, graphData, getFittedGraphOutput().getName()); |
+ DoubleArray.writeXYseries(directory, graphData, getFittedGraphOutput().getName()); |
|
//Add first series to graph |
XYPlot plot = new XYPlot(); |
@@ -642,7 +642,7 @@ |
JFreeChart chart = new JFreeChart(graphTitle, Graphing.titleFont, plot, false); |
|
try{ |
- String path = mainFolder + File.separator + getFittedDataGraph(); |
+ String path = directory + File.separator + getFittedDataGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("Graph located at:\t" + path); |
}catch(IOException e){ |
@@ -684,7 +684,7 @@ |
} |
|
//Save results for graphing with JSHighcharts |
- DoubleArray.writeTimeSeries(mainFolder, graphData, "Yearly", getProjectedGraphOutput().getName(), false); |
+ DoubleArray.writeTimeSeries(directory, graphData, "Yearly", getProjectedGraphOutput().getName(), false); |
|
//Add first series to graph |
XYPlot plot = new XYPlot(); |
@@ -731,7 +731,7 @@ |
legendTitle.setItemFont(Graphing.masterFont); |
|
try{ |
- String path = mainFolder + File.separator + getProjectedDataGraph(); |
+ String path = directory + File.separator + getProjectedDataGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("Graph located at:\t" + path); |
}catch(IOException e){ |
@@ -831,7 +831,7 @@ |
ctr++;//Increase by 1 to move from x column to y column |
ctr++;//Increase by 1 to move from y column to new x column |
} |
- DoubleArray.writeXYseries(mainFolder, graphData, getRecurrenceGraphOutput().getName()); |
+ DoubleArray.writeXYseries(directory, graphData, getRecurrenceGraphOutput().getName()); |
|
|
//Create the X Axis |
@@ -877,7 +877,7 @@ |
legendTitle.setItemFont(Graphing.masterFont); |
|
try{ |
- String path = mainFolder + File.separator + getDroughtRecurrenceGraph(); |
+ String path = directory + File.separator + getDroughtRecurrenceGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("Graph located at:\t" + path); |
}catch(IOException e){ |
@@ -951,7 +951,7 @@ |
JFreeChart chart = new JFreeChart("AR(p) Parameter Optimization", Graphing.titleFont, plot, false); |
|
try{ |
- String path = mainFolder + File.separator + getOptimizedModel_ARgraph(); |
+ String path = directory + File.separator + getOptimizedModel_ARgraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("Graph located at:\t" + path); |
}catch(IOException e){ |
@@ -1082,7 +1082,7 @@ |
JFreeChart chart = new JFreeChart("ARMA(p, q) " + method + " Parameter Optimization", Graphing.titleFont, plot, false); |
|
try{ |
- String path = mainFolder + File.separator + getOptimizedModel_ARMAgraphs()[graphNumber-3]; |
+ String path = directory + File.separator + getOptimizedModel_ARMAgraphs()[graphNumber-3]; |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("Graph located at:\t" + path); |
}catch(IOException e){ |
@@ -1096,7 +1096,7 @@ |
*/ |
public void writeSummary(String[] dynamicSummary) throws IOException{ |
//Intialize the file writer |
- String path = mainFolder + File.separator + getResult().getName(); |
+ String path = directory + File.separator + getResult().getName(); |
FileWriter writer = new FileWriter(path, false); |
PrintWriter print_line = new PrintWriter(writer); |
|
@@ -1141,7 +1141,7 @@ |
} |
|
//Check if any flow data exists |
- String[][] sortableData = Data.extractFlowData(mainFolder, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
+ String[][] sortableData = Data.extractFlowData(directory, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
|
//If the user wants the datasets (public and user) merged then retrieve the second dataset (user) |
String[][] sortableData_user = new String[0][0]; |
@@ -33,13 +33,13 @@ |
import org.jfree.data.xy.XYSeriesCollection; |
|
/** |
-* Last Updated: 20-April-2017 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible |
* @since 12-June-2011 |
*/ |
public class guiDC_Model { |
//Inputs |
- String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/DurationCurve"; |
+ String directory = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/DurationCurve"; |
String database = "USGS";//"CDWR";//"STORET";//"CDSN";//"UserData";// |
String organizationID = "n/a";//"n/a";//"21COL001";//"CITYFTCO_WQX";//"n/a";// |
String stationID = "06764880";//"CLAGRECO";//"000028";//"1EFF";//"n/a";// |
@@ -85,13 +85,13 @@ |
|
|
//Gets |
- public File getDurationCurve_results(){ return new File(mainFolder, "duration_curve_results.txt"); } |
+ public File getDurationCurve_results(){ return new File(directory, "duration_curve_results.txt"); } |
public File getFlowStatistics_summary(){ |
FlowStatistics flowStats = new FlowStatistics(); |
- return new File(mainFolder, flowStats.getFlowStatistics_summary()); |
+ return new File(directory, flowStats.getFlowStatistics_summary()); |
} |
public String getGraph() { return "duration_curve_graph.jpg"; } |
- public File getDCgraphOutput(){ return new File(mainFolder, "duration_curve_graph.out"); }//for use with JSHighCharts |
+ public File getDCgraphOutput(){ return new File(directory, "duration_curve_graph.out"); }//for use with JSHighCharts |
public String getFlowLen() { return flowLen; } |
public String getMedian(){ return String.valueOf(flowMedian); } |
public String getMean(){ return String.valueOf(flowMean); } |
@@ -110,7 +110,7 @@ |
public double getMQNval(){ return mQnVal; } |
|
//Sets |
- public void setMainFolder(String mainFolder_str){ mainFolder = mainFolder_str; } |
+ public void setDirectory(String directory_str){ directory = directory_str; } |
public void setDatabase(String database_str){ database = database_str; } |
public void setOrganizationID(String organizationID_str){ organizationID = organizationID_str; } |
public void setStationID(String stationID_str){ stationID = stationID_str; } |
@@ -140,7 +140,7 @@ |
/** |
* Main Flow Duration Curve (FDC) function |
* Creates a graph and dynamic summary for the graph, returns an image and text file in |
- * location "mainFolder"/"fileName"graph.jpg and "mainFolder"/"fileName"paragraph.txt |
+ * location "directory"/"fileName"graph.jpg and "directory"/"fileName"paragraph.txt |
* @param storetResourceFile python driver.py resource file for storet data extraction |
* @throws IOException |
* @throws InterruptedException |
@@ -152,7 +152,7 @@ |
boolean mQnHide = mQnPeriod.contains("false"); |
|
//Check if any flow data exists |
- String[][] sortableData = Data.extractFlowData(mainFolder, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
+ String[][] sortableData = Data.extractFlowData(directory, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
|
//If the user wants the datasets (public and user) merged then retrieve the second dataset (user) |
String[][] sortableData_user = new String[0][0]; |
@@ -208,7 +208,7 @@ |
//Calculate the flow stats file |
FlowStatistics flowStats = new FlowStatistics(); |
if(calcFlowStatisticsFileTF){ |
- Object[] returnValue = flowStats.calculateAllStatisticsSummaries(mainFolder, stationID, stationName, sortedData_combined, highPercentile, lowPercentile, |
+ Object[] returnValue = flowStats.calculateAllStatisticsSummaries(directory, stationID, stationName, sortedData_combined, highPercentile, lowPercentile, |
m, n, showMonthlyStatsTF, seasonBegin, seasonEnd, period1Begin, period1End, period2Begin, period2End, period3Begin, period3End, false); |
|
//Calculate low flow |
@@ -451,7 +451,7 @@ |
} |
|
//Output XY data for use with JHighCharts |
- DoubleArray.writeXYseries(mainFolder, graphData, getDCgraphOutput().getName()); |
+ DoubleArray.writeXYseries(directory, graphData, getDCgraphOutput().getName()); |
|
//Set extra graphing preferences |
plot = Graphing.setLogYaxisPreferences(plot); |
@@ -472,7 +472,7 @@ |
|
//Save resulting graph for proof it works |
try{ |
- String path = mainFolder + File.separator + getGraph(); |
+ String path = directory + File.separator + getGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
}catch(IOException e){ |
@@ -483,7 +483,7 @@ |
/** |
* Main Load Duration Curve (LDC) function |
* Creates a graph and dynamic summary for the graph, returns an image and text file in |
- * location "mainFolder"/"fileName"graph.jpg and "mainFolder"/"fileName"paragraph.txt |
+ * location "directory"/"fileName"graph.jpg and "directory"/"fileName"paragraph.txt |
* @param storetResourceFile python driver.py resource file for storet data extraction |
* @throws IOException |
* @throws InterruptedException |
@@ -492,7 +492,7 @@ |
*/ |
private void createLDC(File storetResourceFile) throws IOException, InterruptedException, ParseException, JSONException { |
//Check if any flow and water quality data exists |
- Object[] returnArray1 = Data.extractFlow_and_WQdata(mainFolder, storetResourceFile, database, organizationID, stationID, beginDate, endDate, wqTest, userData); |
+ Object[] returnArray1 = Data.extractFlow_and_WQdata(directory, storetResourceFile, database, organizationID, stationID, beginDate, endDate, wqTest, userData); |
String[][] sortableData = (String[][]) returnArray1[0]; |
String[][] WQdata = (String[][]) returnArray1[1]; |
|
@@ -583,7 +583,7 @@ |
//Calculate the flow stats file |
FlowStatistics flowStats = new FlowStatistics(); |
if(calcFlowStatisticsFileTF){ |
- Object[] returnValue = flowStats.calculateAllStatisticsSummaries(mainFolder, stationID, stationName, sortedData_combined, highPercentile, lowPercentile, m, n, |
+ Object[] returnValue = flowStats.calculateAllStatisticsSummaries(directory, stationID, stationName, sortedData_combined, highPercentile, lowPercentile, m, n, |
showMonthlyStatsTF, seasonBegin, seasonEnd, period1Begin, period1End, period2Begin, period2End, period3Begin, period3End, false); |
|
//Calculate low flow |
@@ -1165,7 +1165,7 @@ |
} |
|
//Output XY data for use with JHighCharts |
- DoubleArray.writeXYseries(mainFolder, graphData, getDCgraphOutput().getName()); |
+ DoubleArray.writeXYseries(directory, graphData, getDCgraphOutput().getName()); |
|
//Add Flow Range Labels |
plot = Graphing.addIntervalLabel(plot, "High Flow", 0, 10); |
@@ -1190,7 +1190,7 @@ |
|
//Save resulting graph |
try{ |
- String path = mainFolder + File.separator + getGraph(); |
+ String path = directory + File.separator + getGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
}catch(IOException e){ |
@@ -1278,7 +1278,7 @@ |
} |
} |
|
- String path = mainFolder + File.separator + getDurationCurve_results().getName(); |
+ String path = directory + File.separator + getDurationCurve_results().getName(); |
FileWriter writer = new FileWriter(path, false); |
PrintWriter printLine = new PrintWriter(writer); |
|
@@ -81,7 +81,7 @@ |
} |
} |
/** |
-* Last Updated: 20-April-2017 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible (converted from Matlab to Java retaining comments from the Matlab code and the original Matlab code segments as comments before/after their corresponding Java code segments) |
* @author Jeff Burkey (originally written in Matlab) |
* @since Java version: 16-May-2012 |
@@ -100,7 +100,7 @@ |
* datain[][1] = peak annual flow rate |
* @param gg a generalized weighted skew |
* @param MSEGbar the error value for the generalized weighted skew |
- * @param mainFolder the file location of the output file |
+ * @param directory the file location of the output file |
* @param database the database of the current station |
* @param stationID the station ID of the current station |
* @param stationName the name of the current station |
@@ -113,7 +113,7 @@ |
public String[][] b17(double[][] datain, |
double gg, |
double MSEGbar, |
- String mainFolder, |
+ String directory, |
String database, |
String stationID, |
String stationName, |
@@ -528,7 +528,7 @@ |
|
//Graph the data (Tyler) |
//Matlab code: pplot(pp(:,2:4),K,dataout(:,2:end),GD,imgfile,gaugeName,plotref,plottype); |
- pplot(pp, K, dataout, GD, mainFolder, database, stationID, stationName, showLargeFloods, plotref, plottype); |
+ pplot(pp, K, dataout, GD, directory, database, stationID, stationName, showLargeFloods, plotref, plottype); |
|
//Assemble a summary of return periods and flow values (Tyler) |
String[][] summaryTable = probFreqData(dataout); |
@@ -801,7 +801,7 @@ |
* @param K K values for final frequency (double[][]) |
* @param curves calculated regressions (double[][]), ignore the first column |
* @param skew weighted skew used for final frequency curve (double) |
- * @param mainFolder the file location of the output file |
+ * @param directory the file location of the output file |
* @param database the database of the current station |
* @param stationID the station ID of the current station |
* @param stationName the name of the current station |
@@ -815,7 +815,7 @@ |
double[][] K, |
double[][] curves, |
double skew, |
- String mainFolder, |
+ String directory, |
String database, |
String stationID, |
String stationName, |
@@ -1119,7 +1119,7 @@ |
//Save resulting graph (Tyler) |
try{ |
guiFlood_Model model = new guiFlood_Model(); |
- String path = mainFolder + File.separator + model.getGraph(); |
+ String path = directory + File.separator + model.getGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), parentChart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
}catch(IOException e) { |
@@ -12,12 +12,12 @@ |
import java.util.Date; |
|
/** |
-* Last Updated: 13-September-2016 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible |
* @since 13-June-2012 |
*/ |
public class guiFlood_Model { |
- String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA"; |
+ String directory = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA"; |
String database = "USGS";//"CDWR";//"STORET";//"CDSN";//"UserData";// |
String organizationID = "n/a";//"n/a";//"21COL001";//"CITYFTCO_WQX";//"n/a";// |
String stationID = "06764880";//"CLAGRECO";//"000028";//"1EFF";//"n/a";// |
@@ -42,7 +42,7 @@ |
String skewErrorMessage = "?"; |
|
//Gets |
- public File getOutput(){ return new File(mainFolder, "flood_summary.txt"); } |
+ public File getOutput(){ return new File(directory, "flood_summary.txt"); } |
public String getGraph(){ return "flood_graph.jpg"; } |
public String getLen(){ return len; } |
public String getStart(){ return start; } |
@@ -51,7 +51,7 @@ |
public String getSkewErrorMessage(){ return skewErrorMessage; } |
|
//Sets |
- public void setMainFolder(String mainFolder_str){ mainFolder = mainFolder_str; } |
+ public void setDirectory(String directory_str){ directory = directory_str; } |
public void setDatabase(String database_str){ database = database_str; } |
public void setOrganizationID(String organizationID_str){ organizationID = organizationID_str; } |
public void setStationID(String stationID_str){ stationID = stationID_str; } |
@@ -74,7 +74,7 @@ |
* @throws IOException |
*/ |
public void writeSummary(String[][] dynamicSummary) throws IOException{ |
- String path = mainFolder + File.separator + getOutput().getName(); |
+ String path = directory + File.separator + getOutput().getName(); |
FileWriter writer = new FileWriter(path, false); |
PrintWriter print_line = new PrintWriter(writer); |
|
@@ -122,12 +122,12 @@ |
//Decide which analysis to perform |
if(analysisType.equalsIgnoreCase("B17")){ |
//Check if any flow data exists |
- double[][] peakFlowData = Data.extractFloodData(mainFolder, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
+ double[][] peakFlowData = Data.extractFloodData(directory, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
|
//Check if merging the datasets is desired, if so get the user data |
double[][] peakFlowData_user = new double[0][0]; |
if(mergeDatasets){ |
- peakFlowData_user = Data.extractFloodData(mainFolder, storetResourceFile, "UserData", "", "", beginDate, endDate, userData); |
+ peakFlowData_user = Data.extractFloodData(directory, storetResourceFile, "UserData", "", "", beginDate, endDate, userData); |
} |
|
//Merge the two datasets (if user data is empty nothing will be merged) |
@@ -148,7 +148,7 @@ |
|
//Run Bulletin 17 function and return graph |
Bulletin17B bulletin17B = new Bulletin17B(); |
- String[][] dataSummary = bulletin17B.b17(peakFlowData_combined, gg, MSERbar, mainFolder, database, stationID, stationName, showLargeFloods, plotref, plottype); |
+ String[][] dataSummary = bulletin17B.b17(peakFlowData_combined, gg, MSERbar, directory, database, stationID, stationName, showLargeFloods, plotref, plottype); |
|
//Get today's date for the source reference |
Date currentDate = new Date(); |
@@ -20,13 +20,13 @@ |
import org.codehaus.jettison.json.JSONException; |
|
/** |
-* Last Updated: 13-September-2016 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible & Tyler Dell |
* @since 27-March-2013 |
*/ |
public class guiLOADEST_Model { |
//Inputs |
- String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/LOADEST"; |
+ String directory = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/LOADEST"; |
String database = "USGS";//"CDWR";//"STORET";//"CDSN";//"UserData";// |
String organizationID = "n/a";//"n/a";//"21COL001";//"CITYFTCO_WQX";//"n/a";// |
String stationID = "06764880";//"CLAGRECO";//"000028";//"1EFF";//"n/a";// |
@@ -85,17 +85,17 @@ |
|
//Gets |
// public File getOutputSummary() { |
-// return new File(mainFolder, "echo.out"); |
+// return new File(directory, "echo.out"); |
// } |
- public File getOutputResult1() { return new File(mainFolder, fileName + ".ind"); } |
- public File getOutputResult2() { return new File(mainFolder, fileName + ".out"); } |
- public File getOutputResult3() { return new File(mainFolder, fileName + ".res"); } |
- public File getDailyTimeseries(){ return new File(mainFolder, "daily_graph.out"); }//for use with JSHighCharts |
- public File getDailyBoxplot(){ return new File(mainFolder, "daily_boxplot.out"); }//for use with JSHighCharts |
- public File getMonthlyTimeseries(){ return new File(mainFolder, "monthly_graph.out"); }//for use with JSHighCharts |
- public File getMonthlyBoxplot(){ return new File(mainFolder, "monthly_boxplot.out"); }//for use with JSHighCharts |
- public File getYearlyTimeseries(){ return new File(mainFolder, "yearly_graph.out"); }//for use with JSHighCharts |
- public File getYearlyBoxplot(){ return new File(mainFolder, "yearly_boxplot.out"); }//for use with JSHighCharts |
+ public File getOutputResult1() { return new File(directory, fileName + ".ind"); } |
+ public File getOutputResult2() { return new File(directory, fileName + ".out"); } |
+ public File getOutputResult3() { return new File(directory, fileName + ".res"); } |
+ public File getDailyTimeseries(){ return new File(directory, "daily_graph.out"); }//for use with JSHighCharts |
+ public File getDailyBoxplot(){ return new File(directory, "daily_boxplot.out"); }//for use with JSHighCharts |
+ public File getMonthlyTimeseries(){ return new File(directory, "monthly_graph.out"); }//for use with JSHighCharts |
+ public File getMonthlyBoxplot(){ return new File(directory, "monthly_boxplot.out"); }//for use with JSHighCharts |
+ public File getYearlyTimeseries(){ return new File(directory, "yearly_graph.out"); }//for use with JSHighCharts |
+ public File getYearlyBoxplot(){ return new File(directory, "yearly_boxplot.out"); }//for use with JSHighCharts |
public String getFlowLen() { return flowLen; } |
public String getWQLen() { return wqLen; } |
public String getWQUnits() { return wqUnits; } |
@@ -125,7 +125,7 @@ |
public String getYearlyStandardDeviation(){ return String.valueOf(yearlystandardDeviation); } |
|
//Sets |
- public void setMainFolder(String mainFolder_str){ mainFolder = mainFolder_str; } |
+ public void setDirectory(String directory_str){ directory = directory_str; } |
public void setDatabase(String database_str){ database = database_str; } |
public void setOrganizationID(String organizationID_str){ organizationID = organizationID_str; } |
public void setStationName(String stationName_str){ stationName = stationName_str; } |
@@ -150,7 +150,7 @@ |
* @throws IOException |
*/ |
private void writeControl()throws IOException { |
- String path = mainFolder + File.separator + "CONTROL.INP"; |
+ String path = directory + File.separator + "CONTROL.INP"; |
FileWriter writer = new FileWriter(path, false); |
PrintWriter print_line = new PrintWriter(writer); |
|
@@ -181,7 +181,7 @@ |
* @throws IOException |
*/ |
private void writeHeader()throws IOException { |
- String path = mainFolder + File.separator + "HEADER.INP"; |
+ String path = directory + File.separator + "HEADER.INP"; |
FileWriter writer = new FileWriter(path, false); |
PrintWriter print_line = new PrintWriter(writer); |
|
@@ -289,7 +289,7 @@ |
wqLen = String.valueOf(CCONC.size()); |
|
|
- String path = mainFolder + File.separator + "CALIB.INP"; |
+ String path = directory + File.separator + "CALIB.INP"; |
FileWriter writer = new FileWriter(path, false); |
PrintWriter print_line = new PrintWriter(writer); |
|
@@ -344,7 +344,7 @@ |
} |
|
// open the file writer and set path |
- String path = mainFolder + File.separator + "EST.INP"; |
+ String path = directory + File.separator + "EST.INP"; |
FileWriter writer = new FileWriter(path, false); |
PrintWriter print_line = new PrintWriter(writer); |
|
@@ -584,7 +584,7 @@ |
//String endLoadUnits = resultArray[4]; |
|
//Check if any flow and water quality data exists |
- Object[] returnArray1 = Data.extractFlow_and_WQdata(mainFolder, storetResourceFile, database, organizationID, stationID, beginDate, endDate, wqTest, userData); |
+ Object[] returnArray1 = Data.extractFlow_and_WQdata(directory, storetResourceFile, database, organizationID, stationID, beginDate, endDate, wqTest, userData); |
String[][] sortableData = (String[][]) returnArray1[0]; |
String[][] WQdata = (String[][]) returnArray1[1]; |
|
@@ -652,22 +652,22 @@ |
e.exec(); |
|
//Expected Output: "echo.out" and fileName + ".ind", fileName + ".out", fileName + ".res" |
- if (!new File(mainFolder, "echo.out").exists()) { |
+ if (!new File(directory, "echo.out").exists()) { |
throw new FileNotFoundException("echo.out"); |
} |
- if (!new File(mainFolder, fileName + ".ind").exists()) { |
+ if (!new File(directory, fileName + ".ind").exists()) { |
throw new FileNotFoundException(fileName + ".ind"); |
} |
- if (!new File(mainFolder, fileName + ".out").exists()) { |
+ if (!new File(directory, fileName + ".out").exists()) { |
throw new FileNotFoundException(fileName + ".out"); |
} |
- if (!new File(mainFolder, fileName + ".res").exists()) { |
+ if (!new File(directory, fileName + ".res").exists()) { |
throw new FileNotFoundException(fileName + ".res"); |
} |
System.out.println("Finished LOADEST.exe"); |
|
// Daily result data |
- String[][] dailyData = OpenLOADESTresultFile(mainFolder + File.separator + fileName + ".ind"); |
+ String[][] dailyData = OpenLOADESTresultFile(directory + File.separator + fileName + ".ind"); |
|
//convert results to daily,monthly,yearly |
String[][] dailyresultData = DoubleArray.computeFlowMethod(dailyData, "daily", "total", true); |
@@ -719,13 +719,13 @@ |
double[][] yearlyBoxplotData = {{yearlymax},{yearlyupperQuartile},{yearlymedian},{yearlylowerQuartile},{yearlymin}}; |
|
//Put graph file writer call here |
- DoubleArray.writeTimeSeries(mainFolder, dailyresultData, "daily", getDailyTimeseries().getName(), true); |
- DoubleArray.writeTimeSeries(mainFolder, monthlyresultData, "monthly", getMonthlyTimeseries().getName(), true); |
- DoubleArray.writeTimeSeries(mainFolder, yearlyresultData, "yearly", getYearlyTimeseries().getName(), true); |
+ DoubleArray.writeTimeSeries(directory, dailyresultData, "daily", getDailyTimeseries().getName(), true); |
+ DoubleArray.writeTimeSeries(directory, monthlyresultData, "monthly", getMonthlyTimeseries().getName(), true); |
+ DoubleArray.writeTimeSeries(directory, yearlyresultData, "yearly", getYearlyTimeseries().getName(), true); |
|
- DoubleArray.writeBoxplot(mainFolder, dailyBoxplotOutliers, dailyBoxplotData, getDailyBoxplot().getName()); |
- DoubleArray.writeBoxplot(mainFolder, monthlyBoxplotOutliers, monthlyBoxplotData, getMonthlyBoxplot().getName()); |
- DoubleArray.writeBoxplot(mainFolder, yearlyBoxplotOutliers, yearlyBoxplotData, getYearlyBoxplot().getName()); |
+ DoubleArray.writeBoxplot(directory, dailyBoxplotOutliers, dailyBoxplotData, getDailyBoxplot().getName()); |
+ DoubleArray.writeBoxplot(directory, monthlyBoxplotOutliers, monthlyBoxplotData, getMonthlyBoxplot().getName()); |
+ DoubleArray.writeBoxplot(directory, yearlyBoxplotOutliers, yearlyBoxplotData, getYearlyBoxplot().getName()); |
|
// Find what units that LOADEST has given the Load in |
String graphUnits = "??"; |
@@ -9,7 +9,7 @@ |
import java.util.Date; |
|
/** |
-* Last Updated: 13-September-2016 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible |
* @since 16-December-2014 |
*/ |
@@ -19,7 +19,7 @@ |
* based on an 'm'-day average low flow of each year fitted to a Log-Pearson |
* Type III distribution and interpolated for a return period of 'R' years |
* @param flowData flow data, column1 = dates (format yyyy-mm-dd), column2 = flow values |
- * @param m the number of days to average for annual low flow analysis (m-day average) |
+ * @param M the number of days to average for annual low flow analysis (m-day average) |
* @param R the desired return period of the m-day low flow (in years) |
* @param waterYearBegin the month and day (MM-dd) of the start of the water year for this analysis |
* @return |
@@ -27,7 +27,7 @@ |
* @throws ParseException |
*/ |
public double CDPHE_ExtremeValue(String[][] flowData, |
- int m, |
+ int M, |
double R, |
String waterYearBegin) throws IOException, ParseException{ |
if(flowData.length == 0){ |
@@ -56,7 +56,7 @@ |
if(partialData.length > 0){ |
|
//Calculate m-day statistics |
- Object[] resultArray = DoubleArray.getMdayData(partialData, m, "arithmetic"); |
+ Object[] resultArray = DoubleArray.getMdayData(partialData, M, "arithmetic"); |
//ArrayList<String> average_Mday_date = (ArrayList<String>) resultArray[0]; |
ArrayList<Double> average_Mday = (ArrayList<Double>) resultArray[1]; |
|
@@ -104,8 +104,6 @@ |
|
//Compute design flow |
double designFlow = Math.exp(U + K*S); |
- |
- //Call file writer for outputs fo flow statistics |
designFlow = DoubleMath.round(designFlow, 2); |
|
return designFlow; |
@@ -115,7 +113,7 @@ |
* which is an 'm'-day harmonic average low flow based on a certain excursion count (exceedance?), |
* performs this calculation for the entire flow record as well as each month of the year |
* @param flowData a String[][] of flow data, column1 = dates (format yyyy-mm-dd), column2 = flow values |
- * @param m the number of days to average for annual low flow analysis (m-day average) |
+ * @param M the number of days to average for annual low flow analysis (m-day average) |
* @param R the desired return period of the m-day low flow (in years) |
* @param clusterLength the length of time for the definition of a 'cluster' of excursion |
* periods (default should be 120). All excursion periods within this amount of |
@@ -127,17 +125,17 @@ |
* @throws ParseException |
*/ |
public double[] CDPHE_Biological(String[][] flowData, |
- int m, |
+ int M, |
int R, |
int clusterLength, |
int clusterCountMax) throws IOException, ParseException{ |
//Calculate annual design low flow |
- double DFLOW_annual = CDPHE_Biological_calcs(flowData, m, R, clusterLength, clusterCountMax); |
+ double DFLOW_annual = CDPHE_Biological_calcs(flowData, M, R, clusterLength, clusterCountMax); |
|
//Calculate monthly design low flows |
double DFLOW_jan = -9999, DFLOW_feb = -9999, DFLOW_mar = -9999, DFLOW_apr = -9999, DFLOW_may = -9999, DFLOW_jun = -9999; |
double DFLOW_jul = -9999, DFLOW_aug = -9999, DFLOW_sep = -9999, DFLOW_oct = -9999, DFLOW_nov = -9999, DFLOW_dec = -9999; |
- if(m == 30 && R == 3){ |
+ if(M == 30 && R == 3){ |
//If the design flow is 30E3, follow the special provisions set out by reg31 |
double[] monthlyDFLOWs = calc30E3(flowData, DFLOW_annual); |
DFLOW_jan = monthlyDFLOWs[0]; |
@@ -154,35 +152,23 @@ |
DFLOW_dec = monthlyDFLOWs[11]; |
}else{ |
//Otherwise treat it as a normal biological flow |
- DFLOW_jan = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "01-01", "01-31"), m, R, clusterLength, clusterCountMax); |
- DFLOW_feb = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "02-01", "02-28"), m, R, clusterLength, clusterCountMax); |
- DFLOW_mar = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "03-01", "03-31"), m, R, clusterLength, clusterCountMax); |
- DFLOW_apr = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "04-01", "04-30"), m, R, clusterLength, clusterCountMax); |
- DFLOW_may = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "05-01", "05-31"), m, R, clusterLength, clusterCountMax); |
- DFLOW_jun = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "06-01", "06-30"), m, R, clusterLength, clusterCountMax); |
- DFLOW_jul = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "07-01", "07-31"), m, R, clusterLength, clusterCountMax); |
- DFLOW_aug = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "08-01", "08-31"), m, R, clusterLength, clusterCountMax); |
- DFLOW_sep = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "09-01", "09-30"), m, R, clusterLength, clusterCountMax); |
- DFLOW_oct = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "10-01", "10-31"), m, R, clusterLength, clusterCountMax); |
- DFLOW_nov = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "11-01", "11-30"), m, R, clusterLength, clusterCountMax); |
- DFLOW_dec = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "12-01", "12-31"), m, R, clusterLength, clusterCountMax); |
+ DFLOW_jan = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "01-01", "01-31"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_feb = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "02-01", "02-28"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_mar = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "03-01", "03-31"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_apr = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "04-01", "04-30"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_may = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "05-01", "05-31"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_jun = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "06-01", "06-30"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_jul = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "07-01", "07-31"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_aug = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "08-01", "08-31"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_sep = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "09-01", "09-30"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_oct = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "10-01", "10-31"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_nov = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "11-01", "11-30"), M, R, clusterLength, clusterCountMax); |
+ DFLOW_dec = CDPHE_Biological_calcs(DoubleArray.getSeasonalData(flowData, "12-01", "12-31"), M, R, clusterLength, clusterCountMax); |
} |
|
- //Calculate design flows |
- double[] designFlows = new double[13]; |
- designFlows[0] = DoubleMath.round(DFLOW_annual, 2); //entire record |
- designFlows[1] = DoubleMath.round(DFLOW_jan, 2); //January |
- designFlows[2] = DoubleMath.round(DFLOW_feb, 2); //February |
- designFlows[3] = DoubleMath.round(DFLOW_mar, 2); //March |
- designFlows[4] = DoubleMath.round(DFLOW_apr, 2); //April |
- designFlows[5] = DoubleMath.round(DFLOW_may, 2); //May |
- designFlows[6] = DoubleMath.round(DFLOW_jun, 2); //June |
- designFlows[7] = DoubleMath.round(DFLOW_jul, 2); //July |
- designFlows[8] = DoubleMath.round(DFLOW_aug, 2); //August |
- designFlows[9] = DoubleMath.round(DFLOW_sep, 2); //September |
- designFlows[10] = DoubleMath.round(DFLOW_oct, 2); //October |
- designFlows[11] = DoubleMath.round(DFLOW_nov, 2); //November |
- designFlows[12] = DoubleMath.round(DFLOW_dec, 2); //December |
+ //Round design flows |
+ double[] designFlows = {DFLOW_annual, DFLOW_jan, DFLOW_feb, DFLOW_mar, DFLOW_apr, DFLOW_may, DFLOW_jun, DFLOW_jul, DFLOW_aug, DFLOW_sep, DFLOW_oct, DFLOW_nov, DFLOW_dec}; |
+ DoubleMath.roundColumn(designFlows, 2); |
|
return designFlows; |
} |
@@ -190,7 +176,7 @@ |
* Calculate the CDPHE "biologically-based" design flow (see DFLOW user manual) |
* which is an 'm'-day harmonic average low flow based on a certain excursion count (exceedance?) |
* @param flowData flow data, column1 = dates (format yyyy-mm-dd), column2 = flow values |
- * @param m the number of days to average for annual low flow analysis (m-day average) |
+ * @param M the number of days to average for annual low flow analysis (m-day average) |
* @param R the desired return period of the m-day low flow (in years) |
* @param clusterLength the length of time for the definition of a 'cluster' of excursion |
* periods (default should be 120). All excursion periods within this amount of |
@@ -202,22 +188,22 @@ |
* @throws ParseException |
*/ |
private double CDPHE_Biological_calcs(String[][] flowData, |
- int m, |
+ int M, |
int R, |
int clusterLength, |
int clusterCountMax) throws IOException, ParseException{ |
//Calculate m-day statistics |
- Object[] resultArray = DoubleArray.getMdayData(flowData, m, "harmonic"); |
+ Object[] resultArray = DoubleArray.getMdayData(flowData, M, "harmonic"); |
ArrayList<String> average_Mday_date = (ArrayList<String>) resultArray[0]; |
ArrayList<Double> average_Mday = (ArrayList<Double>) resultArray[1]; |
|
//Get extreme-value based design flow (as a trial design flow to start searching for the biologically based one, note this still uses an arithmetic mean) |
- double trialDFLOW = CDPHE_ExtremeValue(flowData, m, R, "04-01"); |
+ double trialDFLOW = CDPHE_ExtremeValue(flowData, M, R, "04-01"); |
if(trialDFLOW == 0){ |
//Catch zero-flow guess to avoid ending the convergence loop early and reporting a zero when it shouldn't be zero |
trialDFLOW = DoubleMath.meanHarmonic(average_Mday); |
} |
- double trialDFLOW_excursions = countExcursions(average_Mday_date, average_Mday, m, trialDFLOW, clusterLength, clusterCountMax); |
+ double trialDFLOW_excursions = countExcursions(average_Mday_date, average_Mday, M, trialDFLOW, clusterLength, clusterCountMax); |
|
//Get allowed number of excursions |
double A = flowData.length/(R * 365.25); |
@@ -246,7 +232,7 @@ |
}else{ |
//If convergance is not met, interpolate a new trial design flow and count it's excursions |
trialDFLOW = flow_lowerBound + ( ((flow_upperBound - flow_lowerBound) * (A - excursions_lowerBound)) / (excursions_upperBound - excursions_lowerBound) ); |
- trialDFLOW_excursions = countExcursions(average_Mday_date, average_Mday, m, trialDFLOW, clusterLength, clusterCountMax); |
+ trialDFLOW_excursions = countExcursions(average_Mday_date, average_Mday, M, trialDFLOW, clusterLength, clusterCountMax); |
if(trialDFLOW_excursions <= A){ |
flow_lowerBound = trialDFLOW; |
excursions_lowerBound = trialDFLOW_excursions; |
@@ -52,13 +52,13 @@ |
import org.jfree.ui.RectangleInsets; |
|
/** |
-* Last Updated: 13-September-2016 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible |
* @since 24-June-2011 |
*/ |
public class guiTimeseries_Model { |
//Inputs |
- String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/Timeseries"; |
+ String directory = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/Timeseries"; |
String database = "USGS";//"CDWR";//"STORET";//"CDSN";//"UserData";// |
String organizationID = "n/a";//"n/a";//"21COL001";//"CITYFTCO_WQX";//"n/a";// |
String stationID = "06764880";//"CLAGRECO";//"000028";//"1EFF";//"n/a";// |
@@ -186,18 +186,18 @@ |
|
|
//Gets |
- public File getParagraph(){ return new File(mainFolder, "timeseries_summary.txt"); } |
+ public File getParagraph(){ return new File(directory, "timeseries_summary.txt"); } |
public File getFlowStatistics_summary() { |
FlowStatistics flowStats = new FlowStatistics(); |
- return new File(mainFolder, flowStats.getFlowStatistics_summary()); |
+ return new File(directory, flowStats.getFlowStatistics_summary()); |
} |
- public File getTimeseriesOutput(){ return new File(mainFolder, "timeseries_graph.out"); }//for use with JSHighCharts |
- public File getBoxplotOutput(){ return new File(mainFolder, "timeseries_boxplot.out"); }//for use with JSHighCharts |
- public File getMonthlyTimeseriesOutput(){ return new File(mainFolder, "timeseries_monthlygraph.out"); }//for use with JSHighCharts |
-// public File getMonthlyBoxplotOutput(){ return new File(mainFolder, "timeseries_monthlyboxplot.out"); }//for use with JSHighCharts |
- public File getTimeseriesEnvelopeOutput(){ return new File(mainFolder, "timeseries_envelope.out"); }//for use with JSHighCharts |
- public File getHistogramOutput(){ return new File(mainFolder, "timeseries_histogram.outt"); }//for use with JSHighCharts |
- public File getCDFoutput(){ return new File(mainFolder, "timeseries_cdf.out"); }//for use with JSHighCharts |
+ public File getTimeseriesOutput(){ return new File(directory, "timeseries_graph.out"); }//for use with JSHighCharts |
+ public File getBoxplotOutput(){ return new File(directory, "timeseries_boxplot.out"); }//for use with JSHighCharts |
+ public File getMonthlyTimeseriesOutput(){ return new File(directory, "timeseries_monthlygraph.out"); }//for use with JSHighCharts |
+// public File getMonthlyBoxplotOutput(){ return new File(directory, "timeseries_monthlyboxplot.out"); }//for use with JSHighCharts |
+ public File getTimeseriesEnvelopeOutput(){ return new File(directory, "timeseries_envelope.out"); }//for use with JSHighCharts |
+ public File getHistogramOutput(){ return new File(directory, "timeseries_histogram.outt"); }//for use with JSHighCharts |
+ public File getCDFoutput(){ return new File(directory, "timeseries_cdf.out"); }//for use with JSHighCharts |
public String getGraph(){ return "timeseries_graph.jpg"; } |
public String getBoxplot(){ return "timeseries_boxplot.jpg"; } |
public String getTimeseriesEnvelope(){ return "timeseries_envelope.jpg"; } |
@@ -287,7 +287,7 @@ |
public String getKendallCorrelationCoefficient_period3(){ return String.valueOf(kendallCorlCoeff_period3); } |
|
//Sets |
- public void setMainFolder(String mainFolder_str){ mainFolder = mainFolder_str; } |
+ public void setDirectory(String directory_str){ directory = directory_str; } |
public void setDatabase(String database_str){ database = database_str; } |
public void setOrganizationID(String organizationID_str){ organizationID = organizationID_str; } |
public void setBeginDate(String beginDate_str){ beginDate = beginDate_str; } |
@@ -516,7 +516,7 @@ |
|
//Write output for JHighChart timeseries for use on eRAMS |
Arrays.sort(graphData, new m.cfa.DateComparator()); |
- DoubleArray.writeTimeSeries(mainFolder, graphData, timeStep, getTimeseriesOutput().getName(), false); |
+ DoubleArray.writeTimeSeries(directory, graphData, timeStep, getTimeseriesOutput().getName(), false); |
|
//Create TimeSeries graph of merged data |
XYPlot plotTime = new XYPlot(); |
@@ -629,7 +629,7 @@ |
|
//Save resulting graph for use later |
try{ |
- String path = mainFolder + File.separator + getGraph(); |
+ String path = directory + File.separator + getGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
|
@@ -656,7 +656,7 @@ |
double[][] boxplotData = {{max},{upperQuartile},{median},{lowerQuartile},{min}}; |
|
//Write output for JHighChart boxplot for use on eRAMS |
- DoubleArray.writeBoxplot(mainFolder, boxplotOutliers, boxplotData, getBoxplotOutput().getName()); |
+ DoubleArray.writeBoxplot(directory, boxplotOutliers, boxplotData, getBoxplotOutput().getName()); |
|
|
//Create boxplot of the timeseries data |
@@ -793,7 +793,7 @@ |
|
//Save resulting graph for use later |
try{ |
- String path = mainFolder + File.separator + getBoxplot(); |
+ String path = directory + File.separator + getBoxplot(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 200, 400); |
System.out.println("JFreeChart created properly at: " + path); |
|
@@ -893,7 +893,7 @@ |
} |
} |
//Save cdf data for JHighCharts |
- DoubleArray.writeXYseries(mainFolder, cdfData, getCDFoutput().getName()); |
+ DoubleArray.writeXYseries(directory, cdfData, getCDFoutput().getName()); |
|
//Create renderer, and axis for timeseries graph |
XYPlot plot = new XYPlot(); |
@@ -968,7 +968,7 @@ |
|
//Save monthly timeseries graph for use later |
try{ |
- String path = mainFolder + File.separator + getCDF(); |
+ String path = directory + File.separator + getCDF(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
|
@@ -1224,7 +1224,7 @@ |
|
//Output monthly boxplot and timeseries data for use with JHighCharts |
if(rasterTF || envelopeTF){ |
- DoubleArray.writeTimeSeries(mainFolder, graphData, "daily", getTimeseriesEnvelopeOutput().getName(), false); |
+ DoubleArray.writeTimeSeries(directory, graphData, "daily", getTimeseriesEnvelopeOutput().getName(), false); |
} |
|
//Check if the user desires a raster graph |
@@ -1267,7 +1267,7 @@ |
|
//Save monthly timeseries graph for use later |
try{ |
- String path = mainFolder + File.separator + getTimeseriesEnvelope(); |
+ String path = directory + File.separator + getTimeseriesEnvelope(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
|
@@ -1387,7 +1387,7 @@ |
|
//Save monthly timeseries graph for use later |
try{ |
- String path = mainFolder + File.separator + getTimeseriesRaster(); |
+ String path = directory + File.separator + getTimeseriesRaster(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
|
@@ -1598,7 +1598,7 @@ |
} |
} |
//Save histogram data for JHighCharts |
- DoubleArray.writeXYseries(mainFolder, histogramData, getHistogramOutput().getName()); |
+ DoubleArray.writeXYseries(directory, histogramData, getHistogramOutput().getName()); |
|
//Define renderer properties for bar graph |
int seriesIndex = 0; |
@@ -1646,7 +1646,7 @@ |
|
//Save resulting graph for use later |
try{ |
- String path = mainFolder + File.separator + getHistogram(); |
+ String path = directory + File.separator + getHistogram(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
}catch(IOException e){ |
@@ -1885,8 +1885,8 @@ |
} |
|
//Output monthly boxplot and timeseries data for use with JHighCharts |
- DoubleArray.writeXYseries(mainFolder, monthXYdata, getMonthlyTimeseriesOutput().getName()); |
-// DoubleArray.writeBoxplot(mainFolder, boxplotOutliers, boxplotData, getMonthlyBoxplotOutput().getName()); |
+ DoubleArray.writeXYseries(directory, monthXYdata, getMonthlyTimeseriesOutput().getName()); |
+// DoubleArray.writeBoxplot(directory, boxplotOutliers, boxplotData, getMonthlyBoxplotOutput().getName()); |
|
//Create Y Axis |
ValueAxis rangeAxis = new NumberAxis(yAxisTitle); |
@@ -1914,7 +1914,7 @@ |
|
//Save monthly timeseries graph for use later |
try{ |
- String path = mainFolder + File.separator + getMonthlyGraph(); |
+ String path = directory + File.separator + getMonthlyGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
|
@@ -1966,7 +1966,7 @@ |
String[][] sortableData = new String[0][2]; |
if(wqTest.equalsIgnoreCase("flow")){ |
//Check if any flow data exists |
- sortableData = Data.extractFlowData(mainFolder, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
+ sortableData = Data.extractFlowData(directory, storetResourceFile, database, organizationID, stationID, beginDate, endDate, userData); |
|
//Define other graph information |
graphUnits = "cfs"; |
@@ -1981,7 +1981,7 @@ |
showLine = true; |
}else{ |
//Search for WQ data |
- Object[] returnArray = Data.extractWQdata(mainFolder, storetResourceFile, database, organizationID, stationID, beginDate, endDate, wqTest, userData); |
+ Object[] returnArray = Data.extractWQdata(directory, storetResourceFile, database, organizationID, stationID, beginDate, endDate, wqTest, userData); |
sortableData = (String[][]) returnArray[0]; |
graphUnits = (String) returnArray[1]; |
WQlabel = (String) returnArray[2]; |
@@ -2046,7 +2046,7 @@ |
|
//Calculate Hydrologic Indicators of Alteration |
if(calcFlowStatisticsFileTF){ |
- flowStats.calculateAllStatisticsSummaries(mainFolder, stationID, stationName, sortedData_combined, highPercentile, lowPercentile, 0, 0, showMonthlyStatsTF, |
+ flowStats.calculateAllStatisticsSummaries(directory, stationID, stationName, sortedData_combined, highPercentile, lowPercentile, 0, 0, showMonthlyStatsTF, |
seasonBegin, seasonEnd, period1Begin, period1End, period2Begin, period2End, period3Begin, period3End, waterYearTF); |
} |
|
@@ -2106,7 +2106,7 @@ |
}else{ |
//Report that there cannot be flow statistics for water quality data |
String[][] errorMessage = {{"Error"," Cannot compute flow statistics as indicators of hydrologic alteration using water quality data."},{"This output is only applicable for flow analysis.",""}}; |
- flowStats.writeStatsSummaryFile(mainFolder, errorMessage); |
+ flowStats.writeStatsSummaryFile(directory, errorMessage); |
} |
|
//Perform analysis method on data |
@@ -30,12 +30,12 @@ |
import org.jfree.data.time.TimeSeries; |
|
/** |
-* Last Updated: 13-September-2016 |
+* Last Updated: 31-May-2017 |
* @author Tyler Wible |
* @since 23-June-2014 |
*/ |
public class gui15minTimeseries_Model { |
- String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/Timeseries"; |
+ String directory = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/Timeseries"; |
String database = "USGS";//"CDWR"; |
String stationID = "06752260";//"CLAGRECO"; |
String stationName = "CACHE LA POUDRE RIVER AT FORT COLLINS, CO";//"Cache La Poudre Near Greeley"; |
@@ -60,14 +60,14 @@ |
|
//Gets |
public File getOutputSummary() { |
- return new File(mainFolder, "timeseries15min_summary.csv"); |
+ return new File(directory, "timeseries15min_summary.csv"); |
} |
public String getGraph() { |
return "timeseries15min_graph.jpg"; |
} |
public File getTimeseriesOutput(){ |
//This output file is for use with JSHighCharts |
- return new File(mainFolder, "timeseries15min_graph.out"); |
+ return new File(directory, "timeseries15min_graph.out"); |
} |
public String getLen(){ return len; } |
public String getStart(){ return start; } |
@@ -81,7 +81,7 @@ |
public String getStandardDeviation(){ return String.valueOf(standardDeviation); } |
|
//Sets |
- public void setMainFolder(String mainFolder_str){ mainFolder = mainFolder_str; } |
+ public void setDirectory(String directory_str){ directory = directory_str; } |
public void setDatabase(String database_str){ database = database_str; } |
public void setStationID(String stationID_str){ stationID = stationID_str; } |
public void setStationName(String stationName_str){ stationName = stationName_str; } |
@@ -203,7 +203,7 @@ |
} |
|
//Output XY data for use with JHighCharts |
- DoubleArray.writeTimeSeries(mainFolder, graphData, "15-min", getTimeseriesOutput().getName(), false); |
+ DoubleArray.writeTimeSeries(directory, graphData, "15-min", getTimeseriesOutput().getName(), false); |
|
//Create renderer, and axis for timeseries graph |
XYPlot plotTime = new XYPlot(); |
@@ -243,7 +243,7 @@ |
|
//Save resulting graph for use later |
try{ |
- String path = mainFolder + File.separator + getGraph(); |
+ String path = directory + File.separator + getGraph(); |
ChartUtilities.saveChartAsJPEG(new File(path), chart, 1280, 800); |
System.out.println("JFreeChart created properly at: " + path); |
|
@@ -271,7 +271,7 @@ |
*/ |
private void writeSummary(String[][] resultsSummary) throws IOException{ |
//Open a file writer for the summary of the flow statistcs |
- String path = mainFolder + File.separator + getOutputSummary().getName(); |
+ String path = directory + File.separator + getOutputSummary().getName(); |
FileWriter newFile = new FileWriter(path, false); |
PrintWriter writer = new PrintWriter(newFile); |
|
@@ -305,7 +305,7 @@ |
} |
|
//Check if any flow data exists |
- String[][] sortableData = Data.extractInstantaneousFlowData(mainFolder, database, stationID, beginDate, endDate, userData); |
+ String[][] sortableData = Data.extractInstantaneousFlowData(directory, database, stationID, beginDate, endDate, userData); |
|
//If the user wants the datasets (public and user) merged then retrieve the second dataset (user) |
String[][] sortableData_user = new String[0][0]; |