Displaying differences for changeset
 
display as  

src/java/m/cfa/timeseries/CDPHE_lowFlowStats.java

@@ -9,7 +9,7 @@
 import java.util.Date;
 
 /**
-* Last Updated: 31-May-2017
+* Last Updated: 2-June-2017
 * @author Tyler Wible
 * @since 16-December-2014
 */
@@ -104,6 +104,8 @@
         
         //Compute design flow
         double designFlow = Math.exp(U + K*S);
+        
+        //Round design flow
         designFlow = DoubleMath.round(designFlow, 2);
         
         return designFlow;
@@ -451,7 +453,10 @@
     public double CDPHE_HumanHealth(String[][] flowData) throws IOException, ParseException{
         //Calculate design flows
         double[] flowOnlyData = convertSecondColumn(flowData);
-        double designFlow = DoubleMath.round(DoubleMath.meanHarmonic(flowOnlyData), 2);
+        double designFlow = DoubleMath.meanHarmonic(flowOnlyData);
+        
+        //Round design flows
+        designFlow = DoubleMath.round(designFlow, 2);
         
         return designFlow;
     }
@@ -523,7 +528,7 @@
         
         return summaryTable;
     }
-    private double annualMedianReturnPeriod(String[][] flowData, int R){
+    public double annualMedianReturnPeriod(String[][] flowData, int R){
         //Calculate the annual median of daily average flow values with a recurrance intervale of 1 in "R" years
 
         //Calculate median for each year in time period

src/java/m/cfa/timeseries/V1_0.java

@@ -1,7 +1,9 @@
 package m.cfa.timeseries;
 
+import csip.Executable;
 import csip.ModelDataService;
 import csip.annotations.Resource;
+import csip.annotations.ResourceType;
 import static csip.annotations.ResourceType.FILE;
 import java.io.File;
 import javax.ws.rs.Path;
@@ -13,6 +15,7 @@
 @Description("timeseries")
 @VersionInfo("1.0")
 @Path("m/cfa/timeseries/1.0")
+@Resource(file="/bin/win-x86/dflow.exe", wine=true, id="dflow", type=ResourceType.EXECUTABLE)
 @Resource(file = "/python/driver.py", type = FILE, id = "driver")
 public class V1_0 extends ModelDataService {
 
@@ -60,8 +63,9 @@
         model.setMergeMethod(getStringParam("merge_method"));
         model.setUserData(getStringParam("user_data"));
 
+        Executable e = getResourceExe("dflow");
         File f = getResourceFile("driver");
-        model.run(f);
+        model.run(e,f);
         return EXEC_OK;
     }
     

src/java/m/cfa/timeseries/V1_0.json

@@ -150,7 +150,7 @@
     },
     {
       "name": "CDPHE_lowFlowType",
-      "description": "The type of CDPHE low flow to be calculated, 'all' performs all the low flow calculations (all | extreme-value | biological | human-health | reg31). Only used if calcCDPHElowflowTF is True.",
+      "description": "The type of CDPHE low flow to be calculated, 'all' performs all the low flow calculations (all | extreme-value | biological | human-health | reg31 | dflow-all | dflow-extreme-value | dflow-biological | dflow-human-health | dflow-reg31). Only used if calcCDPHElowflowTF is True.",
       "value": "all"
     },
     {

src/java/m/cfa/timeseries/guiTimeseries_Model.java

@@ -1,5 +1,6 @@
 package m.cfa.timeseries;
 
+import csip.Executable;
 import m.cfa.FlowStatistics;
 import m.cfa.Data;
 import m.cfa.DoubleArray;
@@ -1939,11 +1940,13 @@
      * Primary TimeSeries
      * It calls the subfunctions based on user selection/inputs.
      * Calls STORET or USGS database queries and their respective subfunctions
+     * @param e  DFLOW executable file
      * @param storetResourceFile  python driver.py resource file for storet data extraction
      * @throws IOException 
      * @throws InterruptedException 
+     * @throws java.text.ParseException 
      */
-    public void run(File storetResourceFile) throws IOException, InterruptedException, ParseException, Exception {
+    public void run(Executable e, File storetResourceFile) throws IOException, InterruptedException, ParseException, Exception {
         //If no date input, make it the maximum of available data
         if(beginDate == null || beginDate.equalsIgnoreCase("")){
             beginDate = "1850-01-01";
@@ -2053,10 +2056,15 @@
             //Calculate CDPHE design low flow
             if(calcCDPHElowflowTF){
                 CDPHE_lowFlowStats cdphe_lowflow = new CDPHE_lowFlowStats();
+                DFLOW_lowFlowStats dflow_lowflow = new DFLOW_lowFlowStats();
                 if(CDPHE_lowFlowType.equalsIgnoreCase("extreme-value")){
                     //Calculate the Extreme-value based design flow:
                     extremeValueDFLOW = cdphe_lowflow.CDPHE_ExtremeValue(sortedData_combined, CDPHE_m, CDPHE_R, CDPHE_waterYearBegin);
                     
+                }if(CDPHE_lowFlowType.equalsIgnoreCase("dflow-extreme-value")){
+                    //Calculate the Extreme-value based design flow:
+                    extremeValueDFLOW = dflow_lowflow.CDPHE_ExtremeValue(e, directory, sortedData_combined, CDPHE_m, CDPHE_R);
+                    
                 }else if(CDPHE_lowFlowType.equalsIgnoreCase("biological")){
                     //Calculate the Biologically based design flow:
                     double[] biologial_flows = cdphe_lowflow.CDPHE_Biological(sortedData_combined, CDPHE_m, CDPHE_R, CDPHE_clusterLength, CDPHE_clusterCountMax);
@@ -2074,14 +2082,39 @@
                     biologicalDFLOW_nov = biologial_flows[11];
                     biologicalDFLOW_dec = biologial_flows[12];
                     
+                }else if(CDPHE_lowFlowType.equalsIgnoreCase("dflow-biological")){
+                    //Calculate the Biologically based design flow:
+                    double[] biologial_flows = dflow_lowflow.CDPHE_Biological(e, directory, sortedData_combined, CDPHE_m, CDPHE_R, CDPHE_clusterLength, CDPHE_clusterCountMax);
+                    biologicalDFLOW_all = biologial_flows[0];
+                    biologicalDFLOW_jan = biologial_flows[1];
+                    biologicalDFLOW_feb = biologial_flows[2];
+                    biologicalDFLOW_mar = biologial_flows[3];
+                    biologicalDFLOW_apr = biologial_flows[4];
+                    biologicalDFLOW_may = biologial_flows[5];
+                    biologicalDFLOW_jun = biologial_flows[6];
+                    biologicalDFLOW_jul = biologial_flows[7];
+                    biologicalDFLOW_aug = biologial_flows[8];
+                    biologicalDFLOW_sep = biologial_flows[9];
+                    biologicalDFLOW_oct = biologial_flows[10];
+                    biologicalDFLOW_nov = biologial_flows[11];
+                    biologicalDFLOW_dec = biologial_flows[12];
+                    
                 }else if(CDPHE_lowFlowType.equalsIgnoreCase("human-health")){
                     //Calculate the Human-health based design flow:
                     humanHealthDFLOW = cdphe_lowflow.CDPHE_HumanHealth(sortedData_combined);
                     
+                }else if(CDPHE_lowFlowType.equalsIgnoreCase("dflow-human-health")){
+                    //Calculate the Human-health based design flow:
+                    humanHealthDFLOW = dflow_lowflow.CDPHE_HumanHealth(e, directory, sortedData_combined);
+                    
                 }else if(CDPHE_lowFlowType.equalsIgnoreCase("reg31")){
                     //Calcualte the Regulation 31 summary of design flows:
                     reg31DFLOWsummary = cdphe_lowflow.CDPHE_REG31(sortedData_combined);
                     
+                }else if(CDPHE_lowFlowType.equalsIgnoreCase("dflow-reg31")){
+                    //Calcualte the Regulation 31 summary of design flows:
+                    reg31DFLOWsummary = dflow_lowflow.CDPHE_REG31(e, directory, sortedData_combined);
+                    
                 }else if(CDPHE_lowFlowType.equalsIgnoreCase("all")){
                     //Calculate all design flows
                     extremeValueDFLOW = cdphe_lowflow.CDPHE_ExtremeValue(sortedData_combined, CDPHE_m, CDPHE_R, CDPHE_waterYearBegin);
@@ -2101,6 +2134,26 @@
                     biologicalDFLOW_dec = biologial_flows[12];
                     humanHealthDFLOW = cdphe_lowflow.CDPHE_HumanHealth(sortedData_combined);
                     reg31DFLOWsummary = cdphe_lowflow.CDPHE_REG31(sortedData_combined);
+                    
+                }else if(CDPHE_lowFlowType.equalsIgnoreCase("dflow-all")){
+                    //Calculate all design flows
+                    extremeValueDFLOW = dflow_lowflow.CDPHE_ExtremeValue(e, directory, sortedData_combined, CDPHE_m, CDPHE_R);
+                    double[] biologial_flows = dflow_lowflow.CDPHE_Biological(e, directory, sortedData_combined, CDPHE_m, CDPHE_R, CDPHE_clusterLength, CDPHE_clusterCountMax);
+                    biologicalDFLOW_all = biologial_flows[0];
+                    biologicalDFLOW_jan = biologial_flows[1];
+                    biologicalDFLOW_feb = biologial_flows[2];
+                    biologicalDFLOW_mar = biologial_flows[3];
+                    biologicalDFLOW_apr = biologial_flows[4];
+                    biologicalDFLOW_may = biologial_flows[5];
+                    biologicalDFLOW_jun = biologial_flows[6];
+                    biologicalDFLOW_jul = biologial_flows[7];
+                    biologicalDFLOW_aug = biologial_flows[8];
+                    biologicalDFLOW_sep = biologial_flows[9];
+                    biologicalDFLOW_oct = biologial_flows[10];
+                    biologicalDFLOW_nov = biologial_flows[11];
+                    biologicalDFLOW_dec = biologial_flows[12];
+                    humanHealthDFLOW = dflow_lowflow.CDPHE_HumanHealth(e, directory, sortedData_combined);
+                    reg31DFLOWsummary = dflow_lowflow.CDPHE_REG31(e, directory, sortedData_combined);
                 }
             }
         }else{
@@ -2148,6 +2201,6 @@
     public static void main(String[] args) throws IOException, InterruptedException, Exception {
         //Run model
         guiTimeseries_Model timeseries_Model = new guiTimeseries_Model();
-        timeseries_Model.run(null);
+        timeseries_Model.run(null, null);
     }
 }
\ No newline at end of file