From a04e5720e49d1c59a0a9fc7d30ec3249a601d2a1 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Tue, 13 Jun 2017 14:08:26 -0700 Subject: [PATCH] Updates with HSPEXP+ 1. If the RCHRES does not have information about the number of exits, then program exits. 2. Parameter Listing module has been updated with Occurrence Index, and caption. 3. Sensitivity Analysis script is updated to make sure that new UCI file is used everytime for running. 4. Extra spaces have been remoced from the CSV files. --- HSPEXP/HSPFOutputReports.vb | 2 +- HSPEXP/SensitivityAnalysis.vb | 10 +-- HSPEXP/modListUCIParameters.vb | 17 +++-- atcHspfSupport/atcHspfConstituentBudget.vb | 87 +++++++++++++--------- 4 files changed, 68 insertions(+), 48 deletions(-) diff --git a/HSPEXP/HSPFOutputReports.vb b/HSPEXP/HSPFOutputReports.vb index f575acd78..39d58c450 100644 --- a/HSPEXP/HSPFOutputReports.vb +++ b/HSPEXP/HSPFOutputReports.vb @@ -210,7 +210,7 @@ Module HSPFOutputReports File.Copy(pTestPath & pBaseName & ".uci", loutfoldername & pBaseName & ".uci", overwrite:=True) 'A folder name is given that has the basename and the time when the run was made. - pListModelParameters = False + pListModelParameters = True If pListModelParameters Then ListReachParametersForAllUCIFiles(pTestPath) 'modListUCIParameters.ListReachParameters(aHspfUci, loutfoldername) diff --git a/HSPEXP/SensitivityAnalysis.vb b/HSPEXP/SensitivityAnalysis.vb index 0a8eb1801..eb30caad4 100644 --- a/HSPEXP/SensitivityAnalysis.vb +++ b/HSPEXP/SensitivityAnalysis.vb @@ -97,7 +97,7 @@ Public Module ModSensitivityAnalysis Dim lParameterListFilesIsAvailable As Boolean = False Dim lSpecificationFile As String = "SensitiveParametersList.csv" Dim lOutputFile As StreamWriter = File.CreateText("SensitivityOutput.csv") - lOutputFile.WriteLine("SimID, DSNID, Sum, AnnualSum, Mean, GeometricMean, 10%High, 25%High, 50%High, 50%Low, 25%Low, 10%Low, 5%Low, 2%Low") + lOutputFile.WriteLine("SimID,DSNID,Sum,AnnualSum,Mean,GeometricMean,10%High,25%High,50%High,50%Low,25%Low,10%Low,5%Low,2%Low") Dim NumberOfOutputDSN As Integer = 0 @@ -122,11 +122,11 @@ Public Module ModSensitivityAnalysis SensitivityParameterFile.WriteLine(TextToAddForSensitivityFile) TextToAddForSensitivityFile = "***The operation number, land use, tied with next, and multiplier can be left blank" SensitivityParameterFile.WriteLine(TextToAddForSensitivityFile) - TextToAddForSensitivityFile = "Parameter,OPERATION, OPERATION NUMBER, LANDUSE, TABLE, PARM, OCCURENCE, LOWERLIMIT, UPPERLIMIT" + TextToAddForSensitivityFile = "Parameter,OPERATION,OPERATION NUMBER,LANDUSE,TABLE,PARM,OCCURENCE,LOWERLIMIT,UPPERLIMIT" SensitivityParameterFile.WriteLine(TextToAddForSensitivityFile) - TextToAddForSensitivityFile = "1,PERLND, , , PWAT-PARM2, LZSN, , 3,8" + TextToAddForSensitivityFile = "1,PERLND,,,PWAT-PARM2,LZSN,,3,8" SensitivityParameterFile.WriteLine(TextToAddForSensitivityFile) - TextToAddForSensitivityFile = "2,PERLND, , , PWAT-PARM2, INFILT, , 0.01,0.5" + TextToAddForSensitivityFile = "2,PERLND,,,PWAT-PARM2,INFILT,,0.01,0.5" SensitivityParameterFile.WriteLine(TextToAddForSensitivityFile) TextToAddForSensitivityFile = "***Following lines list the multiplication factor for each parameter for each simulation." SensitivityParameterFile.WriteLine(TextToAddForSensitivityFile) @@ -248,7 +248,7 @@ Public Module ModSensitivityAnalysis Next - loutputLine = ModelRunandReportAnswers(SimID, lUci, uciName, lExitCode, pBaseName, pTestPath, + loutputLine = ModelRunandReportAnswers(SimID, lUci, SimID & uciName, lExitCode, pBaseName, pTestPath, aSDateJ, aEDateJ, YearsofSimulation, lStats, listOfOutputDSN) 'lUci = Nothing lOutputFile.Write(loutputLine) diff --git a/HSPEXP/modListUCIParameters.vb b/HSPEXP/modListUCIParameters.vb index dea3742b9..a89b23562 100644 --- a/HSPEXP/modListUCIParameters.vb +++ b/HSPEXP/modListUCIParameters.vb @@ -27,13 +27,14 @@ Public Module modListUCIParameters Next ParameterList.WriteLine("Number Of Reaches in the UCI File = " & NumberOfReaches) - ParameterList.WriteLine("OperationType, OperationID, TableName, PrameterName, ParameterValue") + ParameterList.WriteLine("OperationType, OperationID, OperationCaption, TableName, TableOccurrence, PrameterName, ParameterValue") For Each lOperation As HspfOperation In aHSPFUCI.OpnSeqBlock.Opns If lOperation.Name = "RCHRES" Then For Each lTable As HspfTable In lOperation.Tables For Each lparm As HspfParm In lTable.Parms - ParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & lTable.Name & ", " & lparm.Name & ", " & lparm.Value) + ParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & lOperation.Caption & ", " & lTable.Name & ", " & + lTable.OccurIndex & ", " & lparm.Name & ", " & lparm.Value) Next Next End If @@ -62,14 +63,15 @@ Public Module modListUCIParameters Next ParameterList.WriteLine("Number Of PERLND Operations in the UCI File = " & NumberOfPERLNDOperations) - ParameterList.WriteLine("OperationType, OperationID, TableName, PrameterName, Table Occurrence Index, ParameterValue") + ParameterList.WriteLine("OperationType, OperationID, Operationcaption, TableName, Table Occurrence Index, ParameterName, ParameterValue") For Each lOperation As HspfOperation In aHSPFUCI.OpnSeqBlock.Opns If lOperation.Name = "PERLND" Then For Each lTable As HspfTable In lOperation.Tables For Each lparm As HspfParm In lTable.Parms 'If lTable.OccurIndex > 1 Then Stop - ParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & lTable.Name & "," & lTable.OccurIndex & ", " & lparm.Name & ", " & lparm.Value) + ParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & lOperation.Caption & ", " & + lTable.Name & "," & lTable.OccurIndex & ", " & lparm.Name & ", " & lparm.Value) Next Next End If @@ -98,13 +100,14 @@ Public Module modListUCIParameters Next ParameterList.WriteLine("Number Of IMPLND Operations in the UCI File = " & NumberOfReaches) - ParameterList.WriteLine("OperationType, OperationID, TableName, PrameterName, ParameterValue") + ParameterList.WriteLine("OperationType, OperationID, Operationcaption, TableName, Table Occurrence Index, ParameterName, ParameterValue") For Each lOperation As HspfOperation In aHSPFUCI.OpnSeqBlock.Opns If lOperation.Name = "IMPLND" Then For Each lTable As HspfTable In lOperation.Tables For Each lparm As HspfParm In lTable.Parms - ParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & lTable.Name & "," & lTable.OccurIndex & ", " & lparm.Name & ", " & lparm.Value) + ParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & lOperation.Caption & + ", " & lTable.Name & "," & lTable.OccurIndex & ", " & lparm.Name & ", " & lparm.Value) Next Next End If @@ -132,7 +135,7 @@ Public Module modListUCIParameters Logger.Msg(ex.ToString, MsgBoxStyle.Critical, "UCI Reading Issue!") End Try - 'ListReachParameters(pUci, lFolderName) + ListReachParameters(pUci, lFolderName) ListPERLNDParameters(pUci, lFolderName) ListIMPLNDParameters(pUci, lFolderName) diff --git a/atcHspfSupport/atcHspfConstituentBudget.vb b/atcHspfSupport/atcHspfConstituentBudget.vb index 15722c843..b3d329541 100644 --- a/atcHspfSupport/atcHspfConstituentBudget.vb +++ b/atcHspfSupport/atcHspfConstituentBudget.vb @@ -515,22 +515,28 @@ This message box will not be shown again for." & aBalanceType) Dim lDownstreamReachID As Integer = lID.DownOper("RCHRES") Dim lDiversion As Double = 0.0 - If lID.Tables("GEN-INFO").Parms("NEXITS").Value = 1 Then - lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) - Else - Dim lExitNumber As Integer = 0 - FindDownStreamExitNumber(aUci, lID, lExitNumber) - If lExitNumber = 0 Then + Try + If lID.Tables("GEN-INFO").Parms("NEXITS").Value = 1 Then + Logger.Dbg(lID.Id) lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) Else - Dim lExitOutFlow As atcTimeseries = aScenarioResults.DataSets.FindData("Location", "R:" & lID.Id).FindData("Constituent", "OSED-TOT-EXIT" & lExitNumber)(0) - lDiversion = -(lOutflow - lExitOutFlow.Attributes.GetValue("SumAnnual")) - lOutflow = lExitOutFlow.Attributes.GetValue("SumAnnual") - lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) - End If + Dim lExitNumber As Integer = 0 + FindDownStreamExitNumber(aUci, lID, lExitNumber) + If lExitNumber = 0 Then + lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) + Else + Dim lExitOutFlow As atcTimeseries = aScenarioResults.DataSets.FindData("Location", "R:" & lID.Id).FindData("Constituent", "OSED-TOT-EXIT" & lExitNumber)(0) + lDiversion = -(lOutflow - lExitOutFlow.Attributes.GetValue("SumAnnual")) + lOutflow = lExitOutFlow.Attributes.GetValue("SumAnnual") + lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) + End If - End If + End If + Catch ex As Exception + Logger.Msg("Trouble reading the parameters of RCHRES " & lID.Id & ". Constituent Reports will not be generated.", MsgBoxStyle.Critical, "RCHRES Parameter Issue.") + Return Nothing + End Try With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, 0.0, lPointTons, lGENERLoad, 0.0, -lDepScour, lTotalInflow, lUpstreamIn, lDiversion, aSDateJ, aEDateJ) @@ -746,22 +752,28 @@ This message box will not be shown again for." & aBalanceType) Dim lDepScour As Double = lOutflow - lTotalInflow Dim lDownstreamReachID As Integer = lID.DownOper("RCHRES") Dim lDiversion As Double = 0.0 - If lID.Tables("GEN-INFO").Parms("NEXITS").Value = 1 Then - lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) - Else - Dim lNumberOfExits As Integer = 0 - FindDownStreamExitNumber(aUci, lID, lNumberOfExits) - If lNumberOfExits = 0 Then + Try + + If lID.Tables("GEN-INFO").Parms("NEXITS").Value = 1 Then lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) Else - Dim lExitOutFlow As atcTimeseries = aScenarioResults.DataSets.FindData("Location", "R:" & lID.Id).FindData("Constituent", "N-TOT-OUT-EXIT" & lNumberOfExits)(0) - lDiversion = -(lOutflow - lExitOutFlow.Attributes.GetValue("SumAnnual")) 'Diversion is a type of loss so it is calculated as -ve - lOutflow = lExitOutFlow.Attributes.GetValue("SumAnnual") - lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) - End If + Dim lNumberOfExits As Integer = 0 + FindDownStreamExitNumber(aUci, lID, lNumberOfExits) + If lNumberOfExits = 0 Then + lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) + Else + Dim lExitOutFlow As atcTimeseries = aScenarioResults.DataSets.FindData("Location", "R:" & lID.Id).FindData("Constituent", "N-TOT-OUT-EXIT" & lNumberOfExits)(0) + lDiversion = -(lOutflow - lExitOutFlow.Attributes.GetValue("SumAnnual")) 'Diversion is a type of loss so it is calculated as -ve + lOutflow = lExitOutFlow.Attributes.GetValue("SumAnnual") + lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) + End If - End If + End If + Catch ex As Exception + Logger.Msg("Trouble reading the parameters of RCHRES " & lID.Id & ". Constituent Reports will not be generated.", MsgBoxStyle.Critical, "RCHRES Parameter Issue.") + Return Nothing + End Try With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, CVON, lPointlbs, lGENERLoad, lTotalAtmDep, lDepScour, lTotalInflow, lUpstreamIn, @@ -1113,21 +1125,26 @@ This message box will not be shown again for." & aBalanceType) 'Following few lines calculate diversion if happening in the stream. Dim lDiversion As Double = 0.0 Dim lDownstreamReachID As Integer = lID.DownOper("RCHRES") - If lID.Tables("GEN-INFO").Parms("NEXITS").Value = 1 Then - lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) - Else - Dim lExitNumber As Integer = 0 - FindDownStreamExitNumber(aUci, lID, lExitNumber) - If lExitNumber = 0 Then + Try + If lID.Tables("GEN-INFO").Parms("NEXITS").Value = 1 Then lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) Else - Dim lExitOutFlow As atcTimeseries = aScenarioResults.DataSets.FindData("Location", "R:" & lID.Id).FindData("Constituent", "P-TOT-OUT-EXIT" & lExitNumber)(0) - lDiversion = -(lOutflow - lExitOutFlow.Attributes.GetValue("SumAnnual")) - lOutflow = lExitOutFlow.Attributes.GetValue("SumAnnual") - lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) + Dim lExitNumber As Integer = 0 + FindDownStreamExitNumber(aUci, lID, lExitNumber) + If lExitNumber = 0 Then + lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) + Else + Dim lExitOutFlow As atcTimeseries = aScenarioResults.DataSets.FindData("Location", "R:" & lID.Id).FindData("Constituent", "P-TOT-OUT-EXIT" & lExitNumber)(0) + lDiversion = -(lOutflow - lExitOutFlow.Attributes.GetValue("SumAnnual")) + lOutflow = lExitOutFlow.Attributes.GetValue("SumAnnual") + lUpstreamInflows.Increment(lDownstreamReachID, lOutflow) + End If End If - End If + Catch ex As Exception + Logger.Msg("Trouble reading the parameters of RCHRES " & lID.Id & ". Constituent Reports will not be generated.", MsgBoxStyle.Critical, "RCHRES Parameter Issue.") + Return Nothing + End Try Dim lDepScour As Double = lOutflow - lTotalInflow - lDiversion With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, CVOP, lPointlbs, lGENERLoad, lTotalAtmDep,