Skip to content

Commit

Permalink
Multiple HSPEXP+ Updates
Browse files Browse the repository at this point in the history
1. Fix the bug where the operations with no reach connections were being
output.
2. In some cases, constituents named different than the standard
constituents were not being calculated properly.
3. Some reports were not subsetting the timeseries for analysis, that
bug has been fixed.
4. Fixed the bug for Regan Graphs check box.
  • Loading branch information
mishranurag committed Apr 6, 2018
1 parent a0b71a1 commit 2773cd5
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 77 deletions.
1 change: 1 addition & 0 deletions HSPEXP/StartUp.vb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Public Class StartUp
DateTimePicker2.Enabled = lExists
chkExpertStats.Enabled = lExists
chkMultiSim.Enabled = lExists
chkReganGraphs.Enabled = lExists
'chkGraphStandard.Enabled = lExists
chkWaterBalance.Enabled = lExists
chkAdditionalgraphs.Enabled = lExists
Expand Down
139 changes: 77 additions & 62 deletions atcHspfSupport/atcConstituentTables.vb
Original file line number Diff line number Diff line change
Expand Up @@ -147,27 +147,27 @@ Public Module atcConstituentTables
column.Caption = "Total Evapotranspiration (" & lUnits & ")"
Land_Constituent_Table.Columns.Add(column)

Dim RowNumber As Integer = 0

For Each lOperation As HspfOperation In aUCI.OpnSeqBlock.Opns
If Not (lOperation.Name = "PERLND" OrElse lOperation.Name = "IMPLND") Then Continue For
Dim LocationName As String = lOperation.Name.Substring(0, 1) & ":" & lOperation.Id
landUseNameForTheCollection = lOperation.Name.Substring(0, 1) & ":" & lOperation.Description
Logger.Dbg(LocationName)
If Not listLanduses.Contains(landUseNameForTheCollection) Then
listLanduses.Add(landUseNameForTheCollection)
End If

Dim lTSNumber As Integer = 0
Dim lOutflowDataTypes1 As Dictionary(Of String, String) = ConstituentList(aBalanceType)
Dim lTS As New atcTimeseries(Nothing)
Dim AddTS As New atcDataGroup
Dim lTotalTS As New atcTimeseries(Nothing)
For Each lOutflowDataType As String In lOutflowDataTypes1.Keys
Dim lMasslinkFactor As Double = 1.0
If lOutflowDataType = "TotalOutflow" Then
lTS = lTotalTS
If lTS Is Nothing Then Continue For
Dim RowNumber As Integer = 0

For Each lOperation As HspfOperation In aUCI.OpnSeqBlock.Opns
If Not (lOperation.Name = "PERLND" OrElse lOperation.Name = "IMPLND") Then Continue For
Dim LocationName As String = lOperation.Name.Substring(0, 1) & ":" & lOperation.Id
landUseNameForTheCollection = lOperation.Name.Substring(0, 1) & ":" & lOperation.Description
Logger.Dbg(LocationName)
If Not listLanduses.Contains(landUseNameForTheCollection) Then
listLanduses.Add(landUseNameForTheCollection)
End If
Dim lOperationIsConnected As Boolean = False
Dim lTSNumber As Integer = 0
Dim lOutflowDataTypes1 As Dictionary(Of String, String) = ConstituentList(aBalanceType)
Dim lTS As New atcTimeseries(Nothing)
Dim AddTS As New atcDataGroup
Dim lTotalTS As New atcTimeseries(Nothing)
For Each lOutflowDataType As String In lOutflowDataTypes1.Keys
Dim lMasslinkFactor As Double = 1.0
If lOutflowDataType = "TotalOutflow" Then
lTS = lTotalTS
If lTS Is Nothing Then Continue For
Dim lTsMonthly As atcTimeseries = Aggregate(lTS, atcTimeUnit.TUMonth, 1, atcTran.TranSumDiv)
Dim lSeasons As New atcSeasonsMonth
Dim lSeasonalAttributes As New atcDataAttributes
Expand All @@ -186,28 +186,29 @@ Public Module atcConstituentTables
row(key) = HspfTable.NumFmtRE(lNewSimTSerMonthCalculatedAttributes.GetDefinedValue(key).Value, 10)
Next
row("SumAnnual") = lTS.Attributes.GetDefinedValue("SumAnnual").Value
Land_Constituent_Monthly_Table.Rows.Add(row)
Else
lTS = aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", lOutflowDataType)(0)
Land_Constituent_Monthly_Table.Rows.Add(row)
Else
lTS = aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", lOutflowDataType)(0)
If lTS Is Nothing Then Continue For
lTS = SubsetByDate(lTS, aSDateJ, aEDateJ, Nothing)
If ConstituentsThatNeedMassLink.Contains(lOutflowDataType) Then
For Each lConnection As HspfConnection In lOperation.Targets
If lConnection.Target.VolName = "RCHRES" Then
Dim aReach As HspfOperation = aUCI.OpnBlks("RCHRES").OperFromID(lConnection.Target.VolId)

