@@ -2,10 +2,12 @@ |
|
import java.io.File; |
import java.io.IOException; |
+import java.text.ParseException; |
import java.util.ArrayList; |
+import org.codehaus.jettison.json.JSONException; |
|
/** |
-* Last Updated: 17-March-2016 |
+* Last Updated: 28-April-2016 |
* @author Tyler Wible |
* @since 25-January-2014 |
*/ |
@@ -75,6 +77,14 @@ |
flowData = (String[][]) returnArray[1]; |
//String start = (String) returnArray[2]; |
//String end = (String) returnArray[3]; |
+ }else if(database.equalsIgnoreCase("CDSN")){ |
+ //Search for CDWR flow data |
+ CDSN_Data cdsn_data = new CDSN_Data(); |
+ Object[] returnArray = cdsn_data.getCDSNdata(organizationID, stationID, "flow", beginDate, endDate); |
+ //ArrayList<String> resultFileContents = (ArrayList<String>) returnArray[0]; |
+ flowData = (String[][]) returnArray[1]; |
+ //String start = (String) returnArray[2]; |
+ //String end = (String) returnArray[3]; |
} |
|
return flowData; |
@@ -102,7 +112,7 @@ |
String beginDate, |
String endDate, |
String wqTest, |
- String userData) throws IOException, InterruptedException{ |
+ String userData) throws IOException, InterruptedException, ParseException, JSONException{ |
String[][] wqData = new String[0][2]; |
String wqLabel = "??", wqUnits = "??"; |
if(database.equalsIgnoreCase("USGS")){ |
@@ -152,6 +162,21 @@ |
ArrayList<String> errorMessage = new ArrayList<String>(); |
errorMessage.add("There is no available water quality data available for the CDWR database. This feature is only available for stations in the USGS or STORET databases."); |
writeError(errorMessage); |
+ }else if(database.equalsIgnoreCase("CDSN")){ |
+ String[] resultArray = getWQtestDataInfo(wqTest, database); |
+ //String wqCode = resultArray[0]; |
+ wqLabel = resultArray[1]; |
+ wqUnits = resultArray[2]; |
+ //double loadConversion = Double.parseDouble(resultArray[3]); |
+ //String endLoadUnits = resultArray[4]; |
+ |
+ //Search for CDWR flow data |
+ CDSN_Data cdsn_data = new CDSN_Data(); |
+ Object[] returnArray = cdsn_data.getCDSNdata(organizationID, stationID, wqTest, beginDate, endDate); |
+ //ArrayList<String> resultFileContents = (ArrayList<String>) returnArray[0]; |
+ wqData = (String[][]) returnArray[1]; |
+ //String start = (String) returnArray[2]; |
+ //String end = (String) returnArray[3]; |
} |
|
Object[] returnArray = {wqData, wqUnits, wqLabel}; |
@@ -181,7 +206,7 @@ |
String beginDate, |
String endDate, |
String wqTest, |
- String userData) throws IOException, InterruptedException{ |
+ String userData) throws IOException, InterruptedException, ParseException, JSONException{ |
String[][] flowData = new String[0][2]; |
String[][] wqData = new String[0][2]; |
if(database.equalsIgnoreCase("USGS")){ |
@@ -230,6 +255,20 @@ |
ArrayList<String> errorMessage = new ArrayList<String>(); |
errorMessage.add("There is no available water quality data available for the CDWR database. This feature is only available for stations in the USGS or STORET databases."); |
writeError(errorMessage); |
+ }else if(database.equalsIgnoreCase("CDSN")){ |
+ //Search for CDWR flow data |
+ CDSN_Data cdsn_data = new CDSN_Data(); |
+ Object[] returnArray = cdsn_data.getCDSNdata(organizationID, stationID, "flow", beginDate, endDate); |
+ //ArrayList<String> resultFileContents = (ArrayList<String>) returnArray[0]; |
+ flowData = (String[][]) returnArray[1]; |
+ //String start = (String) returnArray[2]; |
+ //String end = (String) returnArray[3]; |
+ |
+ returnArray = cdsn_data.getCDSNdata(organizationID, stationID, wqTest, beginDate, endDate); |
+ //ArrayList<String> resultFileContents = (ArrayList<String>) returnArray[0]; |
+ wqData = (String[][]) returnArray[1]; |
+ //String start = (String) returnArray[2]; |
+ //String end = (String) returnArray[3]; |
} |
|
Object[] returnArray = {flowData, wqData}; |
@@ -305,6 +344,20 @@ |
|
//Convert into an annual peak time series |
peakFlowData = doubleArray.convertSTORETpeakData(flowData); |
+ }else if(database.equalsIgnoreCase("CDSN")){ |
+ //Search for CDWR flow data |
+ CDSN_Data cdsn_data = new CDSN_Data(); |
+ Object[] returnArray = cdsn_data.getCDSNdata(organizationID, stationID, "flow", beginDate, endDate); |
+ //ArrayList<String> resultFileContents = (ArrayList<String>) returnArray[0]; |
+ String[][] flowData = (String[][]) returnArray[1]; |
+ //String start = (String) returnArray[2]; |
+ //String end = (String) returnArray[3]; |
+ |
+ //Removed duplicate dates |
+ flowData = doubleArray.removeDuplicateDates(flowData); |
+ |
+ //Convert into an annual peak time series |
+ peakFlowData = doubleArray.convertSTORETpeakData(flowData); |
} |
|
return peakFlowData; |
@@ -345,7 +398,7 @@ |
|
}else if(database.equalsIgnoreCase("STORET")){ |
ArrayList<String> errorMessage = new ArrayList<String>(); |
- errorMessage.add("There is no available 15-minute flow data available for the STORET database. This feature is only available for stations in the USGS NWIS database."); |
+ errorMessage.add("There is no available 15-minute flow data available for the STORET database. This feature is only available for stations in the USGS-NWIS or CDWR databases."); |
writeError(errorMessage); |
|
}else if(database.equalsIgnoreCase("CDWR")){ |
@@ -356,6 +409,10 @@ |
flowData = (String[][]) returnArray[1]; |
//String start = (String) returnArray[2]; |
//String end = (String) returnArray[3]; |
+ }else if(database.equalsIgnoreCase("CDSN")){ |
+ ArrayList<String> errorMessage = new ArrayList<String>(); |
+ errorMessage.add("There is no available 15-minute flow data available for the CDSN database. This feature is only available for stations in the USGS-NWIS or CDWR databases."); |
+ writeError(errorMessage); |
} |
|
return flowData; |
@@ -388,6 +445,10 @@ |
Object[] returnArray = cdwr_Data.getCDWRratingCurve(stationID); |
//ArrayList<String> webpageAll = (ArrayList<String>) returnArray[0]; |
ratingCurve = (double[][]) returnArray[1]; |
+ }else if(database.equalsIgnoreCase("CDSN")){ |
+ ArrayList<String> errorMessage = new ArrayList<String>(); |
+ errorMessage.add("There is no rating curve data available for CDSN stations."); |
+ writeError(errorMessage); |
} |
|
return ratingCurve; |
@@ -1,5 +1,6 @@ |
package m.cfa.download; |
|
+import m.cfa.CDSN_Data; |
import m.cfa.CDWR_Data; |
import m.cfa.STORET_Data; |
import m.cfa.USGS_Data; |
@@ -10,35 +11,35 @@ |
import java.io.IOException; |
import java.io.PrintWriter; |
import java.text.DateFormat; |
+import java.text.ParseException; |
import java.text.SimpleDateFormat; |
import java.util.ArrayList; |
import java.util.Date; |
+import org.codehaus.jettison.json.JSONException; |
|
/** |
-* Last Updated: 17-March-2016 |
+* Last Updated: 29-April-2016 |
* @author Tyler Wible |
* @since 21-June-2012 |
*/ |
public class guiDownload_Data { |
String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA"; |
- String database = "USGS";//"CDWR";//"STORET";//"UserData";// |
- String organizationID = "n/a";//"21COL001";//"n/a"; |
- String stationID = "06752260";//"CLAGRECO";//"000028";//"EF-01";//"L01";// |
- String wqTest = "flow";//"00600";//"Nitrogen, Nitrate (NO3) as NO3";//"Fecal Coliform";//"15-min flow";//"stage-discharge";// |
+ String database = "USGS";//"CDWR";//"STORET";//"CDSN";//"UserData";// |
+ String organizationID = "n/a";//"n/a";//"21COL001";//"CITYFTCO_WQX";//"n/a";// |
+ String stationID = "06752260";//"CLAGRECO";//"000028";//"1EFF";//"n/a";// |
+ String wqTest = "flow";//"00600";//"Nitrogen, Nitrate (NO3) as NO3";//"Fecal Coliform";//"15-min flow";//"stage-discharge";//"All";// |
String beginDate = ""; |
String endDate = ""; |
- |
- |
+ |
//Outputs |
String start = "-1"; |
String end = "-1"; |
- |
- |
+ |
//Gets |
public File getOutput(){ return new File(mainFolder, "CFA_dataDownload.txt"); } |
public String getStart(){ return start; } |
public String getEnd(){ return end; } |
- |
+ |
//Sets |
public void setMainFolder(String mainFolder_str){ mainFolder = mainFolder_str; } |
public void setDatabase(String database_str){ database = database_str; } |
@@ -80,7 +81,7 @@ |
|
}else{ |
ArrayList<String> errorMessage = new ArrayList<String>(); |
- errorMessage.add("There is no available data available for " + wqTest + " in the CDWR database. This feature is only available for stations in the USGS or STORET databases."); |
+ errorMessage.add("There is no available data available for " + wqTest + " in the CDWR database. This feature is only available for stations in the USGS-NWIS, STORET, or CDSN databases."); |
writeError(errorMessage); |
} |
|
@@ -106,12 +107,12 @@ |
}else if(wqTest.equalsIgnoreCase("15-min flow")){ |
//Since STORET doesn't have 15-minute data, thrown an error and alert the user of this |
ArrayList<String> errorMessage = new ArrayList<String>(); |
- errorMessage.add("There is no available 15-minute flow data available for the STORET database. This feature is only available for stations in the USGS NWIS database."); |
+ errorMessage.add("There is no available 15-minute flow data available for the STORET database. This feature is only available for stations in the USGS-NWIS or CDWR databases."); |
writeError(errorMessage); |
}else if(wqTest.equalsIgnoreCase("stage-discharge")){ |
//Since STORET doesn't have stage-discharge/rating curve data, thrown an error and alert the user of this |
ArrayList<String> errorMessage = new ArrayList<String>(); |
- errorMessage.add("There is no available stage-discharge data available for the STORET database. This feature is only available for stations in the USGS NWIS database."); |
+ errorMessage.add("There is no available stage-discharge data available for the STORET database. This feature is only available for stations in the USGS-NWIS or CDWR databases."); |
writeError(errorMessage); |
} |
|
@@ -190,6 +191,38 @@ |
return textData; |
} |
/** |
+ * Main CDSN data download subroutine |
+ * @return an ArrayList<String> containing the result file of the download request |
+ * @throws IOException |
+ * @throws InterruptedException |
+ */ |
+ private ArrayList<String> downloadCDSNdata() throws IOException, InterruptedException, ParseException, JSONException{ |
+ //Determine the type of download for CDSN: flow, water quality (individual test) |
+ if(wqTest.equalsIgnoreCase("Flood Flow")){ |
+ //Since CDSN doesn't have annual flood flow values, just return normal flow data to the user |
+ wqTest = "flow"; |
+ }else if(wqTest.equalsIgnoreCase("15-min flow")){ |
+ //Since CDSN doesn't have 15-minute data, thrown an error and alert the user of this |
+ ArrayList<String> errorMessage = new ArrayList<String>(); |
+ errorMessage.add("There is no available 15-minute flow data available for the STORET database. This feature is only available for stations in the USGS-NWIS or CDWR databases."); |
+ writeError(errorMessage); |
+ }else if(wqTest.equalsIgnoreCase("stage-discharge")){ |
+ //Since CDSN doesn't have stage-discharge/rating curve data, thrown an error and alert the user of this |
+ ArrayList<String> errorMessage = new ArrayList<String>(); |
+ errorMessage.add("There is no available stage-discharge data available for the STORET database. This feature is only available for stations in the USGS-NWIS or CDWR databases."); |
+ writeError(errorMessage); |
+ } |
+ |
+ CDSN_Data cdsn_data = new CDSN_Data(); |
+ Object[] returnArray = cdsn_data.getCDSNdata(organizationID, stationID, wqTest, beginDate, endDate); |
+ ArrayList<String> resultFileContents = (ArrayList<String>) returnArray[0]; |
+ //flowData = (String[][]) returnArray[1]; |
+ start = (String) returnArray[2]; |
+ end = (String) returnArray[3]; |
+ |
+ return resultFileContents; |
+ } |
+ /** |
* Writes out the error message, if any, for finding the file and then exits the program |
* @param error string array to be written as each line of an error message |
* @throws IOException |
@@ -247,6 +280,8 @@ |
|
}else if(database.equalsIgnoreCase("CDWR")){ |
textData = downloadCDWRdata(); |
+ }else if(database.equalsIgnoreCase("CDSN")){ |
+ textData = downloadCDSNdata(); |
} |
|
//write out data to text file |
@@ -18,6 +18,7 @@ |
import java.text.SimpleDateFormat; |
import java.util.ArrayList; |
import java.util.Date; |
+import org.codehaus.jettison.json.JSONException; |
import org.jfree.chart.ChartUtilities; |
import org.jfree.chart.JFreeChart; |
import org.jfree.chart.axis.LogarithmicAxis; |
@@ -32,17 +33,17 @@ |
import org.jfree.data.xy.XYSeriesCollection; |
|
/** |
-* Last Updated: 17-March-2016 |
+* Last Updated: 29-April-2016 |
* @author Tyler Wible |
* @since 12-June-2011 |
*/ |
public class guiDC_Model { |
//Inputs |
String mainFolder = "C:/Projects/TylerWible/CodeDirectories/NetBeans/data/CFA/DurationCurve"; |
- String database = "USGS";//"CDWR";//"STORET";//"UserData";// |
- String organizationID = "n/a";//"n/a";//"21COL001"; |
- String stationID = "06752280";//"CLAGRECO";//"000028";// |
- String stationName = "CACHE LA POUDRE RIV AB BOXELDER CRK NR TIMNATH, CO";//"Cache La Poudre Near Greeley";//"BIG THOMPSON R NEAR MOUTH";// |
+ 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";// |
+ String stationName = "South Platte River at Roscoe, Nebr.";//"Cache La Poudre Near Greeley";//"BIG THOMPSON R NEAR MOUTH";//"n/a";//"n/a";// |
String wqTest = "flow";//"00600 Total nitrogen, water, unfiltered, milligrams per liter -- mg/L";//"00625 Ammonia-nitrogen as N -- mg/L";// |
double wqTarget = 10;//in units of current test |
String beginDate = ""; |
@@ -493,8 +494,9 @@ |
* @throws IOException |
* @throws InterruptedException |
* @throws ParseException |
+ * @throws JSONException |
*/ |
- private void createLDC(File storetResourceFile) throws IOException, InterruptedException, ParseException { |
+ private void createLDC(File storetResourceFile) throws IOException, InterruptedException, ParseException, JSONException { |
//Check if any flow and water quality data exists |
Data data = new Data(); |
Object[] returnArray1 = data.extractFlow_and_WQdata(mainFolder, storetResourceFile, database, organizationID, stationID, beginDate, endDate, wqTest, userData); |
@@ -17,19 +17,20 @@ |
import java.text.SimpleDateFormat; |
import java.util.ArrayList; |
import java.util.Date; |
+import org.codehaus.jettison.json.JSONException; |
|
/** |
-* Last Updated: 17-March-2016 |
+* Last Updated: 29-April-2016 |
* @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 database = "USGS";//"CDWR";//"STORET";//"UserData";// |
- String organizationID = "n/a";//"n/a";//"21COL001"; |
- String stationID = "06741510";//"CLAGRECO";//"000028";// |
- String stationName = "BIG THOMPSON RIVER AT LOVELAND, CO.";//"Cache La Poudre Near Greeley";//"BIG THOMPSON R NEAR MOUTH";// |
+ 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";// |
+ String stationName = "South Platte River at Roscoe, Nebr.";//"Cache La Poudre Near Greeley";//"BIG THOMPSON R NEAR MOUTH";//"n/a";//"n/a";// |
String wqTest = "00600 Total nitrogen, water, unfiltered, milligrams per liter -- mg/L";//"00625 Ammonia-nitrogen as N -- mg/L";// |
int PTOPT = 1; // estimated values print option (0,1) |
int SEOPT = 2; // standard error option (1-3) |
@@ -562,7 +563,7 @@ |
* @throws InterruptedException |
* @throws ParseException |
*/ |
- public void run(Executable e, File storetResourceFile) throws IOException, InterruptedException, ParseException { |
+ public void run(Executable e, File storetResourceFile) throws IOException, InterruptedException, ParseException, JSONException { |
//If no date input, make it the maximum of available data |
if(beginDate == null || beginDate.equalsIgnoreCase("")){ |
beginDate = "1850-01-01"; |