Skip to content

Commit a482e76

Browse files
committed
DFLOW time series reference fix; IDF outlier tab retrieves CP-adj N day value
- both legacy and IDF DFLOW updated
1 parent 6fe1245 commit a482e76

File tree

3 files changed

+47
-31
lines changed

3 files changed

+47
-31
lines changed

DFLOW/DFLOWCalcs.vb

+19-14
Original file line numberDiff line numberDiff line change
@@ -662,11 +662,10 @@ Public Class DFLOWCalcs
662662
Dim lHydrologicTS As atcTimeseries = aDataGroup(lDSIndex)
663663
Dim lHydrologicTS2 As atcTimeseries = SubsetByDateBoundary(lHydrologicTS, lStartMonth, lStartDay, Nothing, lFirstyearDFLOW, lLastYearDFLOW, lEndMonthDFLOW, lEndDayDFLOW)
664664
Dim lFirstDate As Double = lHydrologicTS2.Attributes.GetValue("start date")
665-
Dim lHydrologicDS As atcDataSet = lHydrologicTS2
666-
Dim lSYear As Integer = (lDateFormat.JDateToString(lHydrologicDS.Attributes.GetValue("start date"))).Substring(0, 4)
667-
Dim lEYear As Integer = (lDateFormat.JDateToString(lHydrologicDS.Attributes.GetValue("end date"))).Substring(0, 4)
665+
'Dim lHydrologicDS As atcDataSet = lHydrologicTS2
666+
Dim lSYear As Integer = (lDateFormat.JDateToString(lHydrologicTS2.Attributes.GetValue("start date"))).Substring(0, 4)
667+
Dim lEYear As Integer = (lDateFormat.JDateToString(lHydrologicTS2.Attributes.GetValue("end date"))).Substring(0, 4)
668668
Dim lYears As Integer = lEYear - lSYear
669-
Dim lTS As Double() = lHydrologicTS2.Values
670669
lHydrologicTS.Attributes.SetValue("xBy start date", lFirstDate)
671670

672671
' ===== Calculate hydrologic design flow lxQy
@@ -677,7 +676,7 @@ Public Class DFLOWCalcs
677676
If aShowProgress Then lfrmProgress.Label1.Text = (1 + lItemIdx) & " of " & lTotalItems & " - " & fAveragingPeriod & "Q" & fReturnPeriod
678677
Application.DoEvents()
679678
If lYears >= lReturnPeriod Then
680-
lxQy = xQy(lAveragingPeriod, lReturnPeriod, lHydrologicDS, aInputs)
679+
lxQy = xQy(lAveragingPeriod, lReturnPeriod, lHydrologicTS2, aInputs)
681680
Else
682681
lxQy = lNaN
683682
End If
@@ -693,10 +692,11 @@ Public Class DFLOWCalcs
693692
End Select
694693

695694
' ===== Create 4-day running average for start of xBy excursion analysis -
696-
Dim lTimeSeries As atcTimeseries = aDataGroup(lDSIndex)
697-
Dim lTimeSeries2 As atcTimeseries = SubsetByDateBoundary(lTimeSeries, lStartMonth, lStartDay, Nothing, lFirstyearDFLOW, lLastYearDFLOW, lEndMonthDFLOW, lEndDayDFLOW)
695+
'Dim lTimeSeries As atcTimeseries = aDataGroup(lDSIndex)
696+
'Dim lTimeSeries2 As atcTimeseries = SubsetByDateBoundary(lTimeSeries, lStartMonth, lStartDay, Nothing, lFirstyearDFLOW, lLastYearDFLOW, lEndMonthDFLOW, lEndDayDFLOW)
697+
'lTS = lTimeSeries2.Values
698698

699-
lTS = lTimeSeries2.Values
699+
Dim lTS As Double() = lHydrologicTS2.Values
700700
lTS(0) = lNaN
701701

702702
Dim lTSN As Double()
@@ -761,7 +761,8 @@ Public Class DFLOWCalcs
761761
Next
762762

763763
' ----- 2. Get initial guess
764-
Dim lxBy As Double = xQy(lBioPeriod, lBioYears, aDataGroup(lDSIndex), aInputs)
764+
'Dim lxBy As Double = xQy(lBioPeriod, lBioYears, aDataGroup(lDSIndex), aInputs)
765+
Dim lxBy As Double = xQy(lBioPeriod, lBioYears, lHydrologicTS2, aInputs)
765766

766767
' ----- 3. Do xBy calculation
767768
Dim lExcursionCount As Integer
@@ -784,7 +785,8 @@ Public Class DFLOWCalcs
784785
End If
785786
Application.DoEvents()
786787

787-
lEquivalentxQy = xQy(lAveragingPeriod, lYears, aDataGroup(lDSIndex), aInputs)
788+
'lEquivalentxQy = xQy(lAveragingPeriod, lYears, aDataGroup(lDSIndex), aInputs)
789+
lEquivalentxQy = xQy(lAveragingPeriod, lYears, lHydrologicTS2, aInputs)
788790
If lEquivalentxQy > lxBy Then
789791
lReturnPeriodTry = lYears
790792
Else
@@ -796,7 +798,8 @@ Public Class DFLOWCalcs
796798
lEquivalentxQy = lxBy
797799
While lEquivalentxQy >= lxBy And lReturnPeriodTry < lYears
798800
lReturnPeriodTry += 1
799-
lEquivalentxQy = xQy(lAveragingPeriod, lReturnPeriodTry, aDataGroup(lDSIndex), aInputs)
801+
'lEquivalentxQy = xQy(lAveragingPeriod, lReturnPeriodTry, aDataGroup(lDSIndex), aInputs)
802+
lEquivalentxQy = xQy(lAveragingPeriod, lReturnPeriodTry, lHydrologicTS2, aInputs)
800803
If aShowProgress Then
801804
lfrmProgress.Label1.Text = (1 + lItemIdx) & " of " & lTotalItems & " - xQy (" & lReturnPeriodTry & " of up to " & lYears & ")"
802805
End If
@@ -848,12 +851,12 @@ Public Class DFLOWCalcs
848851
Next
849852

850853
' ===== Store results
851-
ladsResults.CellValue(lItemIdx + 1, 0) = lHydrologicDS.Attributes.GetFormattedValue("Location") & " - " & lHydrologicDS.Attributes.GetFormattedValue("STANAM")
854+
ladsResults.CellValue(lItemIdx + 1, 0) = lHydrologicTS2.Attributes.GetFormattedValue("Location") & " - " & lHydrologicTS2.Attributes.GetFormattedValue("STANAM")
852855

853856
' ----- Next three values are corrected by one day to account for current (3/2008) behavior of time series trimming
854857

855-
ladsResults.CellValue(lItemIdx + 1, 1) = lDateFormat.JDateToString(1 + lHydrologicDS.Attributes.GetValue("start date")) & " - " & _
856-
lDateFormat.JDateToString(lHydrologicDS.Attributes.GetValue("end date"))
858+
ladsResults.CellValue(lItemIdx + 1, 1) = lDateFormat.JDateToString(1 + lHydrologicTS2.Attributes.GetValue("start date")) & " - " &
859+
lDateFormat.JDateToString(lHydrologicTS2.Attributes.GetValue("end date"))
857860
ladsResults.CellValue(lItemIdx + 1, 2) = Format(UBound(lTS) - 1, "#,##0") & " "
858861
ladsResults.Alignment(lItemIdx + 1, 2) = atcControls.atcAlignment.HAlignRight
859862
ladsResults.CellValue(lItemIdx + 1, 3) = Format(lNZero, "#,##0") & "/" & Format(lNMiss - 1, "#,##0") & " "
@@ -901,6 +904,8 @@ Public Class DFLOWCalcs
901904
ladsResults.CellValue(lItemIdx + 1, 14) = Format(lNExcHF / (UBound(lTS) - lNMiss), "percent")
902905
ladsResults.Alignment(lItemIdx + 1, 14) = atcControls.atcAlignment.HAlignDecimal
903906
lItemIdx = lItemIdx + 1
907+
908+
lHydrologicTS2.numValues = 0
904909
Next
905910

906911
If aShowProgress Then

atcIntegratedDesignFlow/DFLOWCalcs.vb

+21-16
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,9 @@ Public Class DFLOWCalcs
726726
Dim lHydrologicTS As atcTimeseries = aDataGroup(lDSIndex)
727727
Dim lHydrologicTS2 As atcTimeseries = SubsetByDateBoundary(lHydrologicTS, lStartMonth, lStartDay, Nothing, lFirstyearDFLOW, lLastYearDFLOW, lEndMonthDFLOW, lEndDayDFLOW)
728728
Dim lFirstDate As Double = lHydrologicTS2.Attributes.GetValue("start date")
729-
Dim lHydrologicDS As atcTimeseries = lHydrologicTS2
730-
Dim lSYear As Integer = (lDateFormat.JDateToString(lHydrologicDS.Attributes.GetValue("start date"))).Substring(0, 4)
731-
Dim lEYear As Integer = (lDateFormat.JDateToString(lHydrologicDS.Attributes.GetValue("end date"))).Substring(0, 4)
729+
'Dim lHydrologicDS As atcTimeseries = lHydrologicTS2
730+
Dim lSYear As Integer = (lDateFormat.JDateToString(lHydrologicTS2.Attributes.GetValue("start date"))).Substring(0, 4)
731+
Dim lEYear As Integer = (lDateFormat.JDateToString(lHydrologicTS2.Attributes.GetValue("end date"))).Substring(0, 4)
732732
Dim lYears As Integer = lEYear - lSYear
733733
lHydrologicTS.Attributes.SetValue("xBy start date", lFirstDate)
734734
lHydrologicTS.Attributes.SetValue("xBy start year", lSYear)
@@ -746,7 +746,7 @@ Public Class DFLOWCalcs
746746
If aShowProgress Then lfrmProgress.Label1.Text = (1 + lItemIdx) & " of " & lTotalItems & " - " & fAveragingPeriod & "Q" & fReturnPeriod
747747
Application.DoEvents()
748748
If lYears >= lReturnPeriod Then
749-
lxQy = xQy(lAveragingPeriod, lReturnPeriod, lHydrologicDS, aInputs)
749+
lxQy = xQy(lAveragingPeriod, lReturnPeriod, lHydrologicTS2, aInputs)
750750
Else
751751
lxQy = lNaN
752752
End If
@@ -765,9 +765,10 @@ Public Class DFLOWCalcs
765765
lHydrologicTS.Attributes.SetValue(lxQyKey, lxQy)
766766

767767
' ===== Create 4-day running average for start of xBy excursion analysis -
768-
Dim lTimeSeries As atcTimeseries = SubsetByDateBoundary(aDataGroup(lDSIndex), lStartMonth, lStartDay, Nothing, lFirstyearDFLOW, lLastYearDFLOW, lEndMonthDFLOW, lEndDayDFLOW)
768+
'Dim lTimeSeries As atcTimeseries = SubsetByDateBoundary(aDataGroup(lDSIndex), lStartMonth, lStartDay, Nothing, lFirstyearDFLOW, lLastYearDFLOW, lEndMonthDFLOW, lEndDayDFLOW)
769+
'Dim lHydrologicTS2 As atcTimeseries = SubsetByDateBoundary(lHydrologicTS, lStartMonth, lStartDay, Nothing, lFirstyearDFLOW, lLastYearDFLOW, lEndMonthDFLOW, lEndDayDFLOW)
769770

770-
Dim lTS As Double() = lTimeSeries.Values
771+
Dim lTS As Double() = lHydrologicTS2.Values
771772
lTS(0) = lNaN
772773

773774
Dim lTSN As Double()
@@ -832,7 +833,8 @@ Public Class DFLOWCalcs
832833
Next
833834

834835
' ----- 2. Get initial guess
835-
Dim lxBy As Double = xQy(lBioPeriod, lBioYears, aDataGroup(lDSIndex), aInputs)
836+
'Dim lxBy As Double = xQy(lBioPeriod, lBioYears, aDataGroup(lDSIndex), aInputs)
837+
Dim lxBy As Double = xQy(lBioPeriod, lBioYears, lHydrologicTS2, aInputs)
836838

837839
' ----- 3. Do xBy calculation
838840
Dim lExcursionCount As Integer
@@ -857,7 +859,8 @@ Public Class DFLOWCalcs
857859
End If
858860
Application.DoEvents()
859861

860-
lEquivalentxQy = xQy(lAveragingPeriod, lYears, aDataGroup(lDSIndex), aInputs)
862+
'lEquivalentxQy = xQy(lAveragingPeriod, lYears, aDataGroup(lDSIndex), aInputs)
863+
lEquivalentxQy = xQy(lAveragingPeriod, lYears, lHydrologicTS2, aInputs)
861864
If lEquivalentxQy > lxBy Then
862865
lReturnPeriodTry = lYears
863866
Else
@@ -869,7 +872,8 @@ Public Class DFLOWCalcs
869872
lEquivalentxQy = lxBy
870873
While lEquivalentxQy >= lxBy And lReturnPeriodTry < lYears
871874
lReturnPeriodTry += 1
872-
lEquivalentxQy = xQy(lAveragingPeriod, lReturnPeriodTry, aDataGroup(lDSIndex), aInputs)
875+
'lEquivalentxQy = xQy(lAveragingPeriod, lReturnPeriodTry, aDataGroup(lDSIndex), aInputs)
876+
lEquivalentxQy = xQy(lAveragingPeriod, lReturnPeriodTry, lHydrologicTS2, aInputs)
873877
If aShowProgress Then
874878
lfrmProgress.Label1.Text = (1 + lItemIdx) & " of " & lTotalItems & " - xQy (" & lReturnPeriodTry & " of up to " & lYears & ")"
875879
End If
@@ -931,12 +935,12 @@ Public Class DFLOWCalcs
931935
Next
932936

933937
' ===== Store results
934-
ladsResults.CellValue(lItemIdx + 1, 0) = lHydrologicDS.Attributes.GetFormattedValue("Location") & " - " & lHydrologicDS.Attributes.GetFormattedValue("STANAM")
938+
ladsResults.CellValue(lItemIdx + 1, 0) = lHydrologicTS2.Attributes.GetFormattedValue("Location") & " - " & lHydrologicTS2.Attributes.GetFormattedValue("STANAM")
935939

936940
' ----- Next three values are corrected by one day to account for current (3/2008) behavior of time series trimming
937941

938-
ladsResults.CellValue(lItemIdx + 1, 1) = lDateFormat.JDateToString(1 + lHydrologicDS.Attributes.GetValue("start date")) & " - " &
939-
lDateFormat.JDateToString(lHydrologicDS.Attributes.GetValue("end date"))
942+
ladsResults.CellValue(lItemIdx + 1, 1) = lDateFormat.JDateToString(1 + lHydrologicTS2.Attributes.GetValue("start date")) & " - " &
943+
lDateFormat.JDateToString(lHydrologicTS2.Attributes.GetValue("end date"))
940944
ladsResults.CellValue(lItemIdx + 1, 2) = Format(UBound(lTS) - 1, "#,##0") & " "
941945
ladsResults.Alignment(lItemIdx + 1, 2) = atcControls.atcAlignment.HAlignRight
942946
ladsResults.CellValue(lItemIdx + 1, 3) = Format(lNZero, "#,##0") & "/" & Format(lNMiss - 1, "#,##0") & " "
@@ -1011,17 +1015,18 @@ Public Class DFLOWCalcs
10111015
lPct = lNExcHF / (UBound(lTS) - lNMiss)
10121016
ladsResults.CellValue(lItemIdx + 1, 15) = Format(lPct, "percent")
10131017
ladsResults.Alignment(lItemIdx + 1, 15) = atcControls.atcAlignment.HAlignDecimal
1014-
lHydrologicTS.Attributes.SetValue(lHMeanKey, lTimeSeries.Attributes.GetValue("Harmonic Mean") & vbTab & Format(lPct, "percent") & vbTab & "N/A")
1018+
lHydrologicTS.Attributes.SetValue(lHMeanKey, lHydrologicTS2.Attributes.GetValue("Harmonic Mean") & vbTab & Format(lPct, "percent") & vbTab & "N/A")
10151019
Dim lHMeanAdjKey As String = "NONBIOFLOW-Harmonic Mean Adj"
10161020
Dim lPctAdj As Double = lNExcHFAdj / (UBound(lTS) - lNMiss)
1017-
lHydrologicTS.Attributes.SetValue(lHMeanAdjKey, lTimeSeries.Attributes.GetValue("Harmonic Mean Adj") & vbTab & Format(lPctAdj, "percent") & vbTab & "N/A")
1021+
lHydrologicTS.Attributes.SetValue(lHMeanAdjKey, lHydrologicTS2.Attributes.GetValue("Harmonic Mean Adj") & vbTab & Format(lPctAdj, "percent") & vbTab & "N/A")
10181022

10191023
If lAddSeason Then
10201024
ladsResults.CellValue(lItemIdx + 1, 16) = lHydrologicTS.Attributes.GetValue("seasonname")
10211025
End If
10221026
lItemIdx = lItemIdx + 1
1023-
lHydrologicTS2.Clear() : lHydrologicTS2 = Nothing
1024-
lTimeSeries.Clear() : lTimeSeries = Nothing
1027+
'lHydrologicTS2.Clear()
1028+
'lHydrologicTS2 = Nothing
1029+
lHydrologicTS2.numValues = 0
10251030
Erase lTSN
10261031
GC.Collect()
10271032
Next 'lDSIndex}

atcIntegratedDesignFlow/frmSWSTATmod.vb

+7-1
Original file line numberDiff line numberDiff line change
@@ -4703,7 +4703,13 @@ Public Class frmSWSTATmod
47034703
End If
47044704
.Item(4, I).Value = lFrom
47054705
.Item(5, I).Value = lTo
4706-
lStatVal = lTs.Attributes.GetValue(lOTStatName, Double.NaN)
4706+
With lTs.Attributes
4707+
If .ContainsAttribute(lOTStatName & "Adj") Then
4708+
lStatVal = .GetValue(lOTStatName & "Adj", Double.NaN)
4709+
Else
4710+
lStatVal = .GetValue(lOTStatName, Double.NaN)
4711+
End If
4712+
End With
47074713
If Not Double.IsNaN(lStatVal) Then
47084714
.Item(6, I).Value = DoubleToString(lStatVal, 15, "0.##########", aSignificantDigits:=8)
47094715
Else

0 commit comments

Comments
 (0)