For Each lConnection As HspfConnection In lOperation.Targets
If lConnection.Target.VolName = "RCHRES" Then
lOperationIsConnected = True
Dim aReach As HspfOperation = aUCI.OpnBlks("RCHRES").OperFromID(lConnection.Target.VolId)
If ConstituentsThatNeedMassLink.Contains(lOutflowDataType) Then
Dim lMassLinkID As Integer = lConnection.MassLink
If Not lMassLinkID = 0 Then
lMasslinkFactor = FindMassLinkFactor(aUCI, lMassLinkID, lOutflowDataType,
aBalanceType, 0, 0)
Exit For
End If

End If
Next lConnection
End If
Next lConnection
lMasslinkFactor *= 12 'Converting feet to inches
End If

If Not lOperationIsConnected AndAlso ConstituentsThatNeedMassLink.Contains(lOutflowDataType) Then Exit For
End If
lTS *= lMasslinkFactor
Dim lTSAttributes As String = lTS.Attributes.GetDefinedValue("Constituent").Value
Expand Down Expand Up @@ -256,8 +257,8 @@ Public Module atcConstituentTables

Next i
lTSNumber += 1
Next lOutflowDataType

Next lOutflowDataType

Next lOperation
#End Region

Expand Down Expand Up @@ -308,8 +309,8 @@ Public Module atcConstituentTables
landUseNameForTheCollection = lOperation.Name.Substring(0, 1) & ":" & lOperation.Description
If Not listLanduses.Contains(landUseNameForTheCollection) Then
listLanduses.Add(landUseNameForTheCollection)
End If

End If
Dim lOperationIsConnected As Boolean = False
Dim lTSNumber As Integer = 0
Dim lOutflowDataTypes1 As Dictionary(Of String, String) = ConstituentList(aBalanceType)
Dim lTS As New atcTimeseries(Nothing)
Expand Down Expand Up @@ -343,21 +344,21 @@ Public Module atcConstituentTables
lTS = aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", lOutflowDataType)(0)
If lTS Is Nothing Then Continue For
lTS = SubsetByDate(lTS, aSDateJ, aEDateJ, Nothing)
If ConstituentsThatNeedMassLink.Contains(lOutflowDataType) Then
For Each lConnection As HspfConnection In lOperation.Targets
If lConnection.Target.VolName = "RCHRES" Then
Dim aReach As HspfOperation = aUCI.OpnBlks("RCHRES").OperFromID(lConnection.Target.VolId)

For Each lConnection As HspfConnection In lOperation.Targets
If lConnection.Target.VolName = "RCHRES" Then
lOperationIsConnected = True
Dim aReach As HspfOperation = aUCI.OpnBlks("RCHRES").OperFromID(lConnection.Target.VolId)
If ConstituentsThatNeedMassLink.Contains(lOutflowDataType) Then
Dim lMassLinkID As Integer = lConnection.MassLink
If Not lMassLinkID = 0 Then
lMasslinkFactor = FindMassLinkFactor(aUCI, lMassLinkID, lOutflowDataType,
aBalanceType, 0, 0)
Exit For
End If

End If
Next lConnection
End If
End If
Next lConnection
If Not lOperationIsConnected AndAlso ConstituentsThatNeedMassLink.Contains(lOutflowDataType) Then Exit For
End If
Dim lTSAttributes As String = lTS.Attributes.GetDefinedValue("Constituent").Value
lTSAttributes = SafeSubstring(lTSAttributes, 0, 2)
Expand Down Expand Up @@ -454,7 +455,7 @@ Public Module atcConstituentTables
If Not listLanduses.Contains(landUseNameForTheCollection) Then
listLanduses.Add(landUseNameForTheCollection)
End If

Dim lOperationIsConnected As Boolean = False
Dim lTSNumber As Integer = 0
Dim lOutflowDataTypes1 As Dictionary(Of String, String) = ConstituentList(aBalanceType)
Dim lTS As New atcTimeseries(Nothing)
Expand Down Expand Up @@ -489,23 +490,21 @@ Public Module atcConstituentTables
lTS = aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", lOutflowDataType)(0)
If lTS Is Nothing Then Continue For
lTS = SubsetByDate(lTS, aSDateJ, aEDateJ, Nothing)
If ConstituentsThatNeedMassLink.Contains(lOutflowDataType) Then
For Each lConnection As HspfConnection In lOperation.Targets
If lConnection.Target.VolName = "RCHRES" Then
Dim aReach As HspfOperation = aUCI.OpnBlks("RCHRES").OperFromID(lConnection.Target.VolId)

For Each lConnection As HspfConnection In lOperation.Targets
If lConnection.Target.VolName = "RCHRES" Then
lOperationIsConnected = True
Dim aReach As HspfOperation = aUCI.OpnBlks("RCHRES").OperFromID(lConnection.Target.VolId)
If ConstituentsThatNeedMassLink.Contains(lOutflowDataType) Then
Dim lMassLinkID As Integer = lConnection.MassLink
If Not lMassLinkID = 0 Then
lMasslinkFactor = FindMassLinkFactor(aUCI, lMassLinkID, lOutflowDataType,
aBalanceType, 0, 0)
Exit For
End If

End If
Next lConnection

End If

End If
Next lConnection
If Not lOperationIsConnected AndAlso ConstituentsThatNeedMassLink.Contains(lOutflowDataType) Then Exit For
End If

'Logger.Dbg(lTS.Attributes.GetDefinedValue("Constituent").Value)
Expand Down Expand Up @@ -641,7 +640,7 @@ Public Module atcConstituentTables
(lOperation.Name = "IMPLND" AndAlso lOperation.Tables("ACTIVITY").Parms("IQALFG").Value = "1")) Then Continue For
'If lOperation.Name = "IMPLND" Then Stop
Dim LocationName As String = lOperation.Name.Substring(0, 1) & ":" & lOperation.Id

Dim lOperationIsConnected As Boolean = False
'If lOperation.Tables("ACTIVITY").Parms("PQUALFG").Value = "0" Then Continue For

lOperationNameNumber.Add(LocationName)
Expand All @@ -651,7 +650,7 @@ Public Module atcConstituentTables
If Not listLanduses.Contains(landUseNameForTheCollection) Then
listLanduses.Add(landUseNameForTheCollection)
End If

'If lOperation.Id = 319 Then Stop
For Each constituent As ConstituentProperties In aConstProperties
Dim lMultipleIndex As Integer = 0
If constituent.ConstNameForEXPPlus.ToLower.Contains("ref") Then
Expand Down Expand Up @@ -705,6 +704,7 @@ Public Module atcConstituentTables
lTS = SubsetByDate(lTS, aSDateJ, aEDateJ, Nothing)
For Each lConnection As HspfConnection In lOperation.Targets
If lConnection.Target.VolName = "RCHRES" Then
lOperationIsConnected = True
Dim aReach As HspfOperation = aUCI.OpnBlks("RCHRES").OperFromID(lConnection.Target.VolId)
Dim aConversionFactor As Double = 0.0
If aBalanceType = "TN" Or aBalanceType = "TP" Then
Expand All @@ -719,6 +719,7 @@ Public Module atcConstituentTables
'End If
End If
Next lConnection
If Not lOperationIsConnected Then Exit For
End If

'If Not lOutflowDataType.StartsWith("TotalOutflow") Then
Expand Down Expand Up @@ -891,7 +892,10 @@ Public Module atcConstituentTables
Dim Values As New List(Of Double)
If foundRows.Length > 0 Then
For Each foundrow As DataRow In foundRows
Values.Add(foundrow("TotalOutflow"))
Try
Values.Add(foundrow("TotalOutflow"))
Catch
End Try
Next foundrow

If Values.Count > 0 Then
Expand All @@ -915,7 +919,10 @@ Public Module atcConstituentTables
For Each month As String In lMonthNames
Dim Values As New List(Of Double)
For Each MonthRow As DataRow In foundRows
Values.Add(MonthRow(month))
Try
Values.Add(MonthRow(month))
Catch
End Try
Next
If Values.Count > 0 Then
landUseSumAnnualValues.Add(Right(month, 3), Values.ToArray)
Expand All @@ -942,13 +949,18 @@ Public Module atcConstituentTables
Else
lDataForBoxWhiskerPlot.Constituent = aBalanceType
For Each item As String In listLanduses
Dim OpType1 As String = item.Split("-")(0)
Dim SelectExpression As String = "OpTypeNumber Like '" & item.Split(":")(0) & "%' And Year = 'SumAnnual' And OpDesc ='" & item.Split(":")(1) & "'"
'Dim OpType1 As String = item.Split("-")(0)
'If item = "P:CPAB_CONS_NON_NLDAS_" Then Stop
Dim SelectExpression As String = "OpTypeNumber Like '" & item.Split(":")(0) & "%' And Year = 'SumAnnual' And OpDesc ='" & item.Split(":")(1) & "'"
'Logger.Dbg(SelectExpression)
Dim foundRows() As DataRow = Land_Constituent_Table.Select(SelectExpression)
Dim Values As New List(Of Double)
If foundRows.Length > 0 Then
For Each foundrow As DataRow In foundRows
Values.Add(foundrow("TotalOutflow"))
Try
Values.Add(foundrow("TotalOutflow"))
Catch
End Try
Next foundrow
If Values.Count > 0 Then
landUseSumAnnualValues.Add(item, Values.ToArray)
Expand All @@ -972,7 +984,10 @@ Public Module atcConstituentTables
For Each month As String In lMonthNames
Dim Values As New List(Of Double)
For Each MonthRow As DataRow In foundRows
Values.Add(MonthRow(month))
Try
Values.Add(MonthRow(month))
Catch
End Try
Next
landUseSumAnnualValues.Add(Right(month, 3), Values.ToArray)
Next
Expand Down
Loading

0 comments on commit 2773cd5

Please sign in to comment.