@@ -3,7 +3,7 @@ |
import java.util.ArrayList; |
|
/** |
-* Last Updated: 12-January-2015 |
+* Last Updated: 16-January-2015 |
* @author Tyler Wible |
* @since 25-January-2014 |
*/ |
@@ -85,7 +85,7 @@ |
* @param beginDate the begin date of desired water quality data (yyyy-MM-dd) |
* @param endDate the end date of desired water quality data (yyyy-MM-dd) |
* @param userData a concatenated string of User Data (tab-delimited) to extract water quality data from (column1 = date, column2 = value) |
- * @param wqTest the water quality test desired (if USGS it is the 5-digit water quality code for their database) |
+ * @param wqTest the water quality test desired "00600 Total nitrogen, water, unfiltered, milligrams per liter -- mg/L" (format: "5-digit test-name -- units") or "flow" |
* @return a String[][] of all the specified water quality data available for the specified period (column1 = date yyyy-MM-dd format, column2 = value) |
* @throws IOException |
* @throws InterruptedException |
@@ -98,20 +98,15 @@ |
String endDate, |
String userData, |
String wqTest) throws IOException, InterruptedException{ |
- String[][] WQdata = new String[0][2]; |
- String WQlabel = "??"; |
- String graphUnits = "??"; |
- if(database.equalsIgnoreCase("USGS")){ |
- if(wqTest.length() > 5){ |
- //Pull only the code portion of the WQ test |
- int endIndex = wqTest.lastIndexOf(", "); |
- if(endIndex == -1){ |
- endIndex = wqTest.lastIndexOf("--"); |
- } |
- WQlabel = wqTest.substring(11,endIndex);//cut off the "98335 " part before the test name and the units after the name |
- WQlabel = WQlabel.split(",")[0]; |
- wqTest = wqTest.substring(0,5);//pull just the 5 digit USGS WQ code |
- } |
+ String[][] wqData = new String[0][2]; |
+ String wqCode = "??", wqLabel = "??", wqUnits = "??"; |
+ if(database.equalsIgnoreCase("USGS")){ |
+ String[] resultArray = getWQtestDataInfo(wqTest, database); |
+ wqCode = resultArray[0]; |
+ wqLabel = resultArray[1]; |
+ wqUnits = resultArray[2]; |
+ //double loadConversion = Double.parseDouble(resultArray[3]); |
+ //String endLoadUnits = resultArray[4]; |
|
//Retrieve all WQ data from USGS website |
USGS_Data usgs_Data = new USGS_Data(); |
@@ -121,41 +116,35 @@ |
//String start = (String) returnArray1[2]; |
//String end = (String) returnArray1[3]; |
|
- //Extract USGS water quality code for current wqTest only |
- WQdata = usgs_Data.minimizeUSGSWQdata(allWQdata, wqTest, beginDate, endDate); |
- |
- //Get Units and conversion for current WQ test |
- graphUnits = usgs_Data.getUSGSwqUnits(wqTest); |
+ //Extract USGS water quality code for current wqTest only (5-digit code) |
+ wqData = usgs_Data.minimizeUSGSWQdata(allWQdata, wqCode, beginDate, endDate); |
|
}else if(database.equalsIgnoreCase("UserData")){ |
- if(wqTest.length() > 5){ |
- //Pull only the code portion of the WQ test |
- int endIndex = wqTest.lastIndexOf(", "); |
- if(endIndex == -1){ |
- endIndex = wqTest.lastIndexOf("--"); |
- } |
- WQlabel = wqTest.substring(11,endIndex);//cut off the "98335 " part before the test name and the units after the name |
- WQlabel = WQlabel.split(",")[0]; |
- wqTest = wqTest.substring(0,5);//pull just the 5 digit USGS WQ code |
- } |
+ 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]; |
|
//Find the user uploaded data file and uses this for a timeseries graph |
User_Data user_Data = new User_Data(); |
- WQdata = user_Data.readUserFile(userData, wqTest, beginDate, endDate); |
- |
- //Use the header to get the WQ test name |
- USGS_Data usgs_Data = new USGS_Data(); |
- graphUnits = usgs_Data.getUSGSwqUnits(wqTest);//Because user uploaded file headers are wqTest |
+ wqData = user_Data.readUserFile(userData, wqTest, beginDate, endDate); |
|
}else if(database.equalsIgnoreCase("STORET")){ |
+ 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 STORET flow data |
STORET_Data storet_Data = new STORET_Data(); |
String zipLocation = storet_Data.downloadSTORET(mainFolder, organizationName, stationID, "flow", beginDate, endDate); |
|
//Unzip results file and extract all flow and WQ results |
- WQdata = storet_Data.Unzip_STORETDownloadFiles(zipLocation, wqTest, true); |
- WQlabel = wqTest; |
- graphUnits = "mg/L"; |
+ wqData = storet_Data.Unzip_STORETDownloadFiles(zipLocation, wqLabel, true); |
|
}else if(database.equalsIgnoreCase("CDWR")){ |
ArrayList<String> errorMessage = new ArrayList<String>(); |
@@ -163,7 +152,7 @@ |
writeError(errorMessage); |
} |
|
- Object[] returnArray = {WQdata, graphUnits, WQlabel}; |
+ Object[] returnArray = {wqData, wqUnits, wqLabel}; |
return returnArray; |
} |
/** |
@@ -176,7 +165,7 @@ |
* @param endDate the end date of desired flow and water quality data (yyyy-MM-dd) |
* @param userData a concatenated string of User Data (tab-delimited) to extract flow (column1 = date, column2 = value) |
* and water quality data (column1 = date, column2 = value) with a "$$" delimiter between the two types of data |
- * @param wqTest the water quality test desired (if USGS it is the 5-digit water quality code for their database) |
+ * @param wqTest the water quality test desired "00600 Total nitrogen, water, unfiltered, milligrams per liter -- mg/L" (format: "5-digit test-name -- units") |
* @return a String[][] of all the specified water quality data available for the specified period (column1 = date yyyy-MM-dd format, column2 = value) |
* @throws IOException |
* @throws InterruptedException |
@@ -190,8 +179,15 @@ |
String userData, |
String wqTest) throws IOException, InterruptedException{ |
String[][] flowData = new String[0][2]; |
- String[][] WQdata = new String[0][2]; |
+ String[][] wqData = new String[0][2]; |
if(database.equalsIgnoreCase("USGS")){ |
+ String[] resultArray = getWQtestDataInfo(wqTest, database); |
+ String wqCode = resultArray[0]; |
+ //String wqLabel = resultArray[1]; |
+ //String wqUnits = resultArray[2]; |
+ //double loadConversion = Double.parseDouble(resultArray[3]); |
+ //String endLoadUnits = resultArray[4]; |
+ |
//Search for USGS flow data |
USGS_Data usgs_Data = new USGS_Data(); |
Object[] returnArray = usgs_Data.getUSGSflowData(stationID, beginDate, endDate); |
@@ -207,19 +203,9 @@ |
//String start = (String) returnArray1[2]; |
//String end = (String) returnArray1[3]; |
|
- if(wqTest.length() > 5){ |
- //Pull only the code portion of the WQ test |
- int endIndex = wqTest.lastIndexOf(", "); |
- if(endIndex == -1){ |
- endIndex = wqTest.lastIndexOf("--"); |
- } |
- String WQlabel = wqTest.substring(11,endIndex);//cut off the "98335 " part before the test name and the units after the name |
- WQlabel = WQlabel.split(",")[0]; |
- wqTest = wqTest.substring(0,5);//pull just the 5 digit USGS WQ code |
- } |
+ //Extract USGS water quality code for current wqTest only |
+ wqData = usgs_Data.minimizeUSGSWQdata(allWQdata, wqCode, beginDate, endDate); |
|
- //Extract USGS water quality code for current wqTest only |
- WQdata = usgs_Data.minimizeUSGSWQdata(allWQdata, wqTest, beginDate, endDate); |
//Extract and combine USGS discharge water quality codes with the flow dataset |
flowData = usgs_Data.getUSGSwqFlowData(flowData, allWQdata, beginDate, endDate); |
|
@@ -228,16 +214,23 @@ |
User_Data user_Data = new User_Data(); |
Object[] returnArray = user_Data.readUserFileLDC(userData, wqTest, beginDate, endDate); |
flowData = (String[][]) returnArray[0]; |
- WQdata = (String[][]) returnArray[1]; |
+ wqData = (String[][]) returnArray[1]; |
|
}else if(database.equalsIgnoreCase("STORET")){ |
+ String[] resultArray = getWQtestDataInfo(wqTest, database); |
+ //String wqCode = resultArray[0]; |
+ String wqLabel = resultArray[1]; |
+ //String wqUnits = resultArray[2]; |
+ //double loadConversion = Double.parseDouble(resultArray[3]); |
+ //String endLoadUnits = resultArray[4]; |
+ |
//Search for STORET flow data |
STORET_Data storet_Data = new STORET_Data(); |
String zipLocation = storet_Data.downloadSTORET(mainFolder, organizationName, stationID, "all", beginDate, endDate); |
|
//Unzip results file and extract all flow and WQ results |
flowData = storet_Data.Unzip_STORETDownloadFiles(zipLocation, "flow", false); |
- WQdata = storet_Data.Unzip_STORETDownloadFiles(zipLocation, wqTest, true); |
+ wqData = storet_Data.Unzip_STORETDownloadFiles(zipLocation, wqLabel, true); |
|
}else if(database.equalsIgnoreCase("UserData")){ |
ArrayList<String> errorMessage = new ArrayList<String>(); |
@@ -245,7 +238,7 @@ |
writeError(errorMessage); |
} |
|
- Object[] returnArray = {flowData, WQdata}; |
+ Object[] returnArray = {flowData, wqData}; |
return returnArray; |
} |
/** |
@@ -408,6 +401,135 @@ |
return ratingCurve; |
} |
/** |
+ * @param wqTest the water quality test desired "00600 Total nitrogen, water, unfiltered, milligrams per liter -- mg/L" (format: "5-digit test-name -- units") or "flow" |
+ * @return a string with the type of units for the current test. |
+ */ |
+ public String[] getWQtestDataInfo(String wqTest, String database) throws IOException{ |
+ String wqCode = "??", wqLabel = "??", wqUnits = "??"; |
+ if(wqTest.equalsIgnoreCase("flow")){ |
+ wqCode = "flow"; |
+ wqLabel = "flow"; |
+ wqUnits = "cfs"; |
+ }else{ |
+ wqCode = wqTest.substring(0,5);//pull just the 5 digit USGS WQ code |
+ wqLabel = wqTest.substring(6,wqTest.lastIndexOf("--")-1);//cut off the "98335" the test name and the "mg/L" units after the name |
+ if(database.equalsIgnoreCase("USGS")){ |
+ //Get Units for current WQ test (5-digit code) |
+ USGS_Data usgs_Data = new USGS_Data(); |
+ wqUnits = usgs_Data.getUSGSwqUnits(wqCode); |
+ }else{ |
+ wqUnits = wqTest.substring(wqTest.lastIndexOf("--") + 3);//keep the "mg/L" units after the name |
+ } |
+ } |
+ |
+ //Determine load calculation info. (wqUnits * flow * conversion = endUnits) |
+ double conversion = getWQconversion(wqUnits); |
+ String endUnits = getWQendUnits(wqUnits); |
+ |
+ String[] resultArray = {wqCode, wqLabel, wqUnits, String.valueOf(conversion), endUnits}; |
+ return resultArray; |
+ } |
+ /** |
+ * @param units the units of the current USGS water quality test. |
+ * @return a double with the correct conversion factor for the units. |
+ */ |
+ public double getWQconversion(String units){ |
+ double conversion = 0; |
+ if(units.equalsIgnoreCase("#/l")){ |
+ conversion = (1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("#/m3")){ |
+ conversion = (java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("#/ml")){ |
+ conversion = (1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("MPN/100 ml")){ |
+ conversion = (1.0/100.0)*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("MPN/100L")){ |
+ conversion = (1.0/100.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("cfu/100ml")){ |
+ conversion = (1.0/100.0)*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("cfu/mL")){ |
+ conversion = (1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("col/mL")){ |
+ conversion = (1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("cysts/100L")){ |
+ conversion = (1.0/100.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("cysts/10L")){ |
+ conversion = (1.0/10.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("g/cm3") || units.equalsIgnoreCase("g/mL @ 20C")){ |
+ conversion = (java.lang.Math.pow(10,-6))*(1/1)*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("g/m3")){ |
+ conversion = (java.lang.Math.pow(10,-6))*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("mg/l") || units.equalsIgnoreCase("mg/l CaCO3") || units.equalsIgnoreCase("mg/l NH4") || |
+ units.equalsIgnoreCase("mg/l NO3") || units.equalsIgnoreCase("mg/l PO4") || units.equalsIgnoreCase("mg/l SiO2") || |
+ units.equalsIgnoreCase("mg/l as H") || units.equalsIgnoreCase("mg/l as N") || units.equalsIgnoreCase("mg/l as Na") || |
+ units.equalsIgnoreCase("mg/l as P") || units.equalsIgnoreCase("mg/l as S") || units.equalsIgnoreCase("mgC3H6O2/L")){ |
+ conversion = (java.lang.Math.pow(10,-6))*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("mg/mL @25C")){ |
+ conversion = (java.lang.Math.pow(10,-6))*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("ml/l")){ |
+ conversion = (1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("ng/l") || units.equalsIgnoreCase("pg/mL")){ |
+ conversion = (java.lang.Math.pow(10,-12))*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("ng/m3") || units.equalsIgnoreCase("pg/l")){ |
+ conversion = (java.lang.Math.pow(10,-12))*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("ocyst/100L")){ |
+ conversion = (1.0/100.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("oocyst/10L")){ |
+ conversion = (1.0/10.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("pfu/100L")){ |
+ conversion = (1.0/100.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("pfu/100ml")){ |
+ conversion = (1.0/100.0)*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("pg/m3")){ |
+ conversion = (java.lang.Math.pow(10,-15))*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("ug/L 2,4-D") || units.equalsIgnoreCase("ug/L U3O8") || units.equalsIgnoreCase("ug/L as As") || |
+ units.equalsIgnoreCase("ug/L as Cl") || units.equalsIgnoreCase("ug/L as N") || units.equalsIgnoreCase("ug/L as P") || |
+ units.equalsIgnoreCase("ug/l") || units.equalsIgnoreCase("ugAtrazn/L")){ |
+ conversion = (java.lang.Math.pow(10,-9))*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
+ }else if(units.equalsIgnoreCase("ug/m3")){ |
+ conversion = (java.lang.Math.pow(10,-9))*(java.lang.Math.pow(0.3048,3))*(86400); |
+ } |
+ return conversion; |
+ } |
+ /** |
+ * @param units the units of the current USGS water quality test. |
+ * @return a string with the end result units of the conversion. |
+ */ |
+ public String getWQendUnits(String units){ |
+ String endUnits = "No Units"; |
+ if(units.equalsIgnoreCase("#/l") || units.equalsIgnoreCase("#/m3") || units.equalsIgnoreCase("#/ml")){ |
+ endUnits = "#/day"; |
+ }else if(units.equalsIgnoreCase("MPN/100 ml") || units.equalsIgnoreCase("MPN/100L")){ |
+ endUnits = "MPN/day"; |
+ }else if(units.equalsIgnoreCase("cfu/100ml") || units.equalsIgnoreCase("cfu/mL")){ |
+ endUnits = "cfu/day"; |
+ }else if(units.equalsIgnoreCase("col/mL")){ |
+ endUnits = "col/day"; |
+ }else if(units.equalsIgnoreCase("cysts/100L") || units.equalsIgnoreCase("cysts/10L")){ |
+ endUnits = "cysts/day";//= cysts/100L*cfs |
+ }else if(units.equalsIgnoreCase("mg/l") || units.equalsIgnoreCase("mg/l CaCO3") || units.equalsIgnoreCase("mg/l NH4") || |
+ units.equalsIgnoreCase("mg/l NO3") || units.equalsIgnoreCase("mg/l PO4") || units.equalsIgnoreCase("mg/l SiO2") || |
+ units.equalsIgnoreCase("mg/l as H") || units.equalsIgnoreCase("mg/l as N") || units.equalsIgnoreCase("mg/l as Na") || |
+ units.equalsIgnoreCase("mg/l as P") || units.equalsIgnoreCase("mg/l as S") || units.equalsIgnoreCase("mgC3H6O2/L") || |
+ units.equalsIgnoreCase("g/cm3") || units.equalsIgnoreCase("g/mL @ 20C") || units.equalsIgnoreCase("g/m3") || |
+ units.equalsIgnoreCase("mg/mL @25C") || units.equalsIgnoreCase("ng/l") || units.equalsIgnoreCase("pg/mL") || |
+ units.equalsIgnoreCase("ng/m3") || units.equalsIgnoreCase("pg/l") || units.equalsIgnoreCase("pg/m3") || |
+ units.equalsIgnoreCase("ug/L 2,4-D") || units.equalsIgnoreCase("ug/L U3O8") || units.equalsIgnoreCase("ug/L as As") || |
+ units.equalsIgnoreCase("ug/L as Cl") || units.equalsIgnoreCase("ug/L as N") || units.equalsIgnoreCase("ug/L as P") || |
+ units.equalsIgnoreCase("ug/l") || units.equalsIgnoreCase("ugAtrazn/L") || units.equalsIgnoreCase("ug/m3")){ |
+ endUnits = "kg/day";//= mg/l*cfs |
+ }else if(units.equalsIgnoreCase("ml/l")){ |
+ endUnits = "ml/day";//= mg/l*cfs |
+ }else if(units.equalsIgnoreCase("pfu/100L") || units.equalsIgnoreCase("pfu/100ml")){ |
+ endUnits = "pfu/day"; |
+ }else if(units.equalsIgnoreCase("ocyst/100L")){ |
+ endUnits = "ocyst/day"; |
+ }else if(units.equalsIgnoreCase("oocyst/10L")){ |
+ endUnits = "oocyst/day"; |
+ } |
+ return endUnits; |
+ } |
+ /** |
* 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 |
@@ -11,7 +11,7 @@ |
import java.util.Iterator; |
|
/** |
-* Last Updated: 3-September-2014 |
+* Last Updated: 16-January-2015 |
* @author Tyler Wible |
* @since 21-June-2012 |
*/ |
@@ -590,106 +590,6 @@ |
} |
return units; |
} |
- /** |
- * @param units the units of the current USGS water quality test. |
- * @return a double with the correct conversion factor for the units. |
- */ |
- public double getUSGSwqConversion(String units){ |
- double conversion = 0; |
- if(units.equalsIgnoreCase("#/l")){ |
- conversion = (1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("#/m3")){ |
- conversion = (java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("#/ml")){ |
- conversion = (1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("MPN/100 ml")){ |
- conversion = (1.0/100.0)*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("MPN/100L")){ |
- conversion = (1.0/100.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("cfu/100ml")){ |
- conversion = (1.0/100.0)*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("cfu/mL")){ |
- conversion = (1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("col/mL")){ |
- conversion = (1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("cysts/100L")){ |
- conversion = (1.0/100.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("cysts/10L")){ |
- conversion = (1.0/10.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("g/cm3") || units.equalsIgnoreCase("g/mL @ 20C")){ |
- conversion = (java.lang.Math.pow(10,-6))*(1/1)*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("g/m3")){ |
- conversion = (java.lang.Math.pow(10,-6))*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("mg/l") || units.equalsIgnoreCase("mg/l CaCO3") || units.equalsIgnoreCase("mg/l NH4") || |
- units.equalsIgnoreCase("mg/l NO3") || units.equalsIgnoreCase("mg/l PO4") || units.equalsIgnoreCase("mg/l SiO2") || |
- units.equalsIgnoreCase("mg/l as H") || units.equalsIgnoreCase("mg/l as N") || units.equalsIgnoreCase("mg/l as Na") || |
- units.equalsIgnoreCase("mg/l as P") || units.equalsIgnoreCase("mg/l as S") || units.equalsIgnoreCase("mgC3H6O2/L")){ |
- conversion = (java.lang.Math.pow(10,-6))*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("mg/mL @25C")){ |
- conversion = (java.lang.Math.pow(10,-6))*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("ml/l")){ |
- conversion = (1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("ng/l") || units.equalsIgnoreCase("pg/mL")){ |
- conversion = (java.lang.Math.pow(10,-12))*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("ng/m3") || units.equalsIgnoreCase("pg/l")){ |
- conversion = (java.lang.Math.pow(10,-12))*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("ocyst/100L")){ |
- conversion = (1.0/100.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("oocyst/10L")){ |
- conversion = (1.0/10.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("pfu/100L")){ |
- conversion = (1.0/100.0)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("pfu/100ml")){ |
- conversion = (1.0/100.0)*(1000)*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("pg/m3")){ |
- conversion = (java.lang.Math.pow(10,-15))*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("ug/L 2,4-D") || units.equalsIgnoreCase("ug/L U3O8") || units.equalsIgnoreCase("ug/L as As") || |
- units.equalsIgnoreCase("ug/L as Cl") || units.equalsIgnoreCase("ug/L as N") || units.equalsIgnoreCase("ug/L as P") || |
- units.equalsIgnoreCase("ug/l") || units.equalsIgnoreCase("ugAtrazn/L")){ |
- conversion = (java.lang.Math.pow(10,-9))*(1000)*(java.lang.Math.pow(0.3048,3))*(86400); |
- }else if(units.equalsIgnoreCase("ug/m3")){ |
- conversion = (java.lang.Math.pow(10,-9))*(java.lang.Math.pow(0.3048,3))*(86400); |
- } |
- return conversion; |
- } |
- /** |
- * @param units the units of the current USGS water quality test. |
- * @return a string with the end result units of the conversion. |
- */ |
- public String getUSGSwqEndUnits(String units){ |
- String endUnits = "No Units"; |
- if(units.equalsIgnoreCase("#/l") || units.equalsIgnoreCase("#/m3") || units.equalsIgnoreCase("#/ml")){ |
- endUnits = "#/day"; |
- }else if(units.equalsIgnoreCase("MPN/100 ml") || units.equalsIgnoreCase("MPN/100L")){ |
- endUnits = "MPN/day"; |
- }else if(units.equalsIgnoreCase("cfu/100ml") || units.equalsIgnoreCase("cfu/mL")){ |
- endUnits = "cfu/day"; |
- }else if(units.equalsIgnoreCase("col/mL")){ |
- endUnits = "col/day"; |
- }else if(units.equalsIgnoreCase("cysts/100L") || units.equalsIgnoreCase("cysts/10L")){ |
- endUnits = "cysts/day";//= cysts/100L*cfs |
- }else if(units.equalsIgnoreCase("mg/l") || units.equalsIgnoreCase("mg/l CaCO3") || units.equalsIgnoreCase("mg/l NH4") || |
- units.equalsIgnoreCase("mg/l NO3") || units.equalsIgnoreCase("mg/l PO4") || units.equalsIgnoreCase("mg/l SiO2") || |
- units.equalsIgnoreCase("mg/l as H") || units.equalsIgnoreCase("mg/l as N") || units.equalsIgnoreCase("mg/l as Na") || |
- units.equalsIgnoreCase("mg/l as P") || units.equalsIgnoreCase("mg/l as S") || units.equalsIgnoreCase("mgC3H6O2/L") || |
- units.equalsIgnoreCase("g/cm3") || units.equalsIgnoreCase("g/mL @ 20C") || units.equalsIgnoreCase("g/m3") || |
- units.equalsIgnoreCase("mg/mL @25C") || units.equalsIgnoreCase("ng/l") || units.equalsIgnoreCase("pg/mL") || |
- units.equalsIgnoreCase("ng/m3") || units.equalsIgnoreCase("pg/l") || units.equalsIgnoreCase("pg/m3") || |
- units.equalsIgnoreCase("ug/L 2,4-D") || units.equalsIgnoreCase("ug/L U3O8") || units.equalsIgnoreCase("ug/L as As") || |
- units.equalsIgnoreCase("ug/L as Cl") || units.equalsIgnoreCase("ug/L as N") || units.equalsIgnoreCase("ug/L as P") || |
- units.equalsIgnoreCase("ug/l") || units.equalsIgnoreCase("ugAtrazn/L") || units.equalsIgnoreCase("ug/m3")){ |
- endUnits = "kg/day";//= mg/l*cfs |
- }else if(units.equalsIgnoreCase("ml/l")){ |
- endUnits = "ml/day";//= mg/l*cfs |
- }else if(units.equalsIgnoreCase("pfu/100L") || units.equalsIgnoreCase("pfu/100ml")){ |
- endUnits = "pfu/day"; |
- }else if(units.equalsIgnoreCase("ocyst/100L")){ |
- endUnits = "ocyst/day"; |
- }else if(units.equalsIgnoreCase("oocyst/10L")){ |
- endUnits = "oocyst/day"; |
- } |
- return endUnits; |
- } |
/** |
* Extract the USGS water quality tests of 00061 (discharge in cfs) and 30209 (discharge in cms) and combine them |
* with the provided flow data set within the provided date range |
@@ -26,7 +26,7 @@ |
import org.jfree.data.xy.XYSeriesCollection; |
|
/** |
-* Last Updated: 16-December-2014 |
+* Last Updated: 16-January-2015 |
* @author Tyler Wible |
* @since 12-June-2011 |
*/ |
@@ -37,8 +37,7 @@ |
String organizationName = "USGS";//"Co. Division of Water Resources";//"Colorado Dept. of Public Health & Environment";// |
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 modelType = "FDC";//"LDC";// |
- String wqTest = "flow";//"00600 Total nitrogen, water, unfiltered, milligrams per liter -- mg/l";//"Nitrogen, Nitrate (NO3) as NO3";// |
+ 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 = ""; |
String endDate = ""; |
@@ -142,9 +141,6 @@ |
public void setMainFolder(String mainFolder) { |
this.mainFolder = mainFolder; |
} |
- public void setModelType(String modelType) { |
- this.modelType = modelType; |
- } |
public void setDatabase(String database) { |
this.database = database; |
} |
@@ -641,18 +637,27 @@ |
writeError(errorMessage); |
} |
|
- //Determine additional information for the model conversions and labels |
- int endIndex = wqTest.lastIndexOf(", ");//"00597 Dissolved nitrogen gas, water, unfiltered, milligrams per liter -- mg/l" |
- if(endIndex == -1){ |
- endIndex = wqTest.lastIndexOf("--"); |
- } |
- String WQlabel = wqTest.substring(11,endIndex);//cut off the "98335 " part before the test name and the units after the name |
+// //Determine additional information for the model conversions and labels |
+// int endIndex = wqTest.lastIndexOf(", ");//"00597 Dissolved nitrogen gas, water, unfiltered, milligrams per liter -- mg/l" |
+// if(endIndex == -1){ |
+// endIndex = wqTest.lastIndexOf("--"); |
+// } |
+// String WQlabel = wqTest.substring(11,endIndex);//cut off the "98335 " part before the test name and the units after the name |
|
//Get Units and conversion for current WQ test |
- USGS_Data usgs_Data = new USGS_Data(); |
- String units = usgs_Data.getUSGSwqUnits(wqTest.substring(0,5));//pull just the 5 digit USGS WQ code |
- double conversion = usgs_Data.getUSGSwqConversion(units); |
- String endUnits = usgs_Data.getUSGSwqEndUnits(units); |
+ String[] resultArray = data.getWQtestDataInfo(wqTest, database); |
+ //String wqCode = resultArray[0]; |
+ String wqLabel = resultArray[1]; |
+ //String units = resultArray[2]; |
+ double conversion = Double.parseDouble(resultArray[3]); |
+ String endUnits = resultArray[4]; |
+ |
+// //old |
+// USGS_Data usgs_Data = new USGS_Data(); |
+// String units = usgs_Data.getUSGSwqUnits(wqTest.substring(0,5));//pull just the 5 digit USGS WQ code |
+// double conversion = usgs_Data.getUSGSwqConversion(units); |
+// String endUnits = usgs_Data.getUSGSwqEndUnits(units); |
+// //remove here to 'old' above |
|
//Get period data for analyses |
String[][] period1Data = doubleArray.getPeriodData(sortedData_combined, period1Begin, period1End); |
@@ -707,7 +712,7 @@ |
String[][] seasonalWQ_user = doubleArray.getSeasonalData(WQdata_user, seasonBegin, seasonEnd); |
|
//Graph resulting LDC data |
- Object[] returnArray = graphLDC(WQlabel, endUnits, conversion, sortedData_combined, sortedData_user, period1Data, period2Data, period3Data, WQdata_combined, WQdata_user, seasonalWQ_combined, seasonalWQ_user, mQn, m, n); |
+ Object[] returnArray = graphLDC(wqLabel, endUnits, conversion, sortedData_combined, sortedData_user, period1Data, period2Data, period3Data, WQdata_combined, WQdata_user, seasonalWQ_combined, seasonalWQ_user, mQn, m, n); |
String paragraphTitle = (String) returnArray[0]; |
double totalCount = (Double) returnArray[1]; |
|
@@ -1483,9 +1488,9 @@ |
} |
|
//Determine which Duration Curve method to run, FDC or LDC |
- if(modelType.equalsIgnoreCase("FDC")){ |
+ if(wqTest.equalsIgnoreCase("flow")){ |
createFDC(); |
- }else if(modelType.equalsIgnoreCase("LDC")){ |
+ }else{ |
createLDC(); |
} |
} |
@@ -40,7 +40,7 @@ |
import org.jfree.data.xy.XYSeriesCollection; |
|
/** |
-* Last Updated: 12-January-2015 |
+* Last Updated: 20-January-2015 |
* @author Tyler Wible |
* @since 24-June-2011 |
*/ |
@@ -51,7 +51,7 @@ |
String organizationName = "USGS";//"Co. Division of Water Resources";//"Colorado Dept. of Public Health & Environment";// |
String stationID = "06764880";//"CLAGRECO";//"000028";// |
String stationName = "South Platte River at Roscoe, Nebr.";//"Cache La Poudre Near Greeley";//"BIG THOMPSON R NEAR MOUTH";// |
- String wqTest = "flow";//"00600 Total nitrogen, water, unfiltered, milligrams per liter, mg/L"; |
+ String wqTest = "flow";//"00600 Total nitrogen, water, unfiltered, milligrams per liter -- mg/L";//"00625 Ammonia-nitrogen as N -- mg/L";// |
String beginDate = ""; |
String endDate = ""; |
String timeStep = "Daily";//"Yearly";//"Monthly";// |
@@ -1016,6 +1016,7 @@ |
//Create TimeSeries graph |
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); |
String[][] histogramData = new String[numBins][5]; |
+ boolean legendTF = false; |
for(int j=0; j<numBins; j++){ |
//Count data within the bin range |
int count = 0; |
@@ -1052,6 +1053,7 @@ |
} |
dataset.addValue(count, "Period 1 Data", categoryTitle); |
histogramData[j][2] = String.valueOf(count); |
+ legendTF = true; |
}else{ |
histogramData[j][2] = "-1"; |
} |
@@ -1066,6 +1068,7 @@ |
} |
dataset.addValue(count, "Period 2 Data", categoryTitle); |
histogramData[j][3] = String.valueOf(count); |
+ legendTF = true; |
}else{ |
histogramData[j][3] = "-1"; |
} |
@@ -1080,6 +1083,7 @@ |
} |
dataset.addValue(count, "Period 3 Data", categoryTitle); |
histogramData[j][4] = String.valueOf(count); |
+ legendTF = true; |
}else{ |
histogramData[j][4] = "-1"; |
} |
@@ -1124,7 +1128,13 @@ |
|
//Create the chart with the plot |
String graphTitle = "Histogram for " + database + " Station: " + stationID + "; " + stationName; |
- JFreeChart chart = new JFreeChart(graphTitle, graphing.titleFont, plot, true); |
+ JFreeChart chart = new JFreeChart(graphTitle, graphing.titleFont, plot, legendTF); |
+ |
+ //Set legend Font |
+ if(legendTF){ |
+ LegendTitle legendTitle = chart.getLegend(); |
+ legendTitle.setItemFont(graphing.masterFont); |
+ } |
|
//Save resulting graph for use later |
try{ |
@@ -1467,6 +1477,7 @@ |
//Set the line data, renderer, and axis into plot |
plot.setDataset(seriesIndex, xyDataset); |
plot.setRenderer(seriesIndex, renderer); |
+ boolean legendTF = false; |
seriesIndex++; |
|
//Add period data (if any) |
@@ -1475,6 +1486,7 @@ |
renderer_period1.setSeriesPaint(0, Color.red); |
plot.setDataset(seriesIndex, xyDataset_period1); |
plot.setRenderer(seriesIndex, renderer_period1); |
+ legendTF = true; |
seriesIndex++; |
} |
if(period2Data.length > 0){ |
@@ -1482,6 +1494,7 @@ |
renderer_period2.setSeriesPaint(0, new Color(255, 135, 0));//gold |
plot.setDataset(seriesIndex, xyDataset_period2); |
plot.setRenderer(seriesIndex, renderer_period2); |
+ legendTF = true; |
seriesIndex++; |
} |
if(period3Data.length > 0){ |
@@ -1489,6 +1502,7 @@ |
renderer_period3.setSeriesPaint(0, Color.green); |
plot.setDataset(seriesIndex, xyDataset_period3); |
plot.setRenderer(seriesIndex, renderer_period3); |
+ legendTF = true; |
seriesIndex++; |
} |
|
@@ -1560,11 +1574,13 @@ |
|
//Create the charts out of the plots |
String graphTitle = "Monthly Averages for " + database + " Station: " + stationID + "; " + stationName; |
- JFreeChart chart = new JFreeChart(graphTitle, graphing.titleFont, plot, true); |
+ JFreeChart chart = new JFreeChart(graphTitle, graphing.titleFont, plot, legendTF); |
|
//Set legend Font |
- LegendTitle legendTitle = chart.getLegend(); |
- legendTitle.setItemFont(graphing.masterFont); |
+ if(legendTF){ |
+ LegendTitle legendTitle = chart.getLegend(); |
+ legendTitle.setItemFont(graphing.masterFont); |
+ } |
|
//Save monthly timeseries graph for use later |
try{ |
@@ -1684,30 +1700,35 @@ |
//Set the line data, renderer, and axis into plot |
plot.setDataset(0, xyDataset); |
plot.setRenderer(0, renderer); |
+ boolean legendTF = false; |
|
if(sortedData_user.length > 0){ |
XYItemRenderer renderer_user = new XYLineAndShapeRenderer(true, false); |
renderer_user.setSeriesPaint(0, color2); |
plot.setDataset(1, xyDataset_user); |
plot.setRenderer(1, renderer_user); |
+ legendTF = true; |
} |
if(period1Data.length > 0){ |
XYItemRenderer renderer_period1 = new XYLineAndShapeRenderer(true, false); |
renderer_period1.setSeriesPaint(0, Color.red); |
plot.setDataset(2, xyDataset_period1); |
plot.setRenderer(2, renderer_period1); |
+ legendTF = true; |
} |
if(period2Data.length > 0){ |
XYItemRenderer renderer_period2 = new XYLineAndShapeRenderer(true, false); |
renderer_period2.setSeriesPaint(0, new Color(255, 135, 0));//gold |
plot.setDataset(3, xyDataset_period2); |
plot.setRenderer(3, renderer_period2); |
+ legendTF = true; |
} |
if(period3Data.length > 0){ |
XYItemRenderer renderer_period3 = new XYLineAndShapeRenderer(true, false); |
renderer_period3.setSeriesPaint(0, Color.green); |
plot.setDataset(4, xyDataset_period3); |
plot.setRenderer(4, renderer_period3); |
+ legendTF = true; |
} |
|
//Map the line to the first Domain and first Range |
@@ -1730,11 +1751,13 @@ |
|
//Create the charts out of the plots |
String graphTitle = "CDF for " + database + " Station: " + stationID + "; " + stationName; |
- JFreeChart chart = new JFreeChart(graphTitle, graphing.titleFont, plot, true); |
+ JFreeChart chart = new JFreeChart(graphTitle, graphing.titleFont, plot, legendTF); |
|
//Set legend Font |
- LegendTitle legendTitle = chart.getLegend(); |
- legendTitle.setItemFont(graphing.masterFont); |
+ if(legendTF){ |
+ LegendTitle legendTitle = chart.getLegend(); |
+ legendTitle.setItemFont(graphing.masterFont); |
+ } |
|
//Save monthly timeseries graph for use later |
try{ |