Skip to content

Commit

Permalink
Updates with HSPEXP+
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mishranurag committed Jun 13, 2017
1 parent f24499c commit a04e572
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 48 deletions.
2 changes: 1 addition & 1 deletion HSPEXP/HSPFOutputReports.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions HSPEXP/SensitivityAnalysis.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
17 changes: 10 additions & 7 deletions HSPEXP/modListUCIParameters.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
87 changes: 52 additions & 35 deletions atcHspfSupport/atcHspfConstituentBudget.vb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a04e572

Please sign in to comment.