From 35ae999fe3541151aae2d199f69d8757100ee6e3 Mon Sep 17 00:00:00 2001 From: PaulDudaRESPEC Date: Thu, 21 Jan 2021 11:01:36 -0500 Subject: [PATCH] HSPEXP -- updates for coding conventions --- HSPEXP/BATHTUB.vb | 182 +++--- HSPEXP/CookieCutterGraphs.vb | 164 +++--- HSPEXP/HSPFOutputReports.vb | 895 ++++++++++++++--------------- HSPEXP/MultiSimulatioManager.vb | 962 ++++++++++++++++---------------- HSPEXP/StartUp.vb | 17 +- HSPEXP/modListUCIParameters.vb | 81 ++- 6 files changed, 1148 insertions(+), 1153 deletions(-) diff --git a/HSPEXP/BATHTUB.vb b/HSPEXP/BATHTUB.vb index ff493a25d..314be45d9 100644 --- a/HSPEXP/BATHTUB.vb +++ b/HSPEXP/BATHTUB.vb @@ -15,14 +15,14 @@ Module BATHTUB Sub BATHTUBInputFile(ByVal aHSPFUCI As HspfUci, ByVal aBinaryData As atcDataSource, ByVal aSDateJ As Double, ByVal aEDateJ As Double, ByVal aReachId As Integer, ByVal aOutputfolder As String) - Dim BATHTUBInputFile As New Text.StringBuilder - BATHTUBInputFile.AppendLine("Vers 6.14f (04/28/2015)") 'First line of BATHTUB Output - BATHTUBInputFile.AppendLine("HSPF Reach " & aReachId & " BATHTUB Model Developed Using HSPEXP+") + Dim lBATHTUBInputFile As New Text.StringBuilder + lBATHTUBInputFile.AppendLine("Vers 6.14f (04/28/2015)") 'First line of BATHTUB Output + lBATHTUBInputFile.AppendLine("HSPF Reach " & aReachId & " BATHTUB Model Developed Using HSPEXP+") 'GLobal Parameters in four lines - BATHTUBInputFile.AppendLine("4,""Global Parmameters""") + lBATHTUBInputFile.AppendLine("4,""Global Parmameters""") Dim lYears As Integer = YearCount(aSDateJ, aEDateJ) - BATHTUBInputFile.AppendLine("1,""AVERAGING PERIOD (YRS)"",1,0") + lBATHTUBInputFile.AppendLine("1,""AVERAGING PERIOD (YRS)"",1,0") Dim lTimeseries_precip As atcTimeseries = aBinaryData.DataSets.FindData("Location", "R:" & aReachId).FindData("Constituent", "PRSUPY")(0) Dim lTimeseries_sarea As atcTimeseries = aBinaryData.DataSets.FindData("Location", "R:" & aReachId).FindData("Constituent", "SAREA")(0) Dim lTimeseries As atcTimeseries = lTimeseries_precip / lTimeseries_sarea @@ -31,7 +31,7 @@ Module BATHTUB Dim lAverage As Double = lTimeseries.Attributes.GetDefinedValue("Mean").Value Dim lStdEv As Double = lTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value Dim lCVmean As Double = lStdEv / (lTimeseries.numValues) ^ (0.5) / lAverage - BATHTUBInputFile.AppendLine("2,""PRECIPITATION (METERS)""," & Format(lAverage / 3.28084, "0.00") & "," & Format(lCVmean, "0.00")) + lBATHTUBInputFile.AppendLine("2,""PRECIPITATION (METERS)""," & Format(lAverage / 3.28084, "0.00") & "," & Format(lCVmean, "0.00")) Dim lTimeseries_volev = aBinaryData.DataSets.FindData("Location", "R:" & aReachId).FindData("Constituent", "VOLEV")(0) lTimeseries = lTimeseries_volev / lTimeseries_sarea lTimeseries = SubsetByDate(lTimeseries, aSDateJ, aEDateJ, Nothing) @@ -39,10 +39,10 @@ Module BATHTUB lAverage = lTimeseries.Attributes.GetDefinedValue("Mean").Value lStdEv = lTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value lCVmean = lStdEv / (lTimeseries.numValues) ^ (0.5) / lAverage - BATHTUBInputFile.AppendLine("3,""EVAPORATION (METERS)""," & Format(lAverage / 3.28084, "0.00") & "," & Format(lCVmean, "0.00")) + lBATHTUBInputFile.AppendLine("3,""EVAPORATION (METERS)""," & Format(lAverage / 3.28084, "0.00") & "," & Format(lCVmean, "0.00")) lTimeseries = aBinaryData.DataSets.FindData("Location", "R:" & aReachId).FindData("Constituent", "AVDEP")(0) Dim lChangeInDepth_m As Double = (lTimeseries.Value(1) - lTimeseries.Value(lTimeseries.numValues)) * 0.0254 / lYears - BATHTUBInputFile.AppendLine("4,""INCREASE IN STORAGE (METERS)""," & Format(lChangeInDepth_m, "0.00") & ",0") + lBATHTUBInputFile.AppendLine("4,""INCREASE IN STORAGE (METERS)""," & Format(lChangeInDepth_m, "0.00") & ",0") 'Model options in 12 lines; mostly copied from the default btb file Dim lString As String = "12,""Model Options""" & vbCrLf & @@ -58,7 +58,7 @@ Module BATHTUB "10,""AVAILABILITY FACTORS"",0" & vbCrLf & "11,""MASS-BALANCE TABLES"",1" & vbCrLf & "12,""OUTPUT DESTINATION"",2" - BATHTUBInputFile.AppendLine(lString) + lBATHTUBInputFile.AppendLine(lString) 'Model coefficients in 17 lines. Copied from an example file. lString = "17,""Model Coefficients""" & vbCrLf & @@ -79,14 +79,14 @@ Module BATHTUB "15,""Avail Factor - Ortho P"",1.93,0" & vbCrLf & "16,""Avail Factor - TN"",.59,0" & vbCrLf & "17,""Avail Factor - Inorganic N"",.79,0" - BATHTUBInputFile.AppendLine(lString) + lBATHTUBInputFile.AppendLine(lString) 'Atmospheric deposition in 2 lines. Not sure if other atmospheric deposition information is required. - BATHTUBInputFile.AppendLine("5,""Atmospheric Loads""") + lBATHTUBInputFile.AppendLine("5,""Atmospheric Loads""") Dim lSurfaceArea_km2 As Double = 0 lTimeseries = aBinaryData.DataSets.FindData("Location", "R:" & aReachId).FindData("Constituent", "SAREA")(0) lSurfaceArea_km2 = lTimeseries.Attributes.GetDefinedValue("Mean").Value * 0.00404686 - BATHTUBInputFile.AppendLine("1,""CONSERVATIVE SUBST."",0,0") + lBATHTUBInputFile.AppendLine("1,""CONSERVATIVE SUBST."",0,0") lTimeseries = aBinaryData.DataSets.FindData("Location", "R:" & aReachId).FindData("Constituent", "PO4-ATMDEPTOT")(0) Dim lTPAverage As Double = 0 Dim lTPCVmean As Double = 0 @@ -99,9 +99,9 @@ Module BATHTUB If lTPAverage <> 0 Then lStdEv = lTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value lTPCVmean = lStdEv / (lTimeseries.numValues) ^ (0.5) / lTPAverage - BATHTUBInputFile.AppendLine("2,""TOTAL P""," & Format(lTPAverage, "0.00") & "," & Format(lTPCVmean, "0.00")) + lBATHTUBInputFile.AppendLine("2,""TOTAL P""," & Format(lTPAverage, "0.00") & "," & Format(lTPCVmean, "0.00")) Else - BATHTUBInputFile.AppendLine("2,""TOTAL P"",0,0") + lBATHTUBInputFile.AppendLine("2,""TOTAL P"",0,0") End If End If @@ -130,13 +130,13 @@ Module BATHTUB If lAverage <> 0 Then lStdEv = lTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value lCVmean = lStdEv / (lTimeseries.numValues) ^ (0.5) / lAverage - BATHTUBInputFile.AppendLine("3,""TOTAL N""," & Format(lAverage, "0.00") & "," & Format(lCVmean, "0.00")) + lBATHTUBInputFile.AppendLine("3,""TOTAL N""," & Format(lAverage, "0.00") & "," & Format(lCVmean, "0.00")) Else - BATHTUBInputFile.AppendLine("3,""TOTAL N"",0,0") + lBATHTUBInputFile.AppendLine("3,""TOTAL N"",0,0") End If - BATHTUBInputFile.AppendLine("4,""ORTHO P""," & Format(lTPAverage / 2, "0.00") & "," & Format(lTPCVmean, "0.00")) - BATHTUBInputFile.AppendLine("5,""INORGANIC N""," & Format(lAverage / 2, "0.00") & "," & Format(lCVmean, "0.00")) + lBATHTUBInputFile.AppendLine("4,""ORTHO P""," & Format(lTPAverage / 2, "0.00") & "," & Format(lTPCVmean, "0.00")) + lBATHTUBInputFile.AppendLine("5,""INORGANIC N""," & Format(lAverage / 2, "0.00") & "," & Format(lCVmean, "0.00")) 'Lake segments; assumes only one segment Dim lMeanDepth_m As Double = 0 @@ -145,15 +145,15 @@ Module BATHTUB lTimeseries = Aggregate(lTimeseries, atcTimeUnit.TUYear, 1, atcTran.TranAverSame) lTimeseries /= 3.28084 lMeanDepth_m = lTimeseries.Attributes.GetDefinedValue("Mean").Value - Dim CVMeanSampleSizeBasedOnHourly As Double = 0 - CVMeanSampleSizeBasedOnHourly = ((aEDateJ - aSDateJ) / 365) + Dim lCVMeanSampleSizeBasedOnHourly As Double = 0 + lCVMeanSampleSizeBasedOnHourly = ((aEDateJ - aSDateJ) / 365) 'Dim lDepth_CVmean As Double = lTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value / (lTimeseries.numValues) ^ (0.5) / lMeanDepth_m - Dim lDepth_CVmean As Double = lTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value / (CVMeanSampleSizeBasedOnHourly) ^ (0.5) / lMeanDepth_m + Dim lDepth_CVmean As Double = lTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value / (lCVMeanSampleSizeBasedOnHourly) ^ (0.5) / lMeanDepth_m Dim lLength_km As Double = aHSPFUCI.OpnBlks("RCHRES").OperFromID(aReachId).Tables("HYDR-PARM2").Parms("LEN").Value * 1.60934 'COnverting stream length in miles to km - BATHTUBInputFile.AppendLine("1,""Segments""") + lBATHTUBInputFile.AppendLine("1,""Segments""") 'Properties of the first segment - BATHTUBInputFile.AppendLine("1,""Main Pool"",0,1," & Format(lSurfaceArea_km2, "0.00") & "," & + lBATHTUBInputFile.AppendLine("1,""Main Pool"",0,1," & Format(lSurfaceArea_km2, "0.00") & "," & Format(lMeanDepth_m, "0.00") & "," & Format(lLength_km, "0.00") & "," & Format(lMeanDepth_m, "0.00") & "," & Format(lDepth_CVmean, "0.00") & ",0,0,0.08,0.05,0,0") 'Lines for pollutants in the first segment; all written as zero and user must input in Bathtub; placeholder values are included for non-algal turbidity mean and CVmean to allow model to run @@ -171,7 +171,7 @@ Module BATHTUB "1,""MOD-V MG/M3-DAY"",0,0,1,0" & vbCrLf - BATHTUBInputFile.Append(lString) + lBATHTUBInputFile.Append(lString) 'Information about the tributaries @@ -184,14 +184,14 @@ Module BATHTUB Next 'An extra tributary is created for lakeshed loading - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""Tributaries""") + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""Tributaries""") lCountNumberOfTributaries = 0 Dim lOperationTypes As New atcCollection lOperationTypes.Add("P:", "PERLND") lOperationTypes.Add("I:", "IMPLND") lOperationTypes.Add("R:", "RCHRES") - CVMeanSampleSizeBasedOnHourly = 0 + lCVMeanSampleSizeBasedOnHourly = 0 Dim lCVmeanROVOL As Double = 0 Dim lCVmeanTP As Double = 0 Dim lCVmeanOP As Double = 0 @@ -206,7 +206,7 @@ Module BATHTUB Dim lLocationID As String = lSource.Source.VolName.Substring(0, 1) & ":" & lSource.Source.VolId Dim lTribID As Integer = lSource.Source.VolId Dim lAreaTable As DataTable = AreaReportInTableFormat(aHSPFUCI, lOperationTypes, lLocationID) - Dim lselectExpression As String = "Landuse='Total'" + Dim lSelectExpression As String = "Landuse='Total'" Dim lTotalRows() As DataRow = lAreaTable.Select("Landuse='Total'") Dim lDrainageAreaKM2 As Double = lTotalRows(0)("TotalArea") * 0.00404686 'Converting areas from ac to km2 @@ -227,9 +227,9 @@ Module BATHTUB lAverage = lTimeseries.Attributes.GetDefinedValue("Mean").Value lStdEv = lTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value lCVmeanROVOL = lStdEv / (lTimeseries.numValues) ^ (0.5) / lAverage - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""HSPF Reach " & lTribID & """,1,1," & Format(lDrainageAreaKM2, "0.00") & "," & Format(lAverage, "0.00") & "," & Format(lCVmeanROVOL, "0.00") & ",0") + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""HSPF Reach " & lTribID & """,1,1," & Format(lDrainageAreaKM2, "0.00") & "," & Format(lAverage, "0.00") & "," & Format(lCVmeanROVOL, "0.00") & ",0") - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""CONSERVATIVE SUBST."",0,0") + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""CONSERVATIVE SUBST."",0,0") 'Get the total P concentration data lTimeseries = LocateTheTimeSeries(aHSPFUCI, lTribID, "PLANK", "TPKCF1", 5, 1, lTimeSeriesIsInWDM) @@ -246,9 +246,9 @@ Module BATHTUB lConcTimeseries /= 1233480 lAverage = FlowWeightedConc(lConcTimeseries, lROVOLTimeseries) lStdEv = lConcTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value - CVMeanSampleSizeBasedOnHourly = ((aEDateJ - aSDateJ) / 365) - lCVmeanTP = lStdEv / (CVMeanSampleSizeBasedOnHourly) ^ (0.5) / lAverage - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""TOTAL P""," & Format(lAverage, "0.00") & "," & Format(lCVmeanTP, "0.00")) + lCVMeanSampleSizeBasedOnHourly = ((aEDateJ - aSDateJ) / 365) + lCVmeanTP = lStdEv / (lCVMeanSampleSizeBasedOnHourly) ^ (0.5) / lAverage + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""TOTAL P""," & Format(lAverage, "0.00") & "," & Format(lCVmeanTP, "0.00")) 'Get the total N concentration lTimeseries = LocateTheTimeSeries(aHSPFUCI, lTribID, "PLANK", "TPKCF1", 4, 1, lTimeSeriesIsInWDM) @@ -265,8 +265,8 @@ Module BATHTUB lConcTimeseries /= 1233480 lAverage = FlowWeightedConc(lConcTimeseries, lROVOLTimeseries) lStdEv = lConcTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value - lCVmeanTN = lStdEv / (CVMeanSampleSizeBasedOnHourly) ^ (0.5) / lAverage - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""TOTAL N""," & Format(lAverage, "0.00") & "," & Format(lCVmeanTN, "0.00")) + lCVmeanTN = lStdEv / (lCVMeanSampleSizeBasedOnHourly) ^ (0.5) / lAverage + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""TOTAL N""," & Format(lAverage, "0.00") & "," & Format(lCVmeanTN, "0.00")) 'Get the ortho P concentration lTimeseries = LocateTheTimeSeries(aHSPFUCI, lTribID, "NUTRX", "DNUST", 4, 1, lTimeSeriesIsInWDM) @@ -279,8 +279,8 @@ Module BATHTUB lTimeseries = SubsetByDate(lTimeseries, aSDateJ, aEDateJ, Nothing) lAverage = FlowWeightedConc(lTimeseries, lROVOLTimeseries) * 1000 'Original concentration is in mg/l or ppm. Multiplying it by 1000, makes it ppb lStdEv = lTimeseries.Attributes.GetDefinedValue("Standard Deviation").Value - lCVmeanOP = lStdEv / (CVMeanSampleSizeBasedOnHourly) ^ (0.5) / lAverage - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""ORTHO P""," & Format(lAverage, "0.00") & "," & Format(lCVmeanOP, "0.00")) + lCVmeanOP = lStdEv / (lCVMeanSampleSizeBasedOnHourly) ^ (0.5) / lAverage + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""ORTHO P""," & Format(lAverage, "0.00") & "," & Format(lCVmeanOP, "0.00")) 'Get the inorganic N concentration (sum of NO3, NO2, and TAM) lTimeseries = LocateTheTimeSeries(aHSPFUCI, lTribID, "NUTRX", "DNUST", 1, 1, lTimeSeriesIsInWDM) @@ -313,9 +313,9 @@ Module BATHTUB lInorgN = SubsetByDate(lInorgN, aSDateJ, aEDateJ, Nothing) lAverage = FlowWeightedConc(lInorgN, lROVOLTimeseries) * 1000 'Original concentration is in mg/l or ppm. Multiplying it by 1000, makes it ppb lStdEv = lInorgN.Attributes.GetDefinedValue("Standard Deviation").Value - lCVmeanIN = lStdEv / (CVMeanSampleSizeBasedOnHourly) ^ (0.5) / lAverage - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""INORGANIC N""," & Format(lAverage, "0.00") & "," & Format(lCVmeanIN, "0.00")) - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""LandUses"",0,0,0,0,0,0,0,0") + lCVmeanIN = lStdEv / (lCVMeanSampleSizeBasedOnHourly) ^ (0.5) / lAverage + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""INORGANIC N""," & Format(lAverage, "0.00") & "," & Format(lCVmeanIN, "0.00")) + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries & ",""LandUses"",0,0,0,0,0,0,0,0") End If Next @@ -393,58 +393,58 @@ Module BATHTUB lRow("Area_km2") = lSource.MFact * 0.00404686 'Converting area from ac to km2 Dim WaterVolumeInMAndCov As Double() = CalculateVolumeInMeters(lSource.Source.Opn, aBinaryData, aSDateJ, aEDateJ, lLocationID) lRow("Water_Vol_m") = WaterVolumeInMAndCov(0) - lRow("Water_Vol_COV") = WaterVolumeInMAndCov(1) * ((lTimeseries.numValues) ^ (0.5)) / ((CVMeanSampleSizeBasedOnHourly) ^ (0.5)) + lRow("Water_Vol_COV") = WaterVolumeInMAndCov(1) * ((lTimeseries.numValues) ^ (0.5)) / ((lCVMeanSampleSizeBasedOnHourly) ^ (0.5)) 'The loading rate from the function is in lbs/ac. Multiplying it by 112.085 converts to mg/m2. Dividing it by water depth, converts to mg/m3 Dim NutrientLoadAndCOV As Double() = CalculatePhosphorus(lSource.Source.Opn, aBinaryData, lRCHRESOperation, lMassLinkID, aSDateJ, aEDateJ, aHSPFUCI) lRow("PO4_mg_m3") = NutrientLoadAndCOV(0) / WaterVolumeInMAndCov(0) - lRow("PO4_COV") = NutrientLoadAndCOV(1) * ((lTimeseries.numValues) ^ (0.5)) / ((CVMeanSampleSizeBasedOnHourly) ^ (0.5)) + lRow("PO4_COV") = NutrientLoadAndCOV(1) * ((lTimeseries.numValues) ^ (0.5)) / ((lCVMeanSampleSizeBasedOnHourly) ^ (0.5)) lRow("TP_mg_m3") = NutrientLoadAndCOV(2) / WaterVolumeInMAndCov(0) - lRow("TP_COV") = NutrientLoadAndCOV(3) * ((lTimeseries.numValues) ^ (0.5)) / ((CVMeanSampleSizeBasedOnHourly) ^ (0.5)) + lRow("TP_COV") = NutrientLoadAndCOV(3) * ((lTimeseries.numValues) ^ (0.5)) / ((lCVMeanSampleSizeBasedOnHourly) ^ (0.5)) NutrientLoadAndCOV = CalculateNitrogen(lSource.Source.Opn, aBinaryData, lRCHRESOperation, lMassLinkID, aSDateJ, aEDateJ, aHSPFUCI) lRow("InorgN_mg_m3") = NutrientLoadAndCOV(0) / WaterVolumeInMAndCov(0) - lRow("InorgN_COV") = NutrientLoadAndCOV(1) * ((lTimeseries.numValues) ^ (0.5)) / ((CVMeanSampleSizeBasedOnHourly) ^ (0.5)) + lRow("InorgN_COV") = NutrientLoadAndCOV(1) * ((lTimeseries.numValues) ^ (0.5)) / ((lCVMeanSampleSizeBasedOnHourly) ^ (0.5)) lRow("TN_mg_m3") = NutrientLoadAndCOV(2) / WaterVolumeInMAndCov(0) - lRow("TN_COV") = NutrientLoadAndCOV(3) * ((lTimeseries.numValues) ^ (0.5)) / ((CVMeanSampleSizeBasedOnHourly) ^ (0.5)) + lRow("TN_COV") = NutrientLoadAndCOV(3) * ((lTimeseries.numValues) ^ (0.5)) / ((lCVMeanSampleSizeBasedOnHourly) ^ (0.5)) lNPSTable.Rows.Add(lRow) End If Next - Dim lakeshedAreaKm2 As Double = lNPSTable.Compute("SUM(Area_km2)", "") + Dim lLakeshedAreaKm2 As Double = lNPSTable.Compute("SUM(Area_km2)", "") 'BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""LakeShed"",1,2," & Format(lakeshedAreaKm2, "0.00") & ",0,0,0") ' & Format(lAverage, "0.00") & "," & Format(lCov, "0.00") & ",0") 'BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""CONSERVATIVE SUBST."",0,0") 'BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""TOTAL P"",0,0") 'BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""TOTAL N"",0,0") 'BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""ORTHO P"",0,0") 'BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""INORGANIC N"",0,0") - Dim landuseAreakm2 As String = lCountNumberOfTributaries + 1 & ",""LandUses""," + Dim lLanduseAreakm2 As String = lCountNumberOfTributaries + 1 & ",""LandUses""," Dim lNumberOfLandUses As Integer = lNPSTable.Rows.Count For Each lNPSTableRow As DataRow In lNPSTable.Rows - landuseAreakm2 &= Format(lNPSTableRow("Area_km2"), "0.00") & "," + lLanduseAreakm2 &= Format(lNPSTableRow("Area_km2"), "0.00") & "," Next If lNumberOfLandUses < 8 Then For i As Integer = 1 To 8 - lNumberOfLandUses - landuseAreakm2 &= "0," + lLanduseAreakm2 &= "0," Next End If - landuseAreakm2 = landuseAreakm2.Substring(0, landuseAreakm2.Length - 1) + lLanduseAreakm2 = lLanduseAreakm2.Substring(0, lLanduseAreakm2.Length - 1) 'BATHTUBInputFile.AppendLine(landuseAreakm2) 'BATHTUBInputFile.AppendLine("0,""Channels""") 'BATHTUBInputFile.AppendLine("8,""Land Use Export Categories""") - Dim CumArea As Double = 0 - Dim CumRunoff As Double = 0 - Dim CumTPLoad As Double = 0 - Dim CumTNLoad As Double = 0 - Dim CumOPLoad As Double = 0 - Dim CumINLoad As Double = 0 - Dim LandUseNumber As Integer = 0 + Dim lCumArea As Double = 0 + Dim lCumRunoff As Double = 0 + Dim lCumTPLoad As Double = 0 + Dim lCumTNLoad As Double = 0 + Dim lCumOPLoad As Double = 0 + Dim lCumINLoad As Double = 0 + Dim lLandUseNumber As Integer = 0 For Each lNPSTableRow As DataRow In lNPSTable.Rows - LandUseNumber += 1 - CumArea += lNPSTableRow("Area_km2") - CumRunoff += lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") - CumTPLoad += lNPSTableRow("TP_mg_m3") * lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") - CumTNLoad += lNPSTableRow("TN_mg_m3") * lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") - CumOPLoad += lNPSTableRow("PO4_mg_m3") * lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") - CumINLoad += lNPSTableRow("InorgN_mg_m3") * lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") + lLandUseNumber += 1 + lCumArea += lNPSTableRow("Area_km2") + lCumRunoff += lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") + lCumTPLoad += lNPSTableRow("TP_mg_m3") * lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") + lCumTNLoad += lNPSTableRow("TN_mg_m3") * lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") + lCumOPLoad += lNPSTableRow("PO4_mg_m3") * lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") + lCumINLoad += lNPSTableRow("InorgN_mg_m3") * lNPSTableRow("Water_Vol_m") * lNPSTableRow("Area_km2") 'BATHTUBInputFile.AppendLine(LandUseNumber & "," & """" & lNPSTableRow("LandUseName") & """") 'BATHTUBInputFile.AppendLine(LandUseNumber & ",""Runoff""," & Format(lNPSTableRow("Water_Vol_m"), "0.00") & "," & Format(lNPSTableRow("Water_Vol_COV"), "0.00")) 'BATHTUBInputFile.AppendLine(LandUseNumber & ",""CONSERVATIVE SUBST."",0,0") @@ -454,57 +454,57 @@ Module BATHTUB 'BATHTUBInputFile.AppendLine(LandUseNumber & ",""INORGANIC N""," & Format(lNPSTableRow("InorgN_mg_m3"), "0.00") & "," & Format(lNPSTableRow("InorgN_COV"), "0.00")) Next - Dim CumTPConc As Double = 0 - Dim CumTNConc As Double = 0 - Dim CumOPConc As Double = 0 - Dim CumINConc As Double = 0 + Dim lCumTPConc As Double = 0 + Dim lCumTNConc As Double = 0 + Dim lCumOPConc As Double = 0 + Dim lCumINConc As Double = 0 - If CumRunoff > 0 Then - CumTPConc = CumTPLoad / CumRunoff - CumTNConc = CumTNLoad / CumRunoff - CumOPConc = CumOPLoad / CumRunoff - CumINConc = CumINLoad / CumRunoff + If lCumRunoff > 0 Then + lCumTPConc = lCumTPLoad / lCumRunoff + lCumTNConc = lCumTNLoad / lCumRunoff + lCumOPConc = lCumOPLoad / lCumRunoff + lCumINConc = lCumINLoad / lCumRunoff End If - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""Lakeshed: HSPF Reach " & aReachId & """,1,1," & Format(CumArea, "0.00") & "," & Format(CumRunoff, "0.00") & "," & Format(lCVmeanROVOL, "0.00") & ",0") - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""CONSERVATIVE SUBST."",0,0") - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""TOTAL P""," & Format(CumTPConc, "0.00") & "," & Format(lCVmeanTP, "0.00")) - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""TOTAL N""," & Format(CumTNConc, "0.00") & "," & Format(lCVmeanTN, "0.00")) - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""ORTHO P""," & Format(CumOPConc, "0.00") & "," & Format(lCVmeanOP, "0.00")) - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""INORGANIC N""," & Format(CumINConc, "0.00") & "," & Format(lCVmeanIN, "0.00")) - BATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""LandUses"",0,0,0,0,0,0,0,0") + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""Lakeshed: HSPF Reach " & aReachId & """,1,1," & Format(lCumArea, "0.00") & "," & Format(lCumRunoff, "0.00") & "," & Format(lCVmeanROVOL, "0.00") & ",0") + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""CONSERVATIVE SUBST."",0,0") + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""TOTAL P""," & Format(lCumTPConc, "0.00") & "," & Format(lCVmeanTP, "0.00")) + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""TOTAL N""," & Format(lCumTNConc, "0.00") & "," & Format(lCVmeanTN, "0.00")) + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""ORTHO P""," & Format(lCumOPConc, "0.00") & "," & Format(lCVmeanOP, "0.00")) + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""INORGANIC N""," & Format(lCumINConc, "0.00") & "," & Format(lCVmeanIN, "0.00")) + lBATHTUBInputFile.AppendLine(lCountNumberOfTributaries + 1 & ",""LandUses"",0,0,0,0,0,0,0,0") 'BATHTUBInputFile.AppendLine(landuseAreakm2) - BATHTUBInputFile.AppendLine("0,""Channels""") - BATHTUBInputFile.AppendLine("8,""Land Use Export Categories""") + lBATHTUBInputFile.AppendLine("0,""Channels""") + lBATHTUBInputFile.AppendLine("8,""Land Use Export Categories""") 'If lNumberOfLandUses < 8 Then For i As Integer = 1 To 8 '- lNumberOfLandUses - BATHTUBInputFile.AppendLine(i & "," & """landuse" & i & """") + lBATHTUBInputFile.AppendLine(i & "," & """landuse" & i & """") 'BATHTUBInputFile.AppendLine(i + lNumberOfLandUses & "," & """""") - BATHTUBInputFile.AppendLine(i & ",""Runoff"",0,0") + lBATHTUBInputFile.AppendLine(i & ",""Runoff"",0,0") 'BATHTUBInputFile.AppendLine(i + lNumberOfLandUses & ",""Runoff"",0,0") - BATHTUBInputFile.AppendLine(i & ",""CONSERVATIVE SUBST."",0,0") + lBATHTUBInputFile.AppendLine(i & ",""CONSERVATIVE SUBST."",0,0") 'BATHTUBInputFile.AppendLine(i + lNumberOfLandUses & ",""CONSERVATIVE SUBST."",0,0") - BATHTUBInputFile.AppendLine(i & ",""TOTAL P"",0,0") + lBATHTUBInputFile.AppendLine(i & ",""TOTAL P"",0,0") 'BATHTUBInputFile.AppendLine(i + lNumberOfLandUses & ",""TOTAL P"",0,0") - BATHTUBInputFile.AppendLine(i & ",""TOTAL N"",0,0") + lBATHTUBInputFile.AppendLine(i & ",""TOTAL N"",0,0") 'BATHTUBInputFile.AppendLine(i + lNumberOfLandUses & ",""TOTAL N"",0,0") - BATHTUBInputFile.AppendLine(i & ",""ORTHO P"",0,0") + lBATHTUBInputFile.AppendLine(i & ",""ORTHO P"",0,0") 'BATHTUBInputFile.AppendLine(i + lNumberOfLandUses & ",""ORTHO P"",0,0") - BATHTUBInputFile.AppendLine(i & ",""INORGANIC N"",0,0") + lBATHTUBInputFile.AppendLine(i & ",""INORGANIC N"",0,0") 'BATHTUBInputFile.AppendLine(i + lNumberOfLandUses & ",""INORGANIC N"",0,0") Next 'End If - BATHTUBInputFile.AppendLine("""Notes""") + lBATHTUBInputFile.AppendLine("""Notes""") 'BATHTUBInputFile.AppendLine("Write Whatever you Want!!!") For i As Integer = 0 To 9 - BATHTUBInputFile.AppendLine() + lBATHTUBInputFile.AppendLine() Next - File.WriteAllText(aOutputfolder & "BATHTUB_" & aReachId & ".btb", BATHTUBInputFile.ToString) + File.WriteAllText(aOutputfolder & "BATHTUB_" & aReachId & ".btb", lBATHTUBInputFile.ToString) End Sub Private Function CalculateVolumeInMeters(ByVal aHSPFOpn As HspfOperation, ByVal aBinaryData As atcDataSource, ByVal aSDateJ As Double, ByVal aEDateJ As Double, diff --git a/HSPEXP/CookieCutterGraphs.vb b/HSPEXP/CookieCutterGraphs.vb index 6c5ee281a..3ea18f717 100644 --- a/HSPEXP/CookieCutterGraphs.vb +++ b/HSPEXP/CookieCutterGraphs.vb @@ -8,17 +8,17 @@ Imports System.Collections.Specialized Public Module CookieCutterGraphs 'This can probably go under atcGraph. - Sub ReganGraphs(ByVal aHSPFUCI As HspfUci, ByVal aSDateJ As Double, ByVal aEDateJ As Double, ByVal lOutputFolder As String) + Sub ReganGraphs(ByVal aHSPFUCI As HspfUci, ByVal aSDateJ As Double, ByVal aEDateJ As Double, ByVal aOutputFolder As String) Dim lConstituentsToGraph As New atcCollection - lOutputFolder &= "ReganPlots\" - Dim WQCriteriaInmgperliter As Double = 0.0 - Dim acftToCubicft As Double = 43560 'Should be called from modUnits - Dim CubicftToLiters As Double = 28.317 - Dim PoundsToMilligrams As Double = 453592.0 - Dim TSTimeUnit As Integer - Dim CommonRESStandard As Double = 0.0 - Dim LowerRangeRCHId As Integer = 0 - Dim HigherRangeRCHId As Integer = 0 + Dim lOutputFolder As String = aOutputFolder & "ReganPlots\" + Dim lWQCriteriaInmgperliter As Double = 0.0 + Dim lAcftToCubicft As Double = 43560 'Should be called from modUnits + Dim lCubicftToLiters As Double = 28.317 + Dim lPoundsToMilligrams As Double = 453592.0 + Dim lTSTimeUnit As Integer + Dim lCommonRESStandard As Double = 0.0 + Dim lLowerRangeRCHId As Integer = 0 + Dim lHigherRangeRCHId As Integer = 0 If Not System.IO.Directory.Exists(lOutputFolder) Then System.IO.Directory.CreateDirectory(lOutputFolder) @@ -68,11 +68,11 @@ Public Module CookieCutterGraphs Next lTs End If - For Each RCHRES In lLocations + For Each lRCHRES In lLocations #Region "Plotting Nutrient Curves" - If RCHRES.Contains("R:") Then + If lRCHRES.Contains("R:") Then - Dim lRchId = RCHRES.split(":")(1) + Dim lRchId = lRCHRES.split(":")(1) Dim lRchresCaption As String = aHSPFUCI.OpnBlks("RCHRES").OperFromID(lRchId).Caption lRchresCaption = Trim(Mid(lRchresCaption, 11)) Dim lTimeseriesGroup As New atcTimeseriesGroup @@ -84,13 +84,13 @@ Public Module CookieCutterGraphs If lFoundTheTimeSeriesinWDMFile = False Then 'Reading the required time series from Binary file and resetting the flag to false - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "BALCLA1")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "BALCLA1")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) End If lTimeSeries.Attributes.SetValue("YAxis", "Aux") @@ -101,12 +101,12 @@ Public Module CookieCutterGraphs lTimeSeries = SubsetByDate(lTimeSeries, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False Then - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "PHYCLA")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "PHYCLA")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) End If lTimeSeries.Attributes.SetValue("YAxis", "Left") @@ -116,13 +116,13 @@ Public Module CookieCutterGraphs lTimeSeries = LocateTheTimeSeries(aHSPFUCI, lRchId, "NUTRX", "DNUST", 4, 1, lFoundTheTimeSeriesinWDMFile) lTimeSeries = SubsetByDate(lTimeSeries, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False Then - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "PO4-CONCDIS")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "PO4-CONCDIS")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) End If lTimeSeries.Attributes.SetValue("YAxis", "Right") @@ -132,12 +132,12 @@ Public Module CookieCutterGraphs lTimeSeries = LocateTheTimeSeries(aHSPFUCI, lRchId, "NUTRX", "DNUST", 2, 1, lFoundTheTimeSeriesinWDMFile) lTimeSeries = SubsetByDate(lTimeSeries, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False Then - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "TAM-CONCDIS")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "TAM-CONCDIS")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) End If lTimeSeries.Attributes.SetValue("YAxis", "Right") @@ -147,14 +147,14 @@ Public Module CookieCutterGraphs lTimeSeries = LocateTheTimeSeries(aHSPFUCI, lRchId, "NUTRX", "DNUST", 1, 1, lFoundTheTimeSeriesinWDMFile) lTimeSeries = SubsetByDate(lTimeSeries, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False Then - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "NO3-CONCDIS")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "NO3-CONCDIS")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) End If lTimeSeries.Attributes.SetValue("YAxis", "Right") @@ -222,12 +222,12 @@ Public Module CookieCutterGraphs lTimeSeries = LocateTheTimeSeries(aHSPFUCI, lRchId, "HYDR", "RO", 1, 1, lFoundTheTimeSeriesinWDMFile) lTimeSeries = SubsetByDate(lTimeSeries, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False Then - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "RO")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "RO")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) End If lTimeSeries.Attributes.SetValue("YAxis", "Aux") @@ -238,13 +238,13 @@ Public Module CookieCutterGraphs lTimeSeries = SubsetByDate(lTimeSeries, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False Then - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "SSED-TOT")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "SSED-TOT")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) End If lTimeSeries.Attributes.SetValue("YAxis", "Left") @@ -253,12 +253,12 @@ Public Module CookieCutterGraphs lTimeSeries = LocateTheTimeSeries(aHSPFUCI, lRchId, "SEDTRN", "BEDDEP", 1, 1, lFoundTheTimeSeriesinWDMFile) lTimeSeries = SubsetByDate(lTimeSeries, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False Then - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "BEDDEP")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "BEDDEP")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) End If lTimeSeries.Attributes.SetValue("YAxis", "Right") @@ -310,7 +310,7 @@ Public Module CookieCutterGraphs lTimeSeriesDO = SubsetByDate(lTimeSeriesDO, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False OrElse lTimeSeriesTimeUnit < 3 Then - lTimeSeriesDO = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "DOXCONC")(0) + lTimeSeriesDO = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "DOXCONC")(0) End If lTimeSeriesTimeUnit = lTimeSeriesDO.Attributes.GetDefinedValue("Time Unit").Value lFoundTheTimeSeriesinWDMFile = False @@ -339,8 +339,8 @@ Public Module CookieCutterGraphs lMainPane.YAxis.Title.Text = "Dissolved Oxygen (mg/L)" lMainPane.YAxis.Scale.Min = 0 lMainPane.YAxis.Scale.Max = 20 - lZgc.SaveIn(lOutputFolder & "DO_Concentration_RCHRES_" & RCHRES.split(":")(1) & ".png") - Logger.Dbg("Generated graph " & lOutputFolder & "DO_Concentration_RCHRES_" & RCHRES.split(":")(1) & ".png") + lZgc.SaveIn(lOutputFolder & "DO_Concentration_RCHRES_" & lRCHRES.split(":")(1) & ".png") + Logger.Dbg("Generated graph " & lOutputFolder & "DO_Concentration_RCHRES_" & lRCHRES.split(":")(1) & ".png") Else Logger.Dbg("The time unit of DO timeseries is daily or greater, so max daily and min daily will not be calculated for RCHRES:" & lRchId) End If @@ -348,49 +348,49 @@ Public Module CookieCutterGraphs 'Plotting Load Duration Curve 'Read the RES_TP_Standard.csv #Region "Plotting RES Curve" - If CommonRESStandard = 0.0 Then + If lCommonRESStandard = 0.0 Then - If Not (lRchId = LowerRangeRCHId Or lRchId = HigherRangeRCHId Or - (lRchId > LowerRangeRCHId AndAlso lRchId < HigherRangeRCHId)) Then - WQCriteriaInmgperliter = 0.0 + If Not (lRchId = lLowerRangeRCHId Or lRchId = lHigherRangeRCHId Or + (lRchId > lLowerRangeRCHId AndAlso lRchId < lHigherRangeRCHId)) Then + lWQCriteriaInmgperliter = 0.0 Dim lRESStandardFileNames As New NameValueCollection AddFilesInDir(lRESStandardFileNames, IO.Directory.GetCurrentDirectory, False, "*RES_TP_Standard.csv") If lRESStandardFileNames.Count < 1 Then ' Logger.Dbg(Now & " Custom graphs will not be produced.") Continue For End If - Dim lgraphRecordsNew As New ArrayList() + Dim lGraphRecordsNew As New ArrayList() Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(lRESStandardFileNames(0)) Dim lines() As String = {} If System.IO.File.Exists(lRESStandardFileNames(0)) Then MyReader.TextFieldType = FileIO.FieldType.Delimited MyReader.SetDelimiters(",") - Dim CurrentRow As String() + Dim lCurrentRow As String() While Not MyReader.EndOfData Try If MyReader.PeekChars(10000).Contains("***") Or MyReader.PeekChars(10000).Contains("RCHRES") Then - CurrentRow = MyReader.ReadFields + lCurrentRow = MyReader.ReadFields Else - CurrentRow = MyReader.ReadFields - If CurrentRow(0).ToLower = "all" Then - CommonRESStandard = CurrentRow(1) - ElseIf CurrentRow(0).Contains("-") Then - Dim Range As String() = CurrentRow(0).Split("-") - LowerRangeRCHId = CType(Trim(Range(0)), Integer) - HigherRangeRCHId = CType(Trim(Range(1)), Integer) - If lRchId = LowerRangeRCHId Or lRchId = HigherRangeRCHId Or - (lRchId > LowerRangeRCHId AndAlso lRchId < HigherRangeRCHId) Then - WQCriteriaInmgperliter = CurrentRow(1) + lCurrentRow = MyReader.ReadFields + If lCurrentRow(0).ToLower = "all" Then + lCommonRESStandard = lCurrentRow(1) + ElseIf lCurrentRow(0).Contains("-") Then + Dim lRange As String() = lCurrentRow(0).Split("-") + lLowerRangeRCHId = CType(Trim(lRange(0)), Integer) + lHigherRangeRCHId = CType(Trim(lRange(1)), Integer) + If lRchId = lLowerRangeRCHId Or lRchId = lHigherRangeRCHId Or + (lRchId > lLowerRangeRCHId AndAlso lRchId < lHigherRangeRCHId) Then + lWQCriteriaInmgperliter = lCurrentRow(1) Exit While End If - ElseIf lRchId = CType(CurrentRow(0), Integer) Then - WQCriteriaInmgperliter = CurrentRow(1) + ElseIf lRchId = CType(lCurrentRow(0), Integer) Then + lWQCriteriaInmgperliter = lCurrentRow(1) End If - lgraphRecordsNew.Add(CurrentRow) + lGraphRecordsNew.Add(lCurrentRow) End If Catch ex As Microsoft.VisualBasic. @@ -405,24 +405,24 @@ Public Module CookieCutterGraphs Else - WQCriteriaInmgperliter = CommonRESStandard + lWQCriteriaInmgperliter = lCommonRESStandard End If - If WQCriteriaInmgperliter > 0.0 Then + If lWQCriteriaInmgperliter > 0.0 Then lTimeseriesGroup = New atcTimeseriesGroup lTimeSeries = LocateTheTimeSeries(aHSPFUCI, lRchId, "HYDR", "IVOL", 1, 1, lFoundTheTimeSeriesinWDMFile) lTimeSeries = SubsetByDate(lTimeSeries, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False Then - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "IVOL")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "IVOL")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranSumDiv) - lTimeSeries = lTimeSeries * WQCriteriaInmgperliter * acftToCubicft * CubicftToLiters / PoundsToMilligrams + lTimeSeries = lTimeSeries * lWQCriteriaInmgperliter * lAcftToCubicft * lCubicftToLiters / lPoundsToMilligrams lTimeSeries.Attributes.SetValue("YAxis", "Left") lTimeseriesGroup.Add(lTimeSeries) End If @@ -430,13 +430,13 @@ Public Module CookieCutterGraphs lTimeSeries = LocateTheTimeSeries(aHSPFUCI, lRchId, "PLANK", "TPKIF", 5, 1, lFoundTheTimeSeriesinWDMFile) lTimeSeries = SubsetByDate(lTimeSeries, aSDateJ, aEDateJ, Nothing) If lFoundTheTimeSeriesinWDMFile = False Then - lTimeSeries = lScenarioResults.DataSets.FindData("Location", RCHRES).FindData("Constituent", "P-TOT-IN")(0) + lTimeSeries = lScenarioResults.DataSets.FindData("Location", lRCHRES).FindData("Constituent", "P-TOT-IN")(0) End If lFoundTheTimeSeriesinWDMFile = False If lTimeSeries IsNot Nothing Then - TSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value - If TSTimeUnit <= 4 Then + lTSTimeUnit = lTimeSeries.Attributes.GetDefinedValue("Time Unit").Value + If lTSTimeUnit <= 4 Then lTimeSeries = Aggregate(lTimeSeries, atcTimeUnit.TUDay, 1, atcTran.TranSumDiv) lTimeSeries.Attributes.SetValue("YAxis", "Left") lTimeseriesGroup.Add(lTimeSeries) @@ -454,7 +454,7 @@ Public Module CookieCutterGraphs lCurve.Symbol.Type = SymbolType.None lCurve.Line.Color = Drawing.Color.FromName("green") lCurve.Line.Width = 2 - lCurve.Label.Text = "RES Standard (" & WQCriteriaInmgperliter & " mg/L)" + lCurve.Label.Text = "RES Standard (" & lWQCriteriaInmgperliter & " mg/L)" lCurve = lMainPane.CurveList.Item(1) lCurve.Line.IsVisible = True lCurve.Symbol.Type = SymbolType.None @@ -475,7 +475,7 @@ Public Module CookieCutterGraphs End If #End Region - Next RCHRES + Next lRCHRES End If @@ -490,17 +490,17 @@ Public Module CookieCutterGraphs ByVal aMemberName As String, ByVal aMemSub1 As Integer, ByVal aMemSub2 As Integer, ByRef aFoundTheTS As Boolean) As atcTimeseries Dim lDataSource As New atcDataSource - Dim aTimeSeries As atcTimeseries = Nothing + Dim lTimeSeries As atcTimeseries = Nothing aFoundTheTS = False Dim lDataID As Integer = 0 - For Each lconnection As HspfConnection In aHSPFUCI.Connections - If lconnection.Source.VolName = "RCHRES" AndAlso lconnection.Source.VolId = aRCHId AndAlso - lconnection.Source.Group = aGroupName AndAlso lconnection.Source.Member = aMemberName AndAlso - lconnection.Source.MemSub1 = aMemSub1 AndAlso lconnection.Source.MemSub2 = aMemSub2 AndAlso - lconnection.Target.VolName.Contains("WDM") Then - lDataID = lconnection.Target.VolId + For Each lConnection As HspfConnection In aHSPFUCI.Connections + If lConnection.Source.VolName = "RCHRES" AndAlso lConnection.Source.VolId = aRCHId AndAlso + lConnection.Source.Group = aGroupName AndAlso lConnection.Source.Member = aMemberName AndAlso + lConnection.Source.MemSub1 = aMemSub1 AndAlso lConnection.Source.MemSub2 = aMemSub2 AndAlso + lConnection.Target.VolName.Contains("WDM") Then + lDataID = lConnection.Target.VolId For i As Integer = 0 To aHSPFUCI.FilesBlock.Count - If aHSPFUCI.FilesBlock.Value(i).Typ = lconnection.Target.VolName Then + If aHSPFUCI.FilesBlock.Value(i).Typ = lConnection.Target.VolName Then Dim lFileName As String = AbsolutePath(aHSPFUCI.FilesBlock.Value(i).Name.Trim, CurDir()) lDataSource = atcDataManager.DataSourceBySpecification(lFileName) If lDataSource Is Nothing Then @@ -514,13 +514,13 @@ Public Module CookieCutterGraphs aFoundTheTS = True Exit For End If - Next lconnection + Next lConnection If lDataID > 0 Then - aTimeSeries = lDataSource.DataSets.FindData("ID", lDataID)(0) + lTimeSeries = lDataSource.DataSets.FindData("ID", lDataID)(0) aFoundTheTS = True End If - Return aTimeSeries + Return lTimeSeries End Function End Module diff --git a/HSPEXP/HSPFOutputReports.vb b/HSPEXP/HSPFOutputReports.vb index 66a2110a0..5466ab958 100644 --- a/HSPEXP/HSPFOutputReports.vb +++ b/HSPEXP/HSPFOutputReports.vb @@ -230,17 +230,17 @@ Module HSPFOutputReports End If 'Start QA/QC Report - Dim QAQCReportFile As New Text.StringBuilder + Dim lQAQCReportFile As New Text.StringBuilder If pModelQAQC Then Logger.Status("Beginning the QAQC Report") - QAQCReportFile.AppendLine("") - QAQCReportFile.AppendLine(QAReportStyle()) - QAQCReportFile.AppendLine("") - QAQCReportFile.AppendLine(QAGeneralModelInfo(aHspfUci, lRunMade)) - QAQCReportFile.AppendLine(QAModelAreaReport(aHspfUci, lOperationTypes)) - QAQCReportFile.AppendLine(QACheckHSPFParmValues(aHspfUci, lRunMade)) - QAQCReportFile.AppendLine(QACheckDiurnalPattern(aHspfUci, "DO")) - QAQCReportFile.AppendLine(QACheckDiurnalPattern(aHspfUci, "Water Temperature")) + lQAQCReportFile.AppendLine("") + lQAQCReportFile.AppendLine(QAReportStyle()) + lQAQCReportFile.AppendLine("") + lQAQCReportFile.AppendLine(QAGeneralModelInfo(aHspfUci, lRunMade)) + lQAQCReportFile.AppendLine(QAModelAreaReport(aHspfUci, lOperationTypes)) + lQAQCReportFile.AppendLine(QACheckHSPFParmValues(aHspfUci, lRunMade)) + lQAQCReportFile.AppendLine(QACheckDiurnalPattern(aHspfUci, "DO")) + lQAQCReportFile.AppendLine(QACheckDiurnalPattern(aHspfUci, "Water Temperature")) 'note that qa reports for loading rate, land use comparison, and storage are done in the wq section 'chuck likes the area report, we should still do it! @@ -348,7 +348,7 @@ Module HSPFOutputReports If pConstituents.Count > 0 Then 'includes qa reports for loading rate, land use comparison, and storage Dim lRet As Integer = InitializeMissingTimeseriesMessage() - DoWaterQualityReports(aHspfUci, lRunMade, lDateString, lOperationTypes, QAQCReportFile) + DoWaterQualityReports(aHspfUci, lRunMade, lDateString, lOperationTypes, lQAQCReportFile) Dim lMsg As String = MissingTimeseriesMessage() If lMsg.Length > 0 Then Logger.Msg(lMsg, "Missing HSPF Binary Output Timeseries") @@ -358,9 +358,9 @@ Module HSPFOutputReports If pModelQAQC Then 'Close out the QA report Logger.Status("Closing the QAQC Report") - QAQCReportFile.AppendLine("") - QAQCReportFile.AppendLine("") - File.WriteAllText(pOutFolderName & "\ModelQAQC.htm", QAQCReportFile.ToString()) + lQAQCReportFile.AppendLine("") + lQAQCReportFile.AppendLine("") + File.WriteAllText(pOutFolderName & "\ModelQAQC.htm", lQAQCReportFile.ToString()) End If Logger.Status(Now & " Output Written to " & pOutFolderName) @@ -567,7 +567,7 @@ Module HSPFOutputReports Logger.Status("Begin summary for " & lConstituent) Dim lConstituentName As String = "" Dim lActiveSections As New List(Of String) - Dim CheckQUALID As Boolean = False + Dim lCheckQUALID As Boolean = False Dim lGQALID As Integer = 0 Select Case lConstituent Case "Water" @@ -655,11 +655,11 @@ Module HSPFOutputReports 'LandLoadingReports generates a text file report as well as the info needed for the QA report ' "_Land_Loadings.txt" and "_Monthly_Land_Loadings.txt" - Dim LandLoadingReportForConstituents As DataTable = LandLoadingReports(pOutFolderName, lScenarioResults, aHspfUci, pBaseName, aRunMade, lConstituentName, lConstProperties, pSDateJ, pEDateJ, lGQALID) + Dim lLandLoadingReportForConstituents As DataTable = LandLoadingReports(pOutFolderName, lScenarioResults, aHspfUci, pBaseName, aRunMade, lConstituentName, lConstProperties, pSDateJ, pEDateJ, lGQALID) If pModelQAQC Then aQAQCReportFile.AppendLine("

" & lConstituent & " Loading Rate Analysis

") - aQAQCReportFile.AppendLine(QALoadingRateComparison(lConstituentName, LandLoadingReportForConstituents, aDateString)) + aQAQCReportFile.AppendLine(QALoadingRateComparison(lConstituentName, lLandLoadingReportForConstituents, aDateString)) End If 'ReachBudgetReports generates a text file report only @@ -751,8 +751,8 @@ Module HSPFOutputReports Else Logger.Dbg("The HBN file didn't have any data for the constituent " & lConstituent & " therefore the balance reports for " & lConstituent & " will not be generated. Make sure that HSPF run completed last time.") - Dim ans As Integer - ans = MsgBox("HBN files do not have any data. Constituent Balance reports will not be generated. " & + Dim lAns As Integer + lAns = MsgBox("HBN files do not have any data. Constituent Balance reports will not be generated. " & "Did uci file run properly last time?") End If For Each lTimeSeries As atcTimeseries In lScenarioResults.DataSets @@ -803,9 +803,9 @@ Module HSPFOutputReports ''' ''' Private Function QAReportStyle() As String - Dim ReportStyleText As New Text.StringBuilder - ReportStyleText.AppendLine("") - ReportStyleText.AppendLine( + Dim lReportStyleText As New Text.StringBuilder + lReportStyleText.AppendLine("") + lReportStyleText.AppendLine( "") - ReportStyleText.AppendLine("") - Return ReportStyleText.ToString + lReportStyleText.AppendLine("") + Return lReportStyleText.ToString End Function ''' @@ -839,18 +839,18 @@ Module HSPFOutputReports ''' Private Function QACheckHSPFParmValues(ByVal aUCI As HspfUci, ByVal aRunMade As String) As String ' , ByVal ParameterValues As DataTable) Logger.Status("Creating the QAQC Model Parameter Report") - Dim HSPFParmTable As XmlDocument = New XmlDocument() - Dim TableName As String = "" - Dim ParameterName As String - Dim MaxValue As Double = 0 - Dim MinValue As Double = 0 - Dim OperationType As String = "" - Dim ParameterInfo As New Text.StringBuilder + Dim lHSPFParmTable As XmlDocument = New XmlDocument() + Dim lTableName As String = "" + Dim lParameterName As String + Dim lMaxValue As Double = 0 + Dim lMinValue As Double = 0 + Dim lOperationType As String = "" + Dim lParameterInfo As New Text.StringBuilder Dim lTotalParmIssues As Integer = 0 - HSPFParmTable.LoadXml(My.Resources.HSPFParmValues) ' - ParameterInfo.AppendLine("

Model Parameter Value Analysis

") + lHSPFParmTable.LoadXml(My.Resources.HSPFParmValues) ' + lParameterInfo.AppendLine("

Model Parameter Value Analysis

") - Dim nodes As XmlNodeList = HSPFParmTable.DocumentElement.SelectNodes("Parm") + Dim lNodes As XmlNodeList = lHSPFParmTable.DocumentElement.SelectNodes("Parm") Dim lParameterViolationTable As DataTable lParameterViolationTable = New DataTable("ModelParameterInfo") Dim lColumn As DataColumn @@ -910,32 +910,32 @@ Module HSPFOutputReports lColumn.DataType = Type.GetType("System.Double") lParameterViolationTable.Columns.Add(lColumn) - Dim lrow As DataRow + Dim lRow As DataRow - For Each node As XmlNode In nodes - OperationType = node.SelectSingleNode("OPNTYPE").InnerText - TableName = node.SelectSingleNode("TABLE").InnerText - ParameterName = node.SelectSingleNode("ParameterName").InnerText - Logger.Status("Creating the QAQC Model Parameter Report -- Examining Table " & TableName) + For Each lNode As XmlNode In lNodes + lOperationType = lNode.SelectSingleNode("OPNTYPE").InnerText + lTableName = lNode.SelectSingleNode("TABLE").InnerText + lParameterName = lNode.SelectSingleNode("ParameterName").InnerText + Logger.Status("Creating the QAQC Model Parameter Report -- Examining Table " & lTableName) 'If ParameterName = "TAUCS" Then Stop - Dim IsMonthlyValuePossible As Integer + Dim lIsMonthlyValuePossible As Integer Try - IsMonthlyValuePossible = CInt(node.SelectSingleNode("IsMonthlyPossible").InnerText) + lIsMonthlyValuePossible = CInt(lNode.SelectSingleNode("IsMonthlyPossible").InnerText) Catch - IsMonthlyValuePossible = 0 + lIsMonthlyValuePossible = 0 End Try Dim lActivityFlag As String = "" - lActivityFlag = node.SelectSingleNode("ACTIVITYFLAG").InnerText + lActivityFlag = lNode.SelectSingleNode("ACTIVITYFLAG").InnerText If lActivityFlag.Length = 0 Then Continue For - Dim MonthlyFlagTable As String = node.SelectSingleNode("FlagTable").InnerText - Dim MonthlyFlagParm As String = node.SelectSingleNode("FlagParm").InnerText - Dim MonthlyParmTable As String = node.SelectSingleNode("MonthlyParmTable").InnerText + Dim lMonthlyFlagTable As String = lNode.SelectSingleNode("FlagTable").InnerText + Dim lMonthlyFlagParm As String = lNode.SelectSingleNode("FlagParm").InnerText + Dim lMonthlyParmTable As String = lNode.SelectSingleNode("MonthlyParmTable").InnerText Dim lQualConstituentName As String = "" - Logger.Dbg("Looking at Table " & TableName & "Parameter " & ParameterName) - lQualConstituentName = node.SelectSingleNode("ConstituentName").InnerText + Logger.Dbg("Looking at Table " & lTableName & "Parameter " & lParameterName) + lQualConstituentName = lNode.SelectSingleNode("ConstituentName").InnerText Dim lQUALID As Integer = 0 If lQualConstituentName.Length > 0 Then Select Case lQualConstituentName 'Can look for QUALID fronm the UCI file also. @@ -951,22 +951,22 @@ Module HSPFOutputReports End If Try - MaxValue = CDbl(node.SelectSingleNode("Max").InnerText) - MinValue = CDbl(node.SelectSingleNode("Min").InnerText) + lMaxValue = CDbl(lNode.SelectSingleNode("Max").InnerText) + lMinValue = CDbl(lNode.SelectSingleNode("Min").InnerText) Catch Continue For End Try Dim lMessageCountPerParameter As Integer = 0 - For Each loperation As HspfOperation In aUCI.OpnBlks(OperationType).Ids + For Each lOperation As HspfOperation In aUCI.OpnBlks(lOperationType).Ids 'Looping through each operation for a specific parameter Dim lActivityFlagValue As Integer = 0 - lActivityFlagValue = loperation.Tables("ACTIVITY").Parms(lActivityFlag).Value + lActivityFlagValue = lOperation.Tables("ACTIVITY").Parms(lActivityFlag).Value If lActivityFlagValue = 0 Then Continue For Dim lMonthlyFlagValue As Integer = 0 - If IsMonthlyValuePossible = 1 Then + If lIsMonthlyValuePossible = 1 Then Try - lMonthlyFlagValue = loperation.Tables(MonthlyFlagTable).Parms(MonthlyFlagParm).Value + lMonthlyFlagValue = lOperation.Tables(lMonthlyFlagTable).Parms(lMonthlyFlagParm).Value Catch lMonthlyFlagValue = 0 End Try @@ -974,87 +974,87 @@ Module HSPFOutputReports Try If lQUALID = 0 Then If lMonthlyFlagValue = 0 Then - Dim lParmValue As Double = loperation.Tables(TableName).Parms(ParameterName).Value + Dim lParmValue As Double = lOperation.Tables(lTableName).Parms(lParameterName).Value Dim lComment As String = "" 'If ParameterName = "TAUCD" Then Stop - If ParameterName = "TAUCD" AndAlso loperation.Tables(TableName).Parms("TAUCS").Value < lParmValue Then + If lParameterName = "TAUCD" AndAlso lOperation.Tables(lTableName).Parms("TAUCS").Value < lParmValue Then lComment = "TAUCD is greater than TAUCS." End If - If (ParameterName = "TAUCS" OrElse ParameterName = "TAUCD") AndAlso TableName = "SILT-CLAY-PM" AndAlso - loperation.Tables("SILT-CLAY-PM:2").Parms(ParameterName).Value > lParmValue Then - lComment &= ParameterName & " for clay is greater than " & ParameterName & " for silt." + If (lParameterName = "TAUCS" OrElse lParameterName = "TAUCD") AndAlso lTableName = "SILT-CLAY-PM" AndAlso + lOperation.Tables("SILT-CLAY-PM:2").Parms(lParameterName).Value > lParmValue Then + lComment &= lParameterName & " for clay is greater than " & lParameterName & " for silt." End If - If lParmValue > MaxValue OrElse lParmValue < MinValue OrElse lComment.Length > 0 Then - lrow = lParameterViolationTable.NewRow - lrow("OPN_TYPE") = OperationType - lrow("OPN_NUM") = loperation.Id - lrow("OPN_INFO") = loperation.Description - lrow("PARM_TABLE") = TableName - lrow("PARM_NAME") = ParameterName - lrow("ConstName") = lComment - lrow("ModelValue") = lParmValue - lrow("TypicalMin") = MinValue - lrow("TypicalMax") = MaxValue - lParameterViolationTable.Rows.Add(lrow) + If lParmValue > lMaxValue OrElse lParmValue < lMinValue OrElse lComment.Length > 0 Then + lRow = lParameterViolationTable.NewRow + lRow("OPN_TYPE") = lOperationType + lRow("OPN_NUM") = lOperation.Id + lRow("OPN_INFO") = lOperation.Description + lRow("PARM_TABLE") = lTableName + lRow("PARM_NAME") = lParameterName + lRow("ConstName") = lComment + lRow("ModelValue") = lParmValue + lRow("TypicalMin") = lMinValue + lRow("TypicalMax") = lMaxValue + lParameterViolationTable.Rows.Add(lRow) End If Else - If MonthlyParmTable = "MON-LGTP2" AndAlso loperation.Tables("PSTEMP-PARM1").Parms("TSOPFG").Value = 1 Then + If lMonthlyParmTable = "MON-LGTP2" AndAlso lOperation.Tables("PSTEMP-PARM1").Parms("TSOPFG").Value = 1 Then Exit For End If - For Each MonthlyParm As HspfParm In loperation.Tables(MonthlyParmTable).Parms - If MonthlyParm.Value < MinValue OrElse MonthlyParm.Value > MaxValue Then - lrow = lParameterViolationTable.NewRow - lrow("OPN_TYPE") = OperationType - lrow("OPN_NUM") = loperation.Id - lrow("OPN_INFO") = loperation.Description - lrow("PARM_TABLE") = MonthlyParmTable - lrow("PARM_NAME") = MonthlyParm.Name - lrow("ConstName") = "" - lrow("ModelValue") = MonthlyParm.Value - lrow("TypicalMin") = MinValue - lrow("TypicalMax") = MaxValue - lParameterViolationTable.Rows.Add(lrow) + For Each MonthlyParm As HspfParm In lOperation.Tables(lMonthlyParmTable).Parms + If MonthlyParm.Value < lMinValue OrElse MonthlyParm.Value > lMaxValue Then + lRow = lParameterViolationTable.NewRow + lRow("OPN_TYPE") = lOperationType + lRow("OPN_NUM") = lOperation.Id + lRow("OPN_INFO") = lOperation.Description + lRow("PARM_TABLE") = lMonthlyParmTable + lRow("PARM_NAME") = MonthlyParm.Name + lRow("ConstName") = "" + lRow("ModelValue") = MonthlyParm.Value + lRow("TypicalMin") = lMinValue + lRow("TypicalMax") = lMaxValue + lParameterViolationTable.Rows.Add(lRow) End If Next End If Else - Dim lTempTABLEName As String = TableName - If lQUALID > 1 Then lTempTABLEName = TableName & ":" & lQUALID + Dim lTempTABLEName As String = lTableName + If lQUALID > 1 Then lTempTABLEName = lTableName & ":" & lQUALID If lMonthlyFlagValue = 0 Then - Dim lParmValue As Double = loperation.Tables(lTempTABLEName).Parms(ParameterName).Value - If lParmValue > MaxValue OrElse lParmValue < MinValue Then - lrow = lParameterViolationTable.NewRow - lrow("OPN_TYPE") = OperationType - lrow("OPN_NUM") = loperation.Id - lrow("OPN_INFO") = loperation.Description - lrow("PARM_TABLE") = lTempTABLEName - lrow("PARM_NAME") = ParameterName - lrow("ConstName") = lQualConstituentName - lrow("ModelValue") = lParmValue - lrow("TypicalMin") = MinValue - lrow("TypicalMax") = MaxValue - lParameterViolationTable.Rows.Add(lrow) + Dim lParmValue As Double = lOperation.Tables(lTempTABLEName).Parms(lParameterName).Value + If lParmValue > lMaxValue OrElse lParmValue < lMinValue Then + lRow = lParameterViolationTable.NewRow + lRow("OPN_TYPE") = lOperationType + lRow("OPN_NUM") = lOperation.Id + lRow("OPN_INFO") = lOperation.Description + lRow("PARM_TABLE") = lTempTABLEName + lRow("PARM_NAME") = lParameterName + lRow("ConstName") = lQualConstituentName + lRow("ModelValue") = lParmValue + lRow("TypicalMin") = lMinValue + lRow("TypicalMax") = lMaxValue + lParameterViolationTable.Rows.Add(lRow) End If Else - Dim lTempMonthlyTable As String = MonthlyParmTable - If lQUALID > 1 Then lTempMonthlyTable = MonthlyParmTable & ":" & lQUALID - For Each MonthlyParm As HspfParm In loperation.Tables(lTempMonthlyTable).Parms - If MonthlyParm.Value < MinValue OrElse MonthlyParm.Value > MaxValue Then + Dim lTempMonthlyTable As String = lMonthlyParmTable + If lQUALID > 1 Then lTempMonthlyTable = lMonthlyParmTable & ":" & lQUALID + For Each MonthlyParm As HspfParm In lOperation.Tables(lTempMonthlyTable).Parms + If MonthlyParm.Value < lMinValue OrElse MonthlyParm.Value > lMaxValue Then 'lMonthlyParmCount += 1 - lrow = lParameterViolationTable.NewRow - lrow("OPN_TYPE") = OperationType - lrow("OPN_NUM") = loperation.Id - lrow("OPN_INFO") = loperation.Description - lrow("PARM_TABLE") = lTempMonthlyTable - lrow("PARM_NAME") = MonthlyParm.Name - lrow("ConstName") = lQualConstituentName - lrow("ModelValue") = MonthlyParm.Value - lrow("TypicalMin") = MinValue - lrow("TypicalMax") = MaxValue - lParameterViolationTable.Rows.Add(lrow) + lRow = lParameterViolationTable.NewRow + lRow("OPN_TYPE") = lOperationType + lRow("OPN_NUM") = lOperation.Id + lRow("OPN_INFO") = lOperation.Description + lRow("PARM_TABLE") = lTempMonthlyTable + lRow("PARM_NAME") = MonthlyParm.Name + lRow("ConstName") = lQualConstituentName + lRow("ModelValue") = MonthlyParm.Value + lRow("TypicalMin") = lMinValue + lRow("TypicalMax") = lMaxValue + lParameterViolationTable.Rows.Add(lRow) End If Next @@ -1064,7 +1064,7 @@ Module HSPFOutputReports Catch ex As Exception End Try - Next loperation + Next lOperation Next Logger.Status("Creating the QAQC Model Parameter Report") @@ -1075,7 +1075,7 @@ Module HSPFOutputReports lRCHRES.Tables("NUT-FLAGS").Parms("ADPOFG").Value = 0) Then lReachesWithAdsDepoIssue += 1 If lReachesWithAdsDepoIssue > 1 Then - ParameterInfo.AppendLine("

At least one reach simulates nutrients but the adsoprtion and desorption from bed sediment is not simulated.

") + lParameterInfo.AppendLine("

At least one reach simulates nutrients but the adsoprtion and desorption from bed sediment is not simulated.

") Exit For End If End If @@ -1083,32 +1083,32 @@ Module HSPFOutputReports If lParameterViolationTable.Rows.Count = 0 AndAlso lReachesWithAdsDepoIssue = 0 Then - ParameterInfo.AppendLine("

All the tested parameters are within the typical range.

") + lParameterInfo.AppendLine("

All the tested parameters are within the typical range.

") End If If lParameterViolationTable.Rows.Count > 0 And lParameterViolationTable.Rows.Count <= 10 Then - ParameterInfo.AppendLine("

Following parameters were beyond the typical range.") - ParameterInfo.Append(ConvertToHtmlFile(lParameterViolationTable)) + lParameterInfo.AppendLine("

Following parameters were beyond the typical range.") + lParameterInfo.Append(ConvertToHtmlFile(lParameterViolationTable)) End If If lParameterViolationTable.Rows.Count > 10 Then Dim lXSLFile As StreamWriter = File.CreateText(Path.Combine(pOutFolderName, "ParameterTableTemplate.xsl")) lXSLFile.Write(My.Resources.LimitViolatingParameterTemplate) lXSLFile.Close() - Dim lParameterInfo As StreamWriter = File.CreateText(Path.Combine(pOutFolderName, "ParameterReport.xml")) - lParameterInfo.WriteLine("") - lParameterInfo.WriteLine("") - lParameterViolationTable.WriteXml(lParameterInfo, XmlWriteMode.IgnoreSchema) - lParameterInfo.Close() + Dim lParameterInfoX As StreamWriter = File.CreateText(Path.Combine(pOutFolderName, "ParameterReport.xml")) + lParameterInfoX.WriteLine("") + lParameterInfoX.WriteLine("") + lParameterViolationTable.WriteXml(lParameterInfoX, XmlWriteMode.IgnoreSchema) + lParameterInfoX.Close() - ParameterInfo.AppendLine("

More than 10 cases were found where the model parameter values were outside the typical range. The first 10 cases are listed below and all the + lParameterInfo.AppendLine("

More than 10 cases were found where the model parameter values were outside the typical range. The first 10 cases are listed below and all the range violations are listed in a separate xml table.

") - ParameterInfo.Append(ConvertToHtmlFile(lParameterViolationTable, 10)) + lParameterInfo.Append(ConvertToHtmlFile(lParameterViolationTable, 10)) End If - Return ParameterInfo.ToString + Return lParameterInfo.ToString End Function ''' @@ -1117,75 +1117,75 @@ Module HSPFOutputReports ''' ''' Private Function QAGeneralModelInfo(ByVal aUCI As HspfUci, ByVal aRunMade As String) As String - Dim GeneralModelInfoText As New Text.StringBuilder - GeneralModelInfoText.AppendLine("

HSPF Model QA QC Report

") - GeneralModelInfoText.AppendLine("

Disclaimer

") - GeneralModelInfoText.AppendLine("

The QA/QC module assumes that the model is run in English Units and the units of nutrients + Dim lGeneralModelInfoText As New Text.StringBuilder + lGeneralModelInfoText.AppendLine("

HSPF Model QA QC Report

") + lGeneralModelInfoText.AppendLine("

Disclaimer

") + lGeneralModelInfoText.AppendLine("

The QA/QC module assumes that the model is run in English Units and the units of nutrients are in lbs. This report provides a set of checks for HSPF hydrology and water quality models that are based on generalized professional judgment. Unique settings and conditions can lead to hydrologic and water quality complexities that do not conform to the judgments that are embedded in this module. Furthermore, the set of aspects for which checks have been included is not all-inclusive.

") - GeneralModelInfoText.AppendLine("

This module also assumes that the first four water quality constituents simulated on the land are + lGeneralModelInfoText.AppendLine("

This module also assumes that the first four water quality constituents simulated on the land are ammonia (NH3+NH4), nitrate as nitrogen (NO3), orthophosphorus as phosphorus (ORTHO P), and biochemical oxygen demand (BOD) in the order that they are listed here with the QUALID as it is listed in the parenthesis.

") - GeneralModelInfoText.AppendLine("

How to use the QA/QC Report

") - GeneralModelInfoText.AppendLine("

The sequence of messages that are contained in the QA/QC Report for any UCI and its + lGeneralModelInfoText.AppendLine("

How to use the QA/QC Report

") + lGeneralModelInfoText.AppendLine("

The sequence of messages that are contained in the QA/QC Report for any UCI and its resulting output will flag aspects of the model input and output that are considered nontypical, thereby providing the modeler with a checklist of items that warrant either re-affirmation or modification, either by refining aspects of the model input or undertaking additional calibration.

") - GeneralModelInfoText.AppendLine("

Iterative use of the QA/QC module should result in decreasing the number of instances + lGeneralModelInfoText.AppendLine("

Iterative use of the QA/QC module should result in decreasing the number of instances of nontypical designations or results. The aspects that remain flagged in a model run that is considered a final calibration will document nuances of the model that should be explained in the modeling application report.

") - GeneralModelInfoText.AppendLine("

General Model Information

") - GeneralModelInfoText.AppendLine("") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" " + lGeneralModelInfoText.AppendLine(lQAQCAnalysis) + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine("
Model File Name" & aUCI.Name & "
Model Span" & aUCI.GlobalBlock.SDate(0) & "/" & aUCI.GlobalBlock.SDate(1) & "/" & aUCI.GlobalBlock.SDate(2) & " - " & + lGeneralModelInfoText.AppendLine("

General Model Information

") + lGeneralModelInfoText.AppendLine("") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine(" ") - Dim QAQCAnalysis As String = " ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + lGeneralModelInfoText.AppendLine(" ") + Dim lQAQCAnalysis As String = " " - GeneralModelInfoText.AppendLine(QAQCAnalysis) - GeneralModelInfoText.AppendLine(" ") - GeneralModelInfoText.AppendLine("
Model File Name" & aUCI.Name & "
Model Span" & aUCI.GlobalBlock.SDate(0) & "/" & aUCI.GlobalBlock.SDate(1) & "/" & aUCI.GlobalBlock.SDate(2) & " - " & aUCI.GlobalBlock.EDate(0) & "/" & aUCI.GlobalBlock.EDate(1) & "/" & aUCI.GlobalBlock.EDate(2) & "
Model Last Run time " & aRunMade & "
QA QC Report generated on " & DateTime.Now & "
HSPEXP+ Version 3.1
Sections listed in this reportParameter Values, Area, Diurnal Patterns" + lGeneralModelInfoText.AppendLine("
Model Last Run time " & aRunMade & "
QA QC Report generated on " & DateTime.Now & "
HSPEXP+ Version 3.1
Sections listed in this reportParameter Values, Area, Diurnal Patterns" If pConstituents.Contains("Water") Then - QAQCAnalysis &= ", Water" + lQAQCAnalysis &= ", Water" End If If pConstituents.Contains("Sediment") Then - QAQCAnalysis &= ", Sediment" + lQAQCAnalysis &= ", Sediment" End If If pConstituents.Contains("TN") Then - QAQCAnalysis &= ", Total Nitrogen" + lQAQCAnalysis &= ", Total Nitrogen" End If If pConstituents.Contains("TP") Then - QAQCAnalysis &= ", Total Phosphorus" + lQAQCAnalysis &= ", Total Phosphorus" End If If pConstituents.Contains("BOD-Labile") Then - QAQCAnalysis &= ", BOD-Labile" + lQAQCAnalysis &= ", BOD-Labile" End If - QAQCAnalysis &= "
") - Return GeneralModelInfoText.ToString + lQAQCAnalysis &= "
") + Return lGeneralModelInfoText.ToString End Function ''' @@ -1195,7 +1195,7 @@ Module HSPFOutputReports ''' ''' Private Function QAModelAreaReport(ByVal aUCI As HspfUci, ByVal aOperationTypes As atcCollection) As String - Dim ModelAreaReportTable As String = "" + Dim lModelAreaReportTable As String = "" Dim lOutletLocations As New atcCollection Dim lCalibrationLocations As New atcCollection Dim lLocationsToOutput As New atcCollection @@ -1249,132 +1249,132 @@ Module HSPFOutputReports End If Next - Dim AreaInfo As New Text.StringBuilder - AreaInfo.AppendLine("

Model Area Table

") + Dim lAreaInfo As New Text.StringBuilder + lAreaInfo.AppendLine("

Model Area Table

") If lCalibrationLocations.Count > 0 Then - AreaInfo.AppendLine("

" & lCalibrationLocations.Count & " Calibration Locations and " & lOutletLocations.Count & " Outlet Locations

") + lAreaInfo.AppendLine("

" & lCalibrationLocations.Count & " Calibration Locations and " & lOutletLocations.Count & " Outlet Locations

") Else If lOutletLocations.Count = 1 Then - AreaInfo.AppendLine("

One Outlet Location

") + lAreaInfo.AppendLine("

One Outlet Location

") Else - AreaInfo.AppendLine("

" & lOutletLocations.Count & " Outlet Locations

") + lAreaInfo.AppendLine("

" & lOutletLocations.Count & " Outlet Locations

") End If End If 'lLocationsToOutput.Add("R:1") 'for debug For Each lLocation In lLocationsToOutput - AreaInfo.AppendLine("

") + lAreaInfo.AppendLine("

") If lCalibrationLocations.Contains(lLocation) Then - AreaInfo.AppendLine("

Calibration Location " & lLocation) + lAreaInfo.AppendLine("

Calibration Location " & lLocation) Else - AreaInfo.AppendLine("

Outlet Location " & lLocation) + lAreaInfo.AppendLine("

Outlet Location " & lLocation) End If Dim lAreaTable As DataTable = AreaReportInTableFormat(aUCI, aOperationTypes, lLocation) - AreaInfo.Append(ConvertToHtmlFile(lAreaTable)) + lAreaInfo.Append(ConvertToHtmlFile(lAreaTable)) Next - ModelAreaReportTable = AreaInfo.ToString + lModelAreaReportTable = lAreaInfo.ToString - Return ModelAreaReportTable + Return lModelAreaReportTable End Function Private Function QALoadingRateComparison(ByVal aConstituentName As String, ByVal aLandLoadingConstReport As DataTable, ByVal aDateString As String) As String Logger.Status("Creating the QAQC Loading Rate Comparison Report") - Dim OverAllComments As New Text.StringBuilder - Dim LoadingRateComments As New Text.StringBuilder - Dim newColumn As DataColumn - newColumn = New DataColumn() - newColumn.DataType = Type.GetType("System.String") - newColumn.ColumnName = "genLandUse" - newColumn.Caption = "Generalized Land Use" - aLandLoadingConstReport.Columns.Add(newColumn) - Dim UCILandUse As String = "" - Dim ListofLandUsesInUCI As New List(Of String) - Dim OpTypeNumber As String = "" - For Each row As DataRow In aLandLoadingConstReport.Rows - UCILandUse = row("OpDesc") - OpTypeNumber = row("OpTypeNumber") - If OpTypeNumber.StartsWith("I:") Then - row("genLandUse") = "Impervious" - If Not ListofLandUsesInUCI.Contains(row("genLandUse")) And Not row("genLandUse") = "Unknown" Then - ListofLandUsesInUCI.Add(row("genLandUse")) + Dim lOverAllComments As New Text.StringBuilder + Dim lLoadingRateComments As New Text.StringBuilder + Dim lNewColumn As DataColumn + lNewColumn = New DataColumn() + lNewColumn.DataType = Type.GetType("System.String") + lNewColumn.ColumnName = "genLandUse" + lNewColumn.Caption = "Generalized Land Use" + aLandLoadingConstReport.Columns.Add(lNewColumn) + Dim lUCILandUse As String = "" + Dim lListofLandUsesInUCI As New List(Of String) + Dim lOpTypeNumber As String = "" + For Each lRow As DataRow In aLandLoadingConstReport.Rows + lUCILandUse = lRow("OpDesc") + lOpTypeNumber = lRow("OpTypeNumber") + If lOpTypeNumber.StartsWith("I:") Then + lRow("genLandUse") = "Impervious" + If Not lListofLandUsesInUCI.Contains(lRow("genLandUse")) And Not lRow("genLandUse") = "Unknown" Then + lListofLandUsesInUCI.Add(lRow("genLandUse")) End If Continue For End If - row("genLandUse") = FindGeneralLandUse(UCILandUse) + lRow("genLandUse") = FindGeneralLandUse(lUCILandUse) - If Not ListofLandUsesInUCI.Contains(row("genLandUse")) And Not row("genLandUse") = "Unknown" Then - ListofLandUsesInUCI.Add(row("genLandUse")) + If Not lListofLandUsesInUCI.Contains(lRow("genLandUse")) And Not lRow("genLandUse") = "Unknown" Then + lListofLandUsesInUCI.Add(lRow("genLandUse")) End If Next Dim lSelectExpression As String = "" 'LoadingRateComments.AppendLine("

    ") - Dim IsWetlandALanduse As Boolean = False - If ListofLandUsesInUCI.Contains("Wetland") Then IsWetlandALanduse = True + Dim lIsWetlandALanduse As Boolean = False + If lListofLandUsesInUCI.Contains("Wetland") Then lIsWetlandALanduse = True - For Each landuse As String In ListofLandUsesInUCI - Dim TextFromFunction As String = String.Empty + For Each lLanduse As String In lListofLandUsesInUCI + Dim lTextFromFunction As String = String.Empty Select Case aConstituentName Case "WAT" - TextFromFunction = CheckIrrigation(landuse, aLandLoadingConstReport) - TextFromFunction &= CheckETIssues(landuse, aLandLoadingConstReport, ListofLandUsesInUCI, IsWetlandALanduse) - TextFromFunction &= CheckRunoff(landuse, aLandLoadingConstReport, ListofLandUsesInUCI) + lTextFromFunction = CheckIrrigation(lLanduse, aLandLoadingConstReport) + lTextFromFunction &= CheckETIssues(lLanduse, aLandLoadingConstReport, lListofLandUsesInUCI, lIsWetlandALanduse) + lTextFromFunction &= CheckRunoff(lLanduse, aLandLoadingConstReport, lListofLandUsesInUCI) Case "TN" - TextFromFunction &= CheckNutrientLoading(landuse, "NO3", ListofLandUsesInUCI, aLandLoadingConstReport) - TextFromFunction &= CheckNutrientLoading(landuse, "TAM", ListofLandUsesInUCI, aLandLoadingConstReport) - TextFromFunction &= CheckNutrientLoading(landuse, "TN", ListofLandUsesInUCI, aLandLoadingConstReport) + lTextFromFunction &= CheckNutrientLoading(lLanduse, "NO3", lListofLandUsesInUCI, aLandLoadingConstReport) + lTextFromFunction &= CheckNutrientLoading(lLanduse, "TAM", lListofLandUsesInUCI, aLandLoadingConstReport) + lTextFromFunction &= CheckNutrientLoading(lLanduse, "TN", lListofLandUsesInUCI, aLandLoadingConstReport) Case "TP" - TextFromFunction &= CheckNutrientLoading(landuse, "PO4", ListofLandUsesInUCI, aLandLoadingConstReport) - TextFromFunction &= CheckNutrientLoading(landuse, "TP", ListofLandUsesInUCI, aLandLoadingConstReport) + lTextFromFunction &= CheckNutrientLoading(lLanduse, "PO4", lListofLandUsesInUCI, aLandLoadingConstReport) + lTextFromFunction &= CheckNutrientLoading(lLanduse, "TP", lListofLandUsesInUCI, aLandLoadingConstReport) Case "BOD-Labile" - TextFromFunction &= CheckNutrientLoading(landuse, "BOD-Labile", ListofLandUsesInUCI, aLandLoadingConstReport) + lTextFromFunction &= CheckNutrientLoading(lLanduse, "BOD-Labile", lListofLandUsesInUCI, aLandLoadingConstReport) Case "SED" - TextFromFunction &= CheckTotalSedimentErosion(landuse, ListofLandUsesInUCI, aLandLoadingConstReport) + lTextFromFunction &= CheckTotalSedimentErosion(lLanduse, lListofLandUsesInUCI, aLandLoadingConstReport) End Select - If TextFromFunction.Length > 0 Then - LoadingRateComments.AppendLine(TextFromFunction) + If lTextFromFunction.Length > 0 Then + lLoadingRateComments.AppendLine(lTextFromFunction) End If Next If aConstituentName = "BOD-Labile" Then - OverAllComments.AppendLine("

    BOD-Labile only includes labile fraction of total organic that enters the RCHRES as OXIF 2 Member of Group INFLOW.

    ") + lOverAllComments.AppendLine("

    BOD-Labile only includes labile fraction of total organic that enters the RCHRES as OXIF 2 Member of Group INFLOW.

    ") End If - If LoadingRateComments.Length > 0 Then - OverAllComments.AppendLine("

    Non-typical behaviors that were noticed in the model.

    ") - OverAllComments.AppendLine("
      ") - OverAllComments.Append(LoadingRateComments) - OverAllComments.AppendLine("
    ") + If lLoadingRateComments.Length > 0 Then + lOverAllComments.AppendLine("

    Non-typical behaviors that were noticed in the model.

    ") + lOverAllComments.AppendLine("
      ") + lOverAllComments.Append(lLoadingRateComments) + lOverAllComments.AppendLine("
    ") End If Select Case aConstituentName Case "WAT" - OverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on annual runoff from each land use.

    ") - OverAllComments.AppendLine("") + lOverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on annual runoff from each land use.

    ") + lOverAllComments.AppendLine("") Case "SED" - OverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on sediment loading rate from each land use.

    ") - OverAllComments.AppendLine("") + lOverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on sediment loading rate from each land use.

    ") + lOverAllComments.AppendLine("") Case "TN" - OverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on total nitrogen loading rate from each land use.

    ") - OverAllComments.AppendLine("") + lOverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on total nitrogen loading rate from each land use.

    ") + lOverAllComments.AppendLine("") Case "TP" - OverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on total phosphorus loading rate from each land use.

    ") - OverAllComments.AppendLine("") + lOverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on total phosphorus loading rate from each land use.

    ") + lOverAllComments.AppendLine("") Case "BOD-Labile" - OverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on biochemical oxygen demand (labile only) loading rate from each land use.

    ") - OverAllComments.AppendLine("") + lOverAllComments.AppendLine("

    Refer to the following Box-Whisker plot for more details on biochemical oxygen demand (labile only) loading rate from each land use.

    ") + lOverAllComments.AppendLine("") End Select - OverAllComments.AppendLine("

    The box-whisker plot shows the variation in average annual loading among the model segments within each land use category. If there is only one + lOverAllComments.AppendLine("

    The box-whisker plot shows the variation in average annual loading among the model segments within each land use category. If there is only one model segment, there will be only a single tick at the average annual load for that land use. If there are multiple model segments, the tick will be at the median, and the extent of the box will indicate the interquartile range (25th and 75th percentile). The whiskers extend to the highest and lowest average annual loading rate for the segments of that land use classification.

    ") - Return OverAllComments.ToString + Return lOverAllComments.ToString End Function ''' @@ -1383,42 +1383,42 @@ Module HSPFOutputReports ''' ''' Private Function FindGeneralLandUse(ByVal aUCILandUse As String) As String - Dim GeneralLandUse As String = "Unknown" + Dim lGeneralLandUse As String = "Unknown" If aUCILandUse.ToLower.Contains("forest") Then - GeneralLandUse = "Forest" - Return GeneralLandUse + lGeneralLandUse = "Forest" + Return lGeneralLandUse ElseIf aUCILandUse.ToLower.Contains("crop") OrElse aUCILandUse.ToLower.Contains("agric") Then - GeneralLandUse = "Ag/Other" - Return GeneralLandUse + lGeneralLandUse = "Ag/Other" + Return lGeneralLandUse ElseIf aUCILandUse.ToLower.Contains("urban") OrElse aUCILandUse.ToLower.Contains("develop") Then - GeneralLandUse = "Urban" - Return GeneralLandUse + lGeneralLandUse = "Urban" + Return lGeneralLandUse End If - Dim LanduseMappings As XmlDocument = New XmlDocument - LanduseMappings.LoadXml(My.Resources.LandUseNames_Mappings) - Dim nodes As XmlNodeList = LanduseMappings.DocumentElement.SelectNodes("landusename") - For Each node As XmlNode In nodes + Dim lLanduseMappings As XmlDocument = New XmlDocument + lLanduseMappings.LoadXml(My.Resources.LandUseNames_Mappings) + Dim lNodes As XmlNodeList = lLanduseMappings.DocumentElement.SelectNodes("landusename") + For Each node As XmlNode In lNodes If node.SelectSingleNode("UCILandUse").InnerText = aUCILandUse Then Return node.SelectSingleNode("GeneralLandUse").InnerText End If Next - Return GeneralLandUse + Return lGeneralLandUse End Function Private Function CheckIrrigation(ByVal aLanduse As String, ByVal aLandLoadingConstReport As DataTable) As String If aLanduse = "Ag/Other" OrElse aLanduse = "Impervious" Then Return String.Empty - Dim IrrigationStatement As String = String.Empty - Dim IrrigationApp As Double = 0.0 + Dim lIrrigationStatement As String = String.Empty + Dim lIrrigationApp As Double = 0.0 Dim lSelectExpression As String = "genLandUse = '" & aLanduse & "' And Year = 'SumAnnual'" Try - IrrigationApp = aLandLoadingConstReport.Compute("AVG(IRRAPP6)", lSelectExpression) + lIrrigationApp = aLandLoadingConstReport.Compute("AVG(IRRAPP6)", lSelectExpression) Catch End Try - If IrrigationApp > 0 Then + If lIrrigationApp > 0 Then Return "
  • " & aLanduse & " land use has irrigation application.
  • " Else Return String.Empty @@ -1435,64 +1435,64 @@ Module HSPFOutputReports ''' Private Function CheckRunoff(ByVal aLanduse As String, ByVal aLandLoadingConstReport As DataTable, ByVal aListofLandUsesinUCI As List(Of String)) As String Dim lSelectExpression As String = "genLandUse = '" & aLanduse & "' And Year = 'SumAnnual'" - Dim TotalOutFlow As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression) - Dim TotalSurfaceRunoff As Double = aLandLoadingConstReport.Compute("AVG(SURO)", lSelectExpression) - Dim CheckRunoffStatement As New Text.StringBuilder + Dim lTotalOutFlow As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression) + Dim lTotalSurfaceRunoff As Double = aLandLoadingConstReport.Compute("AVG(SURO)", lSelectExpression) + Dim lCheckRunoffStatement As New Text.StringBuilder If aLanduse = "Impervious" Then - For Each landuse2 As String In aListofLandUsesinUCI - If landuse2 = "Impervious" Then Continue For - Dim SelectExpression2 As String = "genLandUse = '" & landuse2 & "' And Year = 'SumAnnual'" - Dim TotalOutflow2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", SelectExpression2) - If TotalOutflow2 > TotalOutFlow Then - CheckRunoffStatement.AppendLine("
  • " & landuse2 & " has greater runoff than Impervious area.
  • ") + For Each lLanduse2 As String In aListofLandUsesinUCI + If lLanduse2 = "Impervious" Then Continue For + Dim lSelectExpression2 As String = "genLandUse = '" & lLanduse2 & "' And Year = 'SumAnnual'" + Dim lTotalOutflow2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression2) + If lTotalOutflow2 > lTotalOutFlow Then + lCheckRunoffStatement.AppendLine("
  • " & lLanduse2 & " has greater runoff than Impervious area.
  • ") End If Next Else - Dim TotalBaseFlow As Double = aLandLoadingConstReport.Compute("AVG(IFWO)", lSelectExpression) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression) - Dim TotalLZET As Double = aLandLoadingConstReport.Compute("AVG(LZET)", lSelectExpression) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression) - Dim TotalUZET As Double = aLandLoadingConstReport.Compute("AVG(UZET)", lSelectExpression) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression) - Dim TotalAGWET As Double = aLandLoadingConstReport.Compute("AVG(AGWET)", lSelectExpression) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression) + Dim lTotalBaseFlow As Double = aLandLoadingConstReport.Compute("AVG(IFWO)", lSelectExpression) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression) + Dim lTotalLZET As Double = aLandLoadingConstReport.Compute("AVG(LZET)", lSelectExpression) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression) + Dim lTotalUZET As Double = aLandLoadingConstReport.Compute("AVG(UZET)", lSelectExpression) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression) + Dim lTotalAGWET As Double = aLandLoadingConstReport.Compute("AVG(AGWET)", lSelectExpression) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression) - If TotalSurfaceRunoff > TotalBaseFlow Then - CheckRunoffStatement.AppendLine("
  • Surface runoff is greater than baseflow for " & aLanduse & ".
  • ") + If lTotalSurfaceRunoff > lTotalBaseFlow Then + lCheckRunoffStatement.AppendLine("
  • Surface runoff is greater than baseflow for " & aLanduse & ".
  • ") End If Select Case aLanduse Case "Forest" - For Each landuse2 As String In aListofLandUsesinUCI - If landuse2 = "Forest" OrElse landuse2 = "Impervious" Then Continue For - Dim SelectExpression2 As String = "genLandUse = '" & landuse2 & "' And Year = 'SumAnnual'" - Dim TotalOutflow2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", SelectExpression2) - Dim TotalSurfaceRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(SURO)", SelectExpression2) - Dim TotalBaseFlow2 As Double = aLandLoadingConstReport.Compute("AVG(IFWO)", SelectExpression2) + aLandLoadingConstReport.Compute("AVG(AGWO)", SelectExpression2) + For Each lLanduse2 As String In aListofLandUsesinUCI + If lLanduse2 = "Forest" OrElse lLanduse2 = "Impervious" Then Continue For + Dim lSelectExpression2 As String = "genLandUse = '" & lLanduse2 & "' And Year = 'SumAnnual'" + Dim lTotalOutflow2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression2) + Dim lTotalSurfaceRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(SURO)", lSelectExpression2) + Dim lTotalBaseFlow2 As Double = aLandLoadingConstReport.Compute("AVG(IFWO)", lSelectExpression2) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression2) Select Case True - Case landuse2 = "Wetland" AndAlso TotalOutflow2 > TotalOutFlow - CheckRunoffStatement.AppendLine("
  • Wetland has greater total outflow than Forest.
  • ") - Case landuse2 <> "Wetland" AndAlso TotalOutflow2 < TotalOutFlow - CheckRunoffStatement.AppendLine("
  • Forest has greater total outflow than " & landuse2 & ".
  • ") - Case landuse2 = "Wetland" AndAlso TotalSurfaceRunoff2 > TotalSurfaceRunoff - CheckRunoffStatement.AppendLine("
  • Wetland has greater surface runoff than Forest.
  • ") - Case landuse2 <> "Wetland" AndAlso TotalSurfaceRunoff2 < TotalSurfaceRunoff - CheckRunoffStatement.AppendLine("
  • Forest has greater surface runoff than " & landuse2 & ".
  • ") + Case lLanduse2 = "Wetland" AndAlso lTotalOutflow2 > lTotalOutFlow + lCheckRunoffStatement.AppendLine("
  • Wetland has greater total outflow than Forest.
  • ") + Case lLanduse2 <> "Wetland" AndAlso lTotalOutflow2 < lTotalOutFlow + lCheckRunoffStatement.AppendLine("
  • Forest has greater total outflow than " & lLanduse2 & ".
  • ") + Case lLanduse2 = "Wetland" AndAlso lTotalSurfaceRunoff2 > lTotalSurfaceRunoff + lCheckRunoffStatement.AppendLine("
  • Wetland has greater surface runoff than Forest.
  • ") + Case lLanduse2 <> "Wetland" AndAlso lTotalSurfaceRunoff2 < lTotalSurfaceRunoff + lCheckRunoffStatement.AppendLine("
  • Forest has greater surface runoff than " & lLanduse2 & ".
  • ") End Select Next Case "Wetland" - For Each landuse2 As String In aListofLandUsesinUCI - If landuse2 = "Forest" OrElse landuse2 = "Wetland" OrElse landuse2 = "Impervious" Then Continue For - Dim SelectExpression2 As String = "genLandUse = '" & landuse2 & "' And Year = 'SumAnnual'" - Dim TotalOutflow2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", SelectExpression2) - Dim TotalSurfaceRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(SURO)", SelectExpression2) - Dim TotalBaseFlow2 As Double = aLandLoadingConstReport.Compute("AVG(IFWO)", SelectExpression2) + aLandLoadingConstReport.Compute("AVG(AGWO)", SelectExpression2) - If TotalOutFlow > TotalOutflow2 Then - CheckRunoffStatement.AppendLine("
  • Wetland has greater total outflow than " & landuse2 & ".
  • ") + For Each lLanduse2 As String In aListofLandUsesinUCI + If lLanduse2 = "Forest" OrElse lLanduse2 = "Wetland" OrElse lLanduse2 = "Impervious" Then Continue For + Dim lSelectExpression2 As String = "genLandUse = '" & lLanduse2 & "' And Year = 'SumAnnual'" + Dim lTotalOutflow2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression2) + Dim lTotalSurfaceRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(SURO)", lSelectExpression2) + Dim lTotalBaseFlow2 As Double = aLandLoadingConstReport.Compute("AVG(IFWO)", lSelectExpression2) + aLandLoadingConstReport.Compute("AVG(AGWO)", lSelectExpression2) + If lTotalOutFlow > lTotalOutflow2 Then + lCheckRunoffStatement.AppendLine("
  • Wetland has greater total outflow than " & lLanduse2 & ".
  • ") End If Next End Select End If - Return CheckRunoffStatement.ToString + Return lCheckRunoffStatement.ToString End Function ''' @@ -1501,79 +1501,79 @@ Module HSPFOutputReports ''' ''' ''' - ''' + ''' ''' Private Function CheckETIssues(ByVal aLanduse As String, ByVal aLandLoadingConstReport As DataTable, ByVal aListofLandUsesinUCI As List(Of String), - ByVal WetlandLUExists As Boolean) As String - Dim CheckETIssuesStatement As New Text.StringBuilder + ByVal aWetlandLUExists As Boolean) As String + Dim lCheckETIssuesStatement As New Text.StringBuilder Dim lSelectExpression As String = "" - Dim TotalET As Double = 0 + Dim lTotalET As Double = 0 If aLanduse = "Impervious" Then lSelectExpression = "genLandUse = '" & aLanduse & "' And Year = 'SumAnnual'" - TotalET = aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression) - For Each landuse2 As String In aListofLandUsesinUCI - If landuse2 = "Impervious" Then Continue For - Dim lSelectExpression2 As String = "genLandUse = '" & landuse2 & "' And Year = 'SumAnnual'" - If TotalET > aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression2) Then - CheckETIssuesStatement.AppendLine("
  • Impervious areas have greater ET loss than " & landuse2 & ".
  • ") + lTotalET = aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression) + For Each lLanduse2 As String In aListofLandUsesinUCI + If lLanduse2 = "Impervious" Then Continue For + Dim lSelectExpression2 As String = "genLandUse = '" & lLanduse2 & "' And Year = 'SumAnnual'" + If lTotalET > aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression2) Then + lCheckETIssuesStatement.AppendLine("
  • Impervious areas have greater ET loss than " & lLanduse2 & ".
  • ") End If Next Else lSelectExpression = "OpTypeNumber Like 'P:%' And genLandUse = '" & aLanduse & "' And Year = 'SumAnnual'" - TotalET = aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression) - Dim PotET As Double = aLandLoadingConstReport.Compute("AVG(PET)", lSelectExpression) + lTotalET = aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression) + Dim lPotET As Double = aLandLoadingConstReport.Compute("AVG(PET)", lSelectExpression) - Dim InterceptionET As Double = aLandLoadingConstReport.Compute("AVG(CEPE)", lSelectExpression) - Dim UpperZoneET As Double = aLandLoadingConstReport.Compute("AVG(UZET)", lSelectExpression) - Dim LowerZoneET As Double = aLandLoadingConstReport.Compute("AVG(LZET)", lSelectExpression) - Dim GroundWaterET As Double = aLandLoadingConstReport.Compute("AVG(AGWET)", lSelectExpression) - Dim BaseflowET As Double = aLandLoadingConstReport.Compute("AVG(BASET)", lSelectExpression) + Dim lInterceptionET As Double = aLandLoadingConstReport.Compute("AVG(CEPE)", lSelectExpression) + Dim lUpperZoneET As Double = aLandLoadingConstReport.Compute("AVG(UZET)", lSelectExpression) + Dim lLowerZoneET As Double = aLandLoadingConstReport.Compute("AVG(LZET)", lSelectExpression) + Dim lGroundWaterET As Double = aLandLoadingConstReport.Compute("AVG(AGWET)", lSelectExpression) + Dim lBaseflowET As Double = aLandLoadingConstReport.Compute("AVG(BASET)", lSelectExpression) - If aLanduse <> "Wetland" AndAlso WetlandLUExists AndAlso GroundWaterET > 0 Then - CheckETIssuesStatement.AppendLine("
  • Groundwater is being lost through evapotranspiration in " & aLanduse & " even though there is a separate Wetland land use.
  • ") + If aLanduse <> "Wetland" AndAlso aWetlandLUExists AndAlso lGroundWaterET > 0 Then + lCheckETIssuesStatement.AppendLine("
  • Groundwater is being lost through evapotranspiration in " & aLanduse & " even though there is a separate Wetland land use.
  • ") End If - If UpperZoneET > LowerZoneET Then - CheckETIssuesStatement.AppendLine("
  • Evaporation from upper zone is greater than evaporation from lower zone for " & aLanduse & ".
  • ") + If lUpperZoneET > lLowerZoneET Then + lCheckETIssuesStatement.AppendLine("
  • Evaporation from upper zone is greater than evaporation from lower zone for " & aLanduse & ".
  • ") End If Select Case aLanduse Case "Forest" - For Each landuse2 As String In aListofLandUsesinUCI - If landuse2 = "Forest" OrElse landuse2 = "Impervious" Then Continue For - Dim lSelectExpression2 As String = "OpTypeNumber Like 'P:%' And genLandUse = '" & landuse2 & "' And Year = 'SumAnnual'" + For Each lLanduse2 As String In aListofLandUsesinUCI + If lLanduse2 = "Forest" OrElse lLanduse2 = "Impervious" Then Continue For + Dim lSelectExpression2 As String = "OpTypeNumber Like 'P:%' And genLandUse = '" & lLanduse2 & "' And Year = 'SumAnnual'" 'Comparing Total ET - If landuse2 = "Wetland" AndAlso TotalET > aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression2) Then - CheckETIssuesStatement.AppendLine("
  • Forest has more ET than Wetland.
  • ") - ElseIf landuse2 <> "Wetland" AndAlso TotalET < aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression2) Then - CheckETIssuesStatement.AppendLine("
  • " & landuse2 & " has more ET than Forest.
  • ") + If lLanduse2 = "Wetland" AndAlso lTotalET > aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression2) Then + lCheckETIssuesStatement.AppendLine("
  • Forest has more ET than Wetland.
  • ") + ElseIf lLanduse2 <> "Wetland" AndAlso lTotalET < aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression2) Then + lCheckETIssuesStatement.AppendLine("
  • " & lLanduse2 & " has more ET than Forest.
  • ") End If 'Comparing Interception ET loss - If landuse2 <> "Wetland" AndAlso InterceptionET < aLandLoadingConstReport.Compute("AVG(CEPE)", lSelectExpression2) Then - CheckETIssuesStatement.AppendLine("
  • " & landuse2 & " has more interception loss than Forest.
  • ") + If lLanduse2 <> "Wetland" AndAlso lInterceptionET < aLandLoadingConstReport.Compute("AVG(CEPE)", lSelectExpression2) Then + lCheckETIssuesStatement.AppendLine("
  • " & lLanduse2 & " has more interception loss than Forest.
  • ") End If - Next landuse2 + Next lLanduse2 Case "Wetland" - For Each landuse2 As String In aListofLandUsesinUCI - If landuse2 = "Forest" OrElse landuse2 = "Wetland" OrElse landuse2 = "Impervious" Then Continue For - Dim lSelectExpression2 As String = "OpTypeNumber Like 'P:%' And genLandUse = '" & landuse2 & "' And Year = 'SumAnnual'" - If TotalET < aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression2) Then - CheckETIssuesStatement.AppendLine("
  • " & landuse2 & " has more ET than Wetland.
  • ") + For Each lLanduse2 As String In aListofLandUsesinUCI + If lLanduse2 = "Forest" OrElse lLanduse2 = "Wetland" OrElse lLanduse2 = "Impervious" Then Continue For + Dim lSelectExpression2 As String = "OpTypeNumber Like 'P:%' And genLandUse = '" & lLanduse2 & "' And Year = 'SumAnnual'" + If lTotalET < aLandLoadingConstReport.Compute("AVG(TAET)", lSelectExpression2) Then + lCheckETIssuesStatement.AppendLine("
  • " & lLanduse2 & " has more ET than Wetland.
  • ") End If - If InterceptionET < aLandLoadingConstReport.Compute("AVG(CEPE)", lSelectExpression2) Then - CheckETIssuesStatement.AppendLine("
  • " & landuse2 & " has more interception loss than Wetland.
  • ") + If lInterceptionET < aLandLoadingConstReport.Compute("AVG(CEPE)", lSelectExpression2) Then + lCheckETIssuesStatement.AppendLine("
  • " & lLanduse2 & " has more interception loss than Wetland.
  • ") End If - Next landuse2 + Next lLanduse2 End Select End If - Return CheckETIssuesStatement.ToString + Return lCheckETIssuesStatement.ToString End Function @@ -1587,21 +1587,21 @@ Module HSPFOutputReports Private Function CheckTotalSedimentErosion(ByVal aLanduse As String, ByVal aListofLandUsesinUCI As List(Of String), ByVal aLandLoadingConstReport As DataTable) As String Dim lUnits As String = " lb/ac/yr" - Dim CheckTotalSedErosion As New Text.StringBuilder + Dim lCheckTotalSedErosion As New Text.StringBuilder Dim lSelectExpression As String = "genLandUse = '" & aLanduse & "' And Year = 'SumAnnual'" - Dim TotalSedRunoff As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression) 'Need to convert sediment erosion rate to lbs/ac + Dim lTotalSedRunoff As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression) 'Need to convert sediment erosion rate to lbs/ac - Dim TotalGullyErosion As Double = 0 + Dim lTotalGullyErosion As Double = 0 Try - TotalGullyErosion = aLandLoadingConstReport.Compute("AVG(SCRSD)", lSelectExpression) + lTotalGullyErosion = aLandLoadingConstReport.Compute("AVG(SCRSD)", lSelectExpression) Catch ex As Exception End Try - If TotalGullyErosion > 0 And aLanduse <> "Forest" Then - CheckTotalSedErosion.AppendLine("
  • Gully erosion is being simulated on " & aLanduse & ".
  • ") + If lTotalGullyErosion > 0 And aLanduse <> "Forest" Then + lCheckTotalSedErosion.AppendLine("
  • Gully erosion is being simulated on " & aLanduse & ".
  • ") End If - Dim LoadingRate As List(Of Double) = GetMinMaxLoadingRates(aLanduse, "SED") + Dim lLoadingRate As List(Of Double) = GetMinMaxLoadingRates(aLanduse, "SED") 'If TotalSedRunoff > LoadingRate(1) OrElse TotalSedRunoff < LoadingRate(0) Then ' CheckTotalSedErosion.AppendLine("
  • Sediment loading rate of " & Format(TotalSedRunoff, "0.00") & lUnits & " is outside the typical limit of " & ' LoadingRate(0) & " - " & LoadingRate(1) & lUnits & " for " & aLanduse & ".
  • ") @@ -1609,46 +1609,46 @@ Module HSPFOutputReports Dim lMatchingRows() = aLandLoadingConstReport.Select(lSelectExpression) For Each lDataRow In lMatchingRows Dim lTotalRunoff As Double = lDataRow.ItemArray(5) - If lTotalRunoff > LoadingRate(1) OrElse lTotalRunoff < LoadingRate(0) Then - CheckTotalSedErosion.AppendLine("
  • Sediment loading rate of " & Format(lTotalRunoff, "0.00") & lUnits & "" & + If lTotalRunoff > lLoadingRate(1) OrElse lTotalRunoff < lLoadingRate(0) Then + lCheckTotalSedErosion.AppendLine("
  • Sediment loading rate of " & Format(lTotalRunoff, "0.00") & lUnits & "" & " for " & lDataRow.ItemArray(0) & "-" & lDataRow.ItemArray(1) & " is outside the typical limit of " & - LoadingRate(0) & " - " & LoadingRate(1) & lUnits & " for " & aLanduse & ".
  • ") + lLoadingRate(0) & " - " & lLoadingRate(1) & lUnits & " for " & aLanduse & ".") End If Next Select Case aLanduse Case "Impervious" - For Each landuse2 As String In aListofLandUsesinUCI - If landuse2 = "Impervious" Then Continue For - Dim lSelectExpression2 As String = "genLandUse = '" & landuse2 & "' And Year = 'SumAnnual'" - Dim TotalSedRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression2) - If TotalSedRunoff2 > TotalSedRunoff Then - CheckTotalSedErosion.AppendLine("
  • Impervious area has greater sediment runoff than " & landuse2 & ".
  • ") + For Each lLanduse2 As String In aListofLandUsesinUCI + If lLanduse2 = "Impervious" Then Continue For + Dim lSelectExpression2 As String = "genLandUse = '" & lLanduse2 & "' And Year = 'SumAnnual'" + Dim lTotalSedRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression2) + If lTotalSedRunoff2 > lTotalSedRunoff Then + lCheckTotalSedErosion.AppendLine("
  • Impervious area has greater sediment runoff than " & lLanduse2 & ".
  • ") End If Next Case "Forest" - For Each landuse2 As String In aListofLandUsesinUCI - If landuse2 = "Forest" OrElse landuse2 = "Impervious" Then Continue For - Dim lSelectExpression2 As String = "OpTypeNumber Like 'P:%' And genLandUse = '" & landuse2 & "' And Year = 'SumAnnual'" - Dim TotalSedRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression2) - If landuse2 = "Wetland" AndAlso TotalSedRunoff2 > TotalSedRunoff Then - CheckTotalSedErosion.AppendLine("
  • Wetland has greater sediment runoff than Forest.
  • ") - ElseIf landuse2 <> "Wetland" AndAlso TotalSedRunoff2 < TotalSedRunoff Then - CheckTotalSedErosion.AppendLine("
  • Forest has greater sediment runoff than " & landuse2 & ".
  • ") + For Each lLanduse2 As String In aListofLandUsesinUCI + If lLanduse2 = "Forest" OrElse lLanduse2 = "Impervious" Then Continue For + Dim lSelectExpression2 As String = "OpTypeNumber Like 'P:%' And genLandUse = '" & lLanduse2 & "' And Year = 'SumAnnual'" + Dim lTotalSedRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression2) + If lLanduse2 = "Wetland" AndAlso lTotalSedRunoff2 > lTotalSedRunoff Then + lCheckTotalSedErosion.AppendLine("
  • Wetland has greater sediment runoff than Forest.
  • ") + ElseIf lLanduse2 <> "Wetland" AndAlso lTotalSedRunoff2 < lTotalSedRunoff Then + lCheckTotalSedErosion.AppendLine("
  • Forest has greater sediment runoff than " & lLanduse2 & ".
  • ") End If Next Case "Wetland" - For Each landuse2 As String In aListofLandUsesinUCI - If landuse2 = "Forest" OrElse landuse2 = "Wetland" OrElse landuse2 = "Impervious" Then Continue For - Dim lSelectExpression2 As String = "OpTypeNumber Like 'P:%' And genLandUse = '" & landuse2 & "' And Year = 'SumAnnual'" - Dim TotalSedRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression2) - If TotalSedRunoff2 < TotalSedRunoff Then - CheckTotalSedErosion.AppendLine("
  • Wetland has greater sediment runoff than " & landuse2 & ".
  • ") + For Each lLanduse2 As String In aListofLandUsesinUCI + If lLanduse2 = "Forest" OrElse lLanduse2 = "Wetland" OrElse lLanduse2 = "Impervious" Then Continue For + Dim lSelectExpression2 As String = "OpTypeNumber Like 'P:%' And genLandUse = '" & lLanduse2 & "' And Year = 'SumAnnual'" + Dim lTotalSedRunoff2 As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression2) + If lTotalSedRunoff2 < lTotalSedRunoff Then + lCheckTotalSedErosion.AppendLine("
  • Wetland has greater sediment runoff than " & lLanduse2 & ".
  • ") End If Next End Select - Return CheckTotalSedErosion.ToString + Return lCheckTotalSedErosion.ToString End Function ''' @@ -1661,14 +1661,14 @@ Module HSPFOutputReports ''' Private Function CheckNutrientLoading(ByVal aLanduse As String, ByVal aConstituentName As String, ByVal aListofLandUsesinUCI As List(Of String), ByVal aLandLoadingConstReport As DataTable) As String - Dim CheckNutrientLoadingText As New Text.StringBuilder + Dim lCheckNutrientLoadingText As New Text.StringBuilder Dim lUnits As String = " lb/ac/yr" Dim lSelectExpression As String = "ConstNameEXP = '" & aConstituentName & "' AND genLandUse = '" & aLanduse & "' And Year = 'SumAnnual'" - Dim lconversionfactor As Double = 1.0 + Dim lConversionFactor As Double = 1.0 'If aConstituentName = "SED" Then lconversionfactor = 2000 - Dim TotalRunoff As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression) * lconversionfactor 'Need to convert sediment erosion rate to lbs/ac - Dim LoadingRate As List(Of Double) = GetMinMaxLoadingRates(aLanduse, aConstituentName) + Dim lTotalRunoff As Double = aLandLoadingConstReport.Compute("AVG(TotalOutflow)", lSelectExpression) * lConversionFactor 'Need to convert sediment erosion rate to lbs/ac + Dim lLoadingRate As List(Of Double) = GetMinMaxLoadingRates(aLanduse, aConstituentName) 'If TotalRunoff > LoadingRate(1) OrElse TotalRunoff < LoadingRate(0) Then ' CheckNutrientLoadingText.AppendLine("
  • " & aConstituentName & " loading rate of " & Format(TotalRunoff, "0.00") & lUnits & ' " is outside the typical range of " & Format(LoadingRate(0), "0.00") & " - " & @@ -1676,28 +1676,28 @@ Module HSPFOutputReports 'End If Dim lMatchingRows() = aLandLoadingConstReport.Select(lSelectExpression) For Each lDataRow In lMatchingRows - Dim lTotalRunoff As Double = lDataRow.ItemArray(11) - If lTotalRunoff > LoadingRate(1) OrElse lTotalRunoff < LoadingRate(0) Then - CheckNutrientLoadingText.AppendLine("
  • " & aConstituentName & " loading rate of " & Format(lTotalRunoff, "0.00") & lUnits & "" & + Dim lTotalRunoffX As Double = lDataRow.ItemArray(11) + If lTotalRunoffX > lLoadingRate(1) OrElse lTotalRunoffX < lLoadingRate(0) Then + lCheckNutrientLoadingText.AppendLine("
  • " & aConstituentName & " loading rate of " & Format(lTotalRunoffX, "0.00") & lUnits & "" & " for " & lDataRow.ItemArray(0) & "-" & lDataRow.ItemArray(1) & " is outside the typical limit of " & - LoadingRate(0) & " - " & LoadingRate(1) & lUnits & " for " & aLanduse & ".
  • ") + lLoadingRate(0) & " - " & lLoadingRate(1) & lUnits & " for " & aLanduse & ".") End If Next - Return CheckNutrientLoadingText.ToString + Return lCheckNutrientLoadingText.ToString End Function Private Function GetMinMaxLoadingRates(ByVal aLanduse As String, ByVal aConstituent As String) As List(Of Double) - Dim MinMaxRange As New List(Of Double) - Dim LoadingRateRange As XmlDocument = New XmlDocument() - LoadingRateRange.LoadXml(My.Resources.LoadingRates) ' - Dim SelectStatementFromXML As String = "/LoadingRates/Nutrient[@type='" & aConstituent & "']/Landuse[@name='" & aLanduse & "']" - Dim nodes As XmlNodeList = LoadingRateRange.DocumentElement.SelectNodes(SelectStatementFromXML) + Dim lMinMaxRange As New List(Of Double) + Dim lLoadingRateRange As XmlDocument = New XmlDocument() + lLoadingRateRange.LoadXml(My.Resources.LoadingRates) ' + Dim lSelectStatementFromXML As String = "/LoadingRates/Nutrient[@type='" & aConstituent & "']/Landuse[@name='" & aLanduse & "']" + Dim lNodes As XmlNodeList = lLoadingRateRange.DocumentElement.SelectNodes(lSelectStatementFromXML) - MinMaxRange.Add(nodes(0).SelectSingleNode("Min").InnerText) - MinMaxRange.Add(nodes(0).SelectSingleNode("Max").InnerText) + lMinMaxRange.Add(lNodes(0).SelectSingleNode("Min").InnerText) + lMinMaxRange.Add(lNodes(0).SelectSingleNode("Max").InnerText) - Return MinMaxRange + Return lMinMaxRange End Function 'Private Function CheckIfMonthlyFlagisOn(ByVal aTableParm As String, ByVal aParmName As String, Optional ByVal aConst As String = "") As IList(Of String) @@ -1722,8 +1722,8 @@ Module HSPFOutputReports Private Function QAVerifyStorageTrend(ByVal aUCI As HspfUci, ByVal aBinaryData As atcDataSource, ByVal aConstituent As String) As String Logger.Status("Creating the QAQC Storage Trend Report") - Dim StorageTrend As New Text.StringBuilder - Dim OverAllStorageTrend As New Text.StringBuilder + Dim lStorageTrend As New Text.StringBuilder + Dim lOverAllStorageTrend As New Text.StringBuilder Dim lSimSpan As Double = aUCI.GlobalBlock.EdateJ - aUCI.GlobalBlock.SDateJ Dim lNumberOfTrendIssues As Integer = 0 Logger.Dbg("Constituent Storage Analysis for " & aConstituent) @@ -1731,7 +1731,7 @@ Module HSPFOutputReports Select Case aConstituent Case "WAT" lListOfStorageVariables.Add("R:VOL") - OverAllStorageTrend.AppendLine("

    Reach water volume analysis

    ") + lOverAllStorageTrend.AppendLine("

    Reach water volume analysis

    ") Case "TN" lListOfStorageVariables.Add("R:NO3-STOR") lListOfStorageVariables.Add("R:TAM-STOR") @@ -1740,28 +1740,28 @@ Module HSPFOutputReports lListOfStorageVariables.Add("P:SQO-NH3+NH4") lListOfStorageVariables.Add("I:SQO-NO3") lListOfStorageVariables.Add("I:SQO-NH3+NH4") - OverAllStorageTrend.AppendLine("

    Nitrate, ammonia, and total nitogen storage and concentration analysis

    ") + lOverAllStorageTrend.AppendLine("

    Nitrate, ammonia, and total nitogen storage and concentration analysis

    ") Case "TP" lListOfStorageVariables.Add("R:PO4-STOR") lListOfStorageVariables.Add("R:P-TOT-CONC") lListOfStorageVariables.Add("P:SQO-ORTHO P") lListOfStorageVariables.Add("I:SQO-ORTHO P") - OverAllStorageTrend.AppendLine("

    Orthophosphorus and total phosphorus storage and concentration analysis

    ") + lOverAllStorageTrend.AppendLine("

    Orthophosphorus and total phosphorus storage and concentration analysis

    ") Case "SED" lListOfStorageVariables.Add("R:BEDDEP") lListOfStorageVariables.Add("P:DETS") lListOfStorageVariables.Add("I:SLDS") - OverAllStorageTrend.AppendLine("

    Reach Bed Depth and sediment storage analysis

    ") + lOverAllStorageTrend.AppendLine("

    Reach Bed Depth and sediment storage analysis

    ") Case "BOD-Labile" lListOfStorageVariables.Add("P:SQO-BOD") lListOfStorageVariables.Add("I:SQO-BOD") - OverAllStorageTrend.AppendLine("

    BOD-labile storage analysis

    ") + lOverAllStorageTrend.AppendLine("

    BOD-labile storage analysis

    ") End Select If lSimSpan < 1827 Then - OverAllStorageTrend.AppendLine("

    The time span of simulation is shorter than 5 years. The long term trend analysis may not be accurate.

    ") + lOverAllStorageTrend.AppendLine("

    The time span of simulation is shorter than 5 years. The long term trend analysis may not be accurate.

    ") End If Dim lStorageVarCount As New atcCollection - StorageTrend.AppendLine("
      ") + lStorageTrend.AppendLine("
        ") For Each lOperation As HspfOperation In aUCI.OpnSeqBlock.Opns Dim lLocationName As String = "" Select Case lOperation.Name @@ -1776,20 +1776,20 @@ Module HSPFOutputReports End Select Logger.Status("Creating the QAQC Storage Trend Report for " & aConstituent & " in " & lLocationName) - Dim StorageVariableNoOp As String = "" - For Each StorageVariable As String In lListOfStorageVariables - If Not StorageVariable.StartsWith(lLocationName.Substring(0, 2)) Then Continue For - StorageVariableNoOp = StorageVariable.Split(":")(1) - Logger.Dbg("Operation ID= " & lOperation.Id & ", Storage Variable = " & StorageVariable) + Dim lStorageVariableNoOp As String = "" + For Each lStorageVariable As String In lListOfStorageVariables + If Not lStorageVariable.StartsWith(lLocationName.Substring(0, 2)) Then Continue For + lStorageVariableNoOp = lStorageVariable.Split(":")(1) + Logger.Dbg("Operation ID= " & lOperation.Id & ", Storage Variable = " & lStorageVariable) Dim lSlope As Double = 0 Dim lIntercept As Double = 0 Dim lRCoeff As Double = 0 - Dim lStorageTimeSeries As atcTimeseries = aBinaryData.DataSets.FindData("Location", lLocationName).FindData("Constituent", StorageVariableNoOp)(0) + Dim lStorageTimeSeries As atcTimeseries = aBinaryData.DataSets.FindData("Location", lLocationName).FindData("Constituent", lStorageVariableNoOp)(0) If Not lStorageTimeSeries Is Nothing Then 'binary output found - If lStorageVarCount.Keys.Contains(StorageVariable) Then - lStorageVarCount.ItemByKey(StorageVariable) += 1 + If lStorageVarCount.Keys.Contains(lStorageVariable) Then + lStorageVarCount.ItemByKey(lStorageVariable) += 1 Else - lStorageVarCount.Add(StorageVariable, 1) + lStorageVarCount.Add(lStorageVariable, 1) End If Dim lTempTimeSeries As New atcTimeseries(Nothing) lTempTimeSeries = lStorageTimeSeries.Clone @@ -1806,10 +1806,10 @@ Module HSPFOutputReports If lTSerAverage > 0 Then lCoeffVariation = lTSerStdev / lTSerAverage Else - StorageTrend.AppendLine("
      • Could not estimate trend for Operation ID= " & lOperation.Id & ", Storage Variable = " & StorageVariable & " - Average of output timeseries is 0" & "
      • ") + lStorageTrend.AppendLine("
      • Could not estimate trend for Operation ID= " & lOperation.Id & ", Storage Variable = " & lStorageVariable & " - Average of output timeseries is 0" & "
      • ") End If Catch - StorageTrend.AppendLine("
      • Could not estimate trend for Operation ID= " & lOperation.Id & ", Storage Variable = " & StorageVariable & " - Unable to compute timeseries Average and Standard Deviation" & "
      • ") + lStorageTrend.AppendLine("
      • Could not estimate trend for Operation ID= " & lOperation.Id & ", Storage Variable = " & lStorageVariable & " - Unable to compute timeseries Average and Standard Deviation" & "
      • ") Continue For End Try @@ -1828,88 +1828,88 @@ Module HSPFOutputReports Dim lY2 As Double = ((lSlope * lTempTimeSeries.Value(lTempTimeSeries.numValues - 1)) + lIntercept) * lTSerStdev + lTSerAverage Dim lPercentChange As Double = 100 * ((lY2 - lY) / lY) If lSlope > 0.002 AndAlso lPercentChange > 20 Then - StorageTrend.AppendLine("
      • The " & StorageVariableNoOp & " for " & lLocationName & " increases by" & DecimalAlign(lPercentChange, 6, 1, 4) & "%
      • ") + lStorageTrend.AppendLine("
      • The " & lStorageVariableNoOp & " for " & lLocationName & " increases by" & DecimalAlign(lPercentChange, 6, 1, 4) & "%
      • ") lNumberOfTrendIssues += 1 ElseIf lSlope < -0.002 AndAlso lPercentChange < -20 Then - StorageTrend.AppendLine("
      • The " & StorageVariableNoOp & " for " & lLocationName & " decreases by" & DecimalAlign(Math.Abs(lPercentChange), 6, 1, 4) & "%
      • ") + lStorageTrend.AppendLine("
      • The " & lStorageVariableNoOp & " for " & lLocationName & " decreases by" & DecimalAlign(Math.Abs(lPercentChange), 6, 1, 4) & "%
      • ") lNumberOfTrendIssues += 1 End If End If End If Next Next - StorageTrend.AppendLine("
      ") + lStorageTrend.AppendLine("
    ") If lStorageVarCount.Count = 0 Then 'no timeseries found on binary file - OverAllStorageTrend.AppendLine("

    No storage or concentration timeseries were found for analysis in the binary output file.

    ") + lOverAllStorageTrend.AppendLine("

    No storage or concentration timeseries were found for analysis in the binary output file.

    ") ElseIf lNumberOfTrendIssues > 0 Then - OverAllStorageTrend.AppendLine("

    The following non-typical long term trend issues were noticed in the model.*

    ") - OverAllStorageTrend.Append(StorageTrend) - OverAllStorageTrend.AppendLine("

    *Based on fitted line through difference of values from mean over time

    ") + lOverAllStorageTrend.AppendLine("

    The following non-typical long term trend issues were noticed in the model.*

    ") + lOverAllStorageTrend.Append(lStorageTrend) + lOverAllStorageTrend.AppendLine("

    *Based on fitted line through difference of values from mean over time

    ") Else - OverAllStorageTrend.AppendLine("

    No long term storage or concentration issues were noticed in the model.

    ") + lOverAllStorageTrend.AppendLine("

    No long term storage or concentration issues were noticed in the model.

    ") End If - OverAllStorageTrend.AppendLine("

    The following model elements were reviewed (count of datasets in parentheses):

      ") + lOverAllStorageTrend.AppendLine("

      The following model elements were reviewed (count of datasets in parentheses):

        ") For Each StorageVariable As String In lListOfStorageVariables If lStorageVarCount.ItemByKey(StorageVariable) IsNot Nothing Then - OverAllStorageTrend.AppendLine("
      • " & StorageVariable & " (" & lStorageVarCount.ItemByKey(StorageVariable) & " datasets)") + lOverAllStorageTrend.AppendLine("
      • " & StorageVariable & " (" & lStorageVarCount.ItemByKey(StorageVariable) & " datasets)") End If Next - OverAllStorageTrend.AppendLine("
      ") + lOverAllStorageTrend.AppendLine("
    ") - Return OverAllStorageTrend.ToString + Return lOverAllStorageTrend.ToString End Function - Private Function ConvertToHtmlFile(ByVal myTable As DataTable, ByVal Optional NumberOfRows As Integer = 0) As String - Dim myHtmlFile As String = "" - Dim myBuilder As New Text.StringBuilder - Dim ColumnCounter As Integer = 0 - If myTable Is Nothing Then + Private Function ConvertToHtmlFile(ByVal aTable As DataTable, ByVal Optional aNumberOfRows As Integer = 0) As String + Dim lHtmlFile As String = "" + Dim lBuilder As New Text.StringBuilder + Dim lColumnCounter As Integer = 0 + If aTable Is Nothing Then Throw New System.ArgumentNullException("myTable") Else - myBuilder.AppendLine("") - myBuilder.AppendLine("") - For Each myColumn As DataColumn In myTable.Columns - ColumnCounter += 1 - If ColumnCounter = 1 Then - myBuilder.Append("
    ") + lBuilder.AppendLine("") + lBuilder.AppendLine("") + For Each myColumn As DataColumn In aTable.Columns + lColumnCounter += 1 + If lColumnCounter = 1 Then + lBuilder.Append("") + lBuilder.Append(myColumn.Caption) + lBuilder.AppendLine("") Next - myBuilder.AppendLine("") - - Dim MyRowCounter As Integer = 0 - ColumnCounter = 0 - For Each myRow As DataRow In myTable.Rows - MyRowCounter += 1 - myBuilder.AppendLine("") - For Each myColumn As DataColumn In myTable.Columns - ColumnCounter += 1 - If ColumnCounter = 1 Then - myBuilder.Append("") + + Dim lRowCounter As Integer = 0 + lColumnCounter = 0 + For Each myRow As DataRow In aTable.Rows + lRowCounter += 1 + lBuilder.AppendLine("") + For Each lColumn As DataColumn In aTable.Columns + lColumnCounter += 1 + If lColumnCounter = 1 Then + lBuilder.Append("") + lBuilder.Append(myRow(lColumn.ColumnName).ToString()) + lBuilder.AppendLine("") Next - ColumnCounter = 0 - If NumberOfRows <> 0 AndAlso MyRowCounter = NumberOfRows Then Exit For + lColumnCounter = 0 + If aNumberOfRows <> 0 AndAlso lRowCounter = aNumberOfRows Then Exit For Next - myBuilder.AppendLine("") + lBuilder.AppendLine("") End If 'Close tags. - myBuilder.AppendLine("
    ") Else - myBuilder.Append("") + lBuilder.Append("") End If - myBuilder.Append(myColumn.Caption) - myBuilder.AppendLine("
    ") + lBuilder.AppendLine("
    ") Else - myBuilder.Append("") + lBuilder.Append("") End If - myBuilder.Append(myRow(myColumn.ColumnName).ToString()) - myBuilder.AppendLine("
    ") + lBuilder.AppendLine("
    ") - myHtmlFile = myBuilder.ToString() - Return myHtmlFile + lHtmlFile = lBuilder.ToString() + Return lHtmlFile End Function ''' ''' This function checks the diurnal pattern of the hourly time series. @@ -2162,6 +2162,7 @@ Module HSPFOutputReports Return lDiurnalPattern.ToString End Function + Private Function CheckIfAdsDesIsSimulated() As String Return "" End Function diff --git a/HSPEXP/MultiSimulatioManager.vb b/HSPEXP/MultiSimulatioManager.vb index b85e08a21..94bb6485e 100644 --- a/HSPEXP/MultiSimulatioManager.vb +++ b/HSPEXP/MultiSimulatioManager.vb @@ -7,16 +7,16 @@ Imports System.Data Public Class ModelParameter 'This class manages the property of each individual parameter - Public ParmID As Integer = 0 - Public ParmOperationType As String = "" - Public ParmOperationNumber As Integer = 0 - Public ParmOperationName As String = "" - Public ParmTable As String = "" - Public ParmName As String = "" - Public ParmMultFactor As Integer = 0 - Public ParmLow As Double = -1.0E-30 - Public ParmHigh As Double = 1.0E+30 - Public ParmOccurence As Integer = 0 + Public pParmID As Integer = 0 + Public pParmOperationType As String = "" + Public pParmOperationNumber As Integer = 0 + Public pParmOperationName As String = "" + Public pParmTable As String = "" + Public pParmName As String = "" + Public pParmMultFactor As Integer = 0 + Public pParmLow As Double = -1.0E-30 + Public pParmHigh As Double = 1.0E+30 + Public pParmOccurence As Integer = 0 End Class @@ -27,93 +27,93 @@ Public Module MultiSimAnalysis Dim lMsg As New atcUCI.HspfMsg lMsg.Open("hspfmsg.wdm") 'Need to figure out why we need this. Dim lExitCode As Integer - Dim SimID As Integer = 0 + Dim lSimID As Integer = 0 Dim lUci As New atcUCI.HspfUci - Dim DeleteUCIFiles As Integer = 0 - Dim uciName As String - uciName = "MultiSim.uci" - File.Copy(pBaseName & ".uci", uciName, True) 'Saving the original file with MultiSim.uci name - lUci.ReadUci(lMsg, uciName, -1, False, pBaseName & ".ech") ' Reading the temp uci file + Dim lDeleteUCIFiles As Integer = 0 + Dim lUciName As String + lUciName = "MultiSim.uci" + File.Copy(pBaseName & ".uci", lUciName, True) 'Saving the original file with MultiSim.uci name + lUci.ReadUci(lMsg, lUciName, -1, False, pBaseName & ".ech") ' Reading the temp uci file lUci.GlobalBlock.RunFg = 1 lUci.Save() - Dim loutWDMFileName As String = Path.Combine(pTestPath, "MultiSim.wdm") - If File.Exists(loutWDMFileName) Then + Dim lOutWDMFileName As String = Path.Combine(pTestPath, "MultiSim.wdm") + If File.Exists(lOutWDMFileName) Then Try - File.Delete(loutWDMFileName) + File.Delete(lOutWDMFileName) Catch ex As Exception End Try End If - Dim YearsofSimulation As Single - YearsofSimulation = (aEDateJ - aSDateJ) / JulianYear + Dim lYearsofSimulation As Single + lYearsofSimulation = (aEDateJ - aSDateJ) / JulianYear 'Generate a default Parameter Sensitivity Table file if it does not exist already Dim lParameterListFilesIsAvailable As Boolean = False Dim lSpecificationFile As String = "MultiSimSpecFile.csv" - Dim NumberOfOutputDSN As Integer = 0 + Dim lNumberOfOutputDSN As Integer = 0 If Not IO.File.Exists(lSpecificationFile) Then - Dim SensitivityParameterFile As StreamWriter = IO.File.CreateText("MultiSimSpecFile.csv") - Dim TextToAddForMultiSimFile As String = "***Initial Parameter List For Sensitivity/Uncertainty Analysis And Output DSN from the UCI file" - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "***Following Output IDs are the first two ID read from the EXT TARGET block of the UCI file. You can add more." - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) + Dim lSensitivityParameterFile As StreamWriter = IO.File.CreateText("MultiSimSpecFile.csv") + Dim lTextToAddForMultiSimFile As String = "***Initial Parameter List For Sensitivity/Uncertainty Analysis And Output DSN from the UCI file" + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "***Following Output IDs are the first two ID read from the EXT TARGET block of the UCI file. You can add more." + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) - TextToAddForMultiSimFile = "DSN," + lTextToAddForMultiSimFile = "DSN," For Each lEXTTARGET As HspfConnection In lUci.Connections - If lEXTTARGET.Target.VolName.Contains("WDM") AndAlso NumberOfOutputDSN <= 1 Then - NumberOfOutputDSN += 1 - TextToAddForMultiSimFile &= lEXTTARGET.Target.VolId & "," + If lEXTTARGET.Target.VolName.Contains("WDM") AndAlso lNumberOfOutputDSN <= 1 Then + lNumberOfOutputDSN += 1 + lTextToAddForMultiSimFile &= lEXTTARGET.Target.VolId & "," End If Next - If NumberOfOutputDSN = 0 Then + If lNumberOfOutputDSN = 0 Then Logger.Msg("The UCI file does not have output datasets specified in the EXT TARGETS Block. HSPEXP+ will quit", vbOKOnly) End End If - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = """***The operation number, land use, tied with next, and multiplier can be left blank""" - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "ParmID,OPN_Type,Table_Name,Parm_Name,Occur_Or_MLNumber,Mult_Factor_FG,OPN_Number_Or_Name,Lower_Limit,Upper_Limit" - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "1,PERLND,PWAT-PARM2,LZSN,,1,,3,8" - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "2,PERLND,PWAT-PARM2,INFILT,,1,,0.01,0.5" - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "Delete intermediate UCI files?, 0" - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "***Following lines list the multiplication factor for each parameter for each simulation." - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "SimID,Parm1,Parm2,,,,," - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "1,0.9,," - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "2,1.1,," - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "3,,0.9," - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) - TextToAddForMultiSimFile = "4,,1.1," - SensitivityParameterFile.WriteLine(TextToAddForMultiSimFile) + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = """***The operation number, land use, tied with next, and multiplier can be left blank""" + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "ParmID,OPN_Type,Table_Name,Parm_Name,Occur_Or_MLNumber,Mult_Factor_FG,OPN_Number_Or_Name,Lower_Limit,Upper_Limit" + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "1,PERLND,PWAT-PARM2,LZSN,,1,,3,8" + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "2,PERLND,PWAT-PARM2,INFILT,,1,,0.01,0.5" + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "Delete intermediate UCI files?, 0" + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "***Following lines list the multiplication factor for each parameter for each simulation." + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "SimID,Parm1,Parm2,,,,," + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "1,0.9,," + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "2,1.1,," + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "3,,0.9," + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) + lTextToAddForMultiSimFile = "4,,1.1," + lSensitivityParameterFile.WriteLine(lTextToAddForMultiSimFile) MsgBox("A default list of Sensitive parameters was created as MultiSimSpecFile.csv. Additionally two output DSN from the EXT TARGETS blocks were selected for analyzing outputs. You can edit this specification file and add more parameters and outputs.", vbOKOnly, "Default List of Outputs & Parameters") - SensitivityParameterFile.Close() + lSensitivityParameterFile.Close() End If 'Dim lOutputFile As StreamWriter = File.CreateText("MultiSimOutput.csv") - Dim loutputTable As DataTable - loutputTable = New DataTable("MultiSimOutput") - loutputTable = AddOutputTableColumns(loutputTable) + Dim lOutputTable As DataTable + lOutputTable = New DataTable("MultiSimOutput") + lOutputTable = AddOutputTableColumns(lOutputTable) - Dim TextToWrite As String = "" - For Each TableColumn As DataColumn In loutputTable.Columns 'Writing the table headings - TextToWrite &= TableColumn.Caption & "," + Dim lTextToWrite As String = "" + For Each lTableColumn As DataColumn In lOutputTable.Columns 'Writing the table headings + lTextToWrite &= lTableColumn.Caption & "," Next 'lOutputFile.WriteLine(TextToWrite) @@ -121,133 +121,130 @@ You can edit this specification file and add more parameters and outputs.", vbOK Dim lSpecificationFileRecordsNew As New ArrayList lSpecificationFileRecordsNew = ReadCSVFile(lSpecificationFile) 'Reading the MultiSim specification file - Dim listOfOutputDSN As New atcCollection - Dim lcsvRecordIndex As Integer = 0 - Dim lcsvlinerecord() As String = lSpecificationFileRecordsNew(lcsvRecordIndex) - NumberOfOutputDSN = lcsvlinerecord.Length - 1 - For i = 1 To NumberOfOutputDSN + Dim lListOfOutputDSN As New atcCollection + Dim lCsvRecordIndex As Integer = 0 + Dim lCsvLineRecord() As String = lSpecificationFileRecordsNew(lCsvRecordIndex) + lNumberOfOutputDSN = lCsvLineRecord.Length - 1 + For i = 1 To lNumberOfOutputDSN If lcsvlinerecord(i) = "" Then - NumberOfOutputDSN = i - 1 + lNumberOfOutputDSN = i - 1 Exit For Else - - listOfOutputDSN.Add(Int(lcsvlinerecord(i))) + lListOfOutputDSN.Add(Int(lCsvLineRecord(i))) 'If DSN is not an integer, it will cause an error here. Need to figure out the best way to handle it. End If - Next - Dim loutputLine As String = "" + Dim lOutputLine As String = "" ChDriveDir(PathNameOnly(pHSPFExe)) - loutputTable = ModelRunandReportAnswers(SimID, lUci, uciName, lExitCode, pBaseName, pTestPath, - aSDateJ, aEDateJ, YearsofSimulation, listOfOutputDSN, aHSPFEchofilename, loutputTable) + lOutputTable = ModelRunandReportAnswers(lSimID, lUci, lUciName, lExitCode, pBaseName, pTestPath, + aSDateJ, aEDateJ, lYearsofSimulation, lListOfOutputDSN, aHSPFEchofilename, lOutputTable) - Dim ListOfParameters As New List(Of ModelParameter) - lcsvRecordIndex += 1 - lcsvlinerecord = lSpecificationFileRecordsNew(lcsvRecordIndex) - Do Until lcsvlinerecord(0) = "Simulation ID" Or lcsvlinerecord(0).ToLower.Contains("delete") + Dim lListOfParameters As New List(Of ModelParameter) + lCsvRecordIndex += 1 + lCsvLineRecord = lSpecificationFileRecordsNew(lCsvRecordIndex) + Do Until lCsvLineRecord(0) = "Simulation ID" Or lCsvLineRecord(0).ToLower.Contains("delete") 'Going through the CSV file and getting the list of parameters. - Dim NewParameter As New ModelParameter - With NewParameter + Dim lNewParameter As New ModelParameter + With lNewParameter Try - .ParmID = Trim(Int(lcsvlinerecord(0))) 'Need to figure out better error messages if the values are not correct. + .pParmID = Trim(Int(lCsvLineRecord(0))) 'Need to figure out better error messages if the values are not correct. Catch ex As Exception End Try - If Not Trim(lcsvlinerecord(1)).Length = 0 Then - .ParmOperationType = Trim(lcsvlinerecord(1)) + If Not Trim(lCsvLineRecord(1)).Length = 0 Then + .pParmOperationType = Trim(lCsvLineRecord(1)) End If - .ParmTable = Trim(lcsvlinerecord(2)) + .pParmTable = Trim(lCsvLineRecord(2)) - If lcsvlinerecord.Length > 3 AndAlso Not Trim(lcsvlinerecord(3)).Length = 0 Then - .ParmName = Trim(lcsvlinerecord(3)) + If lCsvLineRecord.Length > 3 AndAlso Not Trim(lCsvLineRecord(3)).Length = 0 Then + .pParmName = Trim(lCsvLineRecord(3)) End If Try - .ParmOccurence = CInt(Trim(lcsvlinerecord(4))) + .pParmOccurence = CInt(Trim(lCsvLineRecord(4))) Catch - .ParmOccurence = 0 + .pParmOccurence = 0 End Try - .ParmMultFactor = 0 + .pParmMultFactor = 0 Try - .ParmMultFactor = CInt(Trim(lcsvlinerecord(5))) + .pParmMultFactor = CInt(Trim(lCsvLineRecord(5))) Catch - .ParmMultFactor = 0 + .pParmMultFactor = 0 End Try 'Assume that the fixed value for parameters will be provided for a MultiSim analysis for each individual simulation. - If .ParmTable.ToLower.StartsWith("mon-") Then .ParmMultFactor = 1 'If a monthly table is provided, a multiplication factor has to be provided. + If .pParmTable.ToLower.StartsWith("mon-") Then .pParmMultFactor = 1 'If a monthly table is provided, a multiplication factor has to be provided. - If Not Trim(lcsvlinerecord(6)).Length = 0 Then + If Not Trim(lCsvLineRecord(6)).Length = 0 Then Try - .ParmOperationNumber = CInt(Trim(lcsvlinerecord(6))) - .ParmOperationName = "" + .pParmOperationNumber = CInt(Trim(lCsvLineRecord(6))) + .pParmOperationName = "" Catch - .ParmOperationName = Trim(lcsvlinerecord(6)) - .ParmOperationNumber = 0 + .pParmOperationName = Trim(lCsvLineRecord(6)) + .pParmOperationNumber = 0 End Try End If Try - .ParmLow = CDbl(Trim(lcsvlinerecord(7))) + .pParmLow = CDbl(Trim(lCsvLineRecord(7))) Catch End Try Try - .ParmHigh = CDbl(Trim(lcsvlinerecord(8))) + .pParmHigh = CDbl(Trim(lCsvLineRecord(8))) Catch End Try End With - ListOfParameters.Add(NewParameter) - lcsvRecordIndex += 1 - lcsvlinerecord = lSpecificationFileRecordsNew(lcsvRecordIndex) + lListOfParameters.Add(lNewParameter) + lCsvRecordIndex += 1 + lCsvLineRecord = lSpecificationFileRecordsNew(lCsvRecordIndex) Loop If File.Exists(Path.Combine(pTestPath, "MultiSim_" & pBaseName & ".wdm")) Then File.Delete(Path.Combine(pTestPath, "MultiSim_" & pBaseName & ".wdm")) Do - lcsvlinerecord = lSpecificationFileRecordsNew(lcsvRecordIndex) - If lcsvlinerecord(0).ToLower.Contains("delete") Then - DeleteUCIFiles = CInt(Trim(lcsvlinerecord(1))) - lcsvRecordIndex += 1 - + lCsvLineRecord = lSpecificationFileRecordsNew(lCsvRecordIndex) + If lCsvLineRecord(0).ToLower.Contains("delete") Then + lDeleteUCIFiles = CInt(Trim(lCsvLineRecord(1))) + lCsvRecordIndex += 1 End If - lcsvRecordIndex += 1 - lcsvlinerecord = lSpecificationFileRecordsNew(lcsvRecordIndex) - SimID = lcsvlinerecord(0) + lCsvRecordIndex += 1 + lCsvLineRecord = lSpecificationFileRecordsNew(lCsvRecordIndex) + lSimID = lCsvLineRecord(0) - IO.File.Copy(Path.Combine(pTestPath, uciName), Path.Combine(pTestPath, SimID & uciName), True) + IO.File.Copy(Path.Combine(pTestPath, lUciName), Path.Combine(pTestPath, lSimID & lUciName), True) lUci = New HspfUci - lUci.ReadUci(lMsg, Path.Combine(pTestPath, SimID & uciName), -1, False, Path.Combine(pTestPath, pBaseName & ".ech")) + lUci.ReadUci(lMsg, Path.Combine(pTestPath, lSimID & lUciName), -1, False, Path.Combine(pTestPath, pBaseName & ".ech")) - Dim MFactorOrParmValue As Double = 0.0 + Dim lMFactorOrParmValue As Double = 0.0 - For Each Parm As ModelParameter In ListOfParameters + For Each lParm As ModelParameter In lListOfParameters Try - MFactorOrParmValue = CDbl(lcsvlinerecord((Parm.ParmID))) + lMFactorOrParmValue = CDbl(lCsvLineRecord((lParm.pParmID))) Catch - MFactorOrParmValue = Double.NaN + lMFactorOrParmValue = Double.NaN End Try - If Not (Double.IsNaN(MFactorOrParmValue) Or (Parm.ParmMultFactor = 0 AndAlso MFactorOrParmValue = 1.0)) Then - ChangeUCIParameterAndSave(lUci, Parm, MFactorOrParmValue) + If Not (Double.IsNaN(lMFactorOrParmValue) Or (lParm.pParmMultFactor = 0 AndAlso lMFactorOrParmValue = 1.0)) Then + ChangeUCIParameterAndSave(lUci, lParm, lMFactorOrParmValue) End If Next - loutputTable = ModelRunandReportAnswers(SimID, lUci, SimID & uciName, lExitCode, pBaseName, pTestPath, - aSDateJ, aEDateJ, YearsofSimulation, listOfOutputDSN, aHSPFEchofilename, loutputTable) + lOutputTable = ModelRunandReportAnswers(lSimID, lUci, lSimID & lUciName, lExitCode, pBaseName, pTestPath, + aSDateJ, aEDateJ, lYearsofSimulation, lListOfOutputDSN, aHSPFEchofilename, lOutputTable) - If DeleteUCIFiles = 1 Then - File.Delete(SimID & uciName) + If lDeleteUCIFiles = 1 Then + File.Delete(lSimID & lUciName) End If - Loop While lcsvRecordIndex < lSpecificationFileRecordsNew.Count - 1 + Loop While lCsvRecordIndex < lSpecificationFileRecordsNew.Count - 1 Dim lOutputFile2 As StreamWriter = File.CreateText(Path.Combine(pTestPath, "MultiSimOutput.xml")) - loutputTable.WriteXml(lOutputFile2) + lOutputTable.WriteXml(lOutputFile2) 'For Each TableRow As DataRow In loutputTable.Rows 'Writing the table contents ' TextToWrite = "" ' For Each TableColumn As DataColumn In loutputTable.Columns @@ -257,33 +254,33 @@ You can edit this specification file and add more parameters and outputs.", vbOK 'Next TableRow 'lOutputFile.Close() lOutputFile2.Close() - End Sub + Private Function ReadCSVFile(aSensitivitySpecificationFile As String) Dim lSensitivityRecordsNew As New ArrayList() - Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(aSensitivitySpecificationFile) - Dim lines() As String = {} - If System.IO.File.Exists(aSensitivitySpecificationFile) Then - MyReader.TextFieldType = FileIO.FieldType.Delimited - MyReader.SetDelimiters(",") - Dim CurrentRow As String() - - While Not MyReader.EndOfData + Using lMyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(aSensitivitySpecificationFile) + Dim lLines() As String = {} + If File.Exists(aSensitivitySpecificationFile) Then + lMyReader.TextFieldType = FileIO.FieldType.Delimited + lMyReader.SetDelimiters(",") + Dim lCurrentRow As String() + + While Not lMyReader.EndOfData Try - If (MyReader.PeekChars(10000).Contains("***") Or - Trim(MyReader.PeekChars(10000)) = "" Or - Trim(MyReader.PeekChars(10000).ToLower.StartsWith("parameter")) Or - Trim(MyReader.PeekChars(10000).ToLower.StartsWith("parmid")) Or - Trim(MyReader.PeekChars(10000).ToLower.StartsWith(","))) Then - CurrentRow = MyReader.ReadFields + If (lMyReader.PeekChars(10000).Contains("***") Or + Trim(lMyReader.PeekChars(10000)) = "" Or + Trim(lMyReader.PeekChars(10000).ToLower.StartsWith("parameter")) Or + Trim(lMyReader.PeekChars(10000).ToLower.StartsWith("parmid")) Or + Trim(lMyReader.PeekChars(10000).ToLower.StartsWith(","))) Then + lCurrentRow = lMyReader.ReadFields Else - CurrentRow = MyReader.ReadFields + lCurrentRow = lMyReader.ReadFields Dim i As Integer = 0 - For Each testtring As String In CurrentRow - CurrentRow(i) = testtring + For Each testtring As String In lCurrentRow + lCurrentRow(i) = testtring i += 1 Next - lSensitivityRecordsNew.Add(CurrentRow) + lSensitivityRecordsNew.Add(lCurrentRow) End If Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException @@ -310,20 +307,20 @@ You can edit this specification file and add more parameters and outputs.", vbOK Dim lOperLowerRange As Integer = -1 Dim lOperUpperRange As Integer = -1 Try - lOperLowerRange = CInt(aParm.ParmOperationName.Split("-")(0)) - lOperUpperRange = CInt(aParm.ParmOperationName.Split("-")(1)) + lOperLowerRange = CInt(aParm.pParmOperationName.Split("-")(0)) + lOperUpperRange = CInt(aParm.pParmOperationName.Split("-")(1)) Logger.Dbg("Range of operaion is provided") Catch ex As Exception Logger.Dbg("Range of Operations is not provided") End Try Select Case True - Case aParm.ParmTable.Contains("MASS-LINK") + Case aParm.pParmTable.Contains("MASS-LINK") Dim lMassLinkID As Integer - lMassLinkID = aParm.ParmOccurence + lMassLinkID = aParm.pParmOccurence Dim lMassLinkParts(7) As String - If aParm.ParmName.Length > 0 Then - lMassLinkParts = aParm.ParmName.Split(":") + If aParm.pParmName.Length > 0 Then + lMassLinkParts = aParm.pParmName.Split(":") ReDim Preserve lMassLinkParts(7) End If @@ -340,7 +337,7 @@ You can edit this specification file and add more parameters and outputs.", vbOK (lMasslink.Target.MemSub1 = lMassLinkParts(6) Or IsNothing(lMassLinkParts(6))) AndAlso (lMasslink.Target.MemSub2 = lMassLinkParts(7) Or IsNothing(lMassLinkParts(7))) Then - If aParm.ParmMultFactor = 1 Then + If aParm.pParmMultFactor = 1 Then lMasslink.MFact = HspfTable.NumFmtRE(lMasslink.MFact * aMFactorOrParmValue, 5) Else lMasslink.MFact = HspfTable.NumFmtRE(aMFactorOrParmValue, 5) @@ -349,92 +346,92 @@ You can edit this specification file and add more parameters and outputs.", vbOK End If Next - Case aParm.ParmTable.Contains("EXTNL") + Case aParm.pParmTable.Contains("EXTNL") - If aParm.ParmOperationType.ToLower = "point" Then + If aParm.pParmOperationType.ToLower = "point" Then Dim lConnections(3) As String - If aParm.ParmName.Length > 0 Then - lConnections = aParm.ParmName.Split(":") + If aParm.pParmName.Length > 0 Then + lConnections = aParm.pParmName.Split(":") For Each lID As HspfOperation In aUCI.OpnBlks("RCHRES").Ids - For Each lpointsource As HspfPointSource In lID.PointSources - If lpointsource.Target.Group = "INFLOW" AndAlso lpointsource.Target.Member = lConnections(0) AndAlso - lpointsource.Target.MemSub1 = lConnections(1) AndAlso lpointsource.Target.MemSub2 = lConnections(2) AndAlso - (lID.Id = aParm.ParmOperationNumber OrElse lID.Description = aParm.ParmOperationName OrElse + For Each lPointSource As HspfPointSource In lID.PointSources + If lPointSource.Target.Group = "INFLOW" AndAlso lPointSource.Target.Member = lConnections(0) AndAlso + lPointSource.Target.MemSub1 = lConnections(1) AndAlso lPointSource.Target.MemSub2 = lConnections(2) AndAlso + (lID.Id = aParm.pParmOperationNumber OrElse lID.Description = aParm.pParmOperationName OrElse (lID.Id >= lOperLowerRange AndAlso lID.Id <= lOperUpperRange) OrElse - (aParm.ParmOperationNumber = 0 AndAlso aParm.ParmOperationName = "")) Then - If aParm.ParmMultFactor = 1 Then - lpointsource.MFact = HspfTable.NumFmtRE(lpointsource.MFact * aMFactorOrParmValue, 5) + (aParm.pParmOperationNumber = 0 AndAlso aParm.pParmOperationName = "")) Then + If aParm.pParmMultFactor = 1 Then + lPointSource.MFact = HspfTable.NumFmtRE(lPointSource.MFact * aMFactorOrParmValue, 5) Else - lpointsource.MFact = HspfTable.NumFmtRE(aMFactorOrParmValue, 5) + lPointSource.MFact = HspfTable.NumFmtRE(aMFactorOrParmValue, 5) End If End If Next Next End If - ElseIf aParm.ParmOperationType.ToLower = "point_ts" Then + ElseIf aParm.pParmOperationType.ToLower = "point_ts" Then Dim lConnections(3) As String - If aParm.ParmName.Length > 0 Then - lConnections = aParm.ParmName.Split(":") + If aParm.pParmName.Length > 0 Then + lConnections = aParm.pParmName.Split(":") For Each lID As HspfOperation In aUCI.OpnBlks("RCHRES").Ids - For Each lpointsource As HspfPointSource In lID.PointSources - If lpointsource.Target.Group = "INFLOW" AndAlso lpointsource.Target.Member = lConnections(0) AndAlso - lpointsource.Target.MemSub1 = lConnections(1) AndAlso lpointsource.Target.MemSub2 = lConnections(2) AndAlso - (lID.Id = aParm.ParmOperationNumber OrElse lID.Description = aParm.ParmOperationName OrElse - (aParm.ParmOperationNumber = 0 AndAlso aParm.ParmOperationName = "")) Then - lpointsource.Source.VolId = aMFactorOrParmValue + For Each lPointSource As HspfPointSource In lID.PointSources + If lPointSource.Target.Group = "INFLOW" AndAlso lPointSource.Target.Member = lConnections(0) AndAlso + lPointSource.Target.MemSub1 = lConnections(1) AndAlso lPointSource.Target.MemSub2 = lConnections(2) AndAlso + (lID.Id = aParm.pParmOperationNumber OrElse lID.Description = aParm.pParmOperationName OrElse + (aParm.pParmOperationNumber = 0 AndAlso aParm.pParmOperationName = "")) Then + lPointSource.Source.VolId = aMFactorOrParmValue End If Next Next End If End If - Dim MetSegRec As Integer = -1 + Dim lMetSegRec As Integer = -1 For Each lMetSeg As HspfMetSeg In aUCI.MetSegs - Select Case aParm.ParmName.ToLower + Select Case aParm.pParmName.ToLower Case "prec" - MetSegRec = 0 + lMetSegRec = 0 Case "atem" - MetSegRec = 2 + lMetSegRec = 2 Case "solr" - MetSegRec = 5 + lMetSegRec = 5 Case Else - MetSegRec = -1 + lMetSegRec = -1 End Select - If MetSegRec = -1 Then Exit For + If lMetSegRec = -1 Then Exit For Try - If aParm.ParmMultFactor = 1 Then - lMetSeg.MetSegRecs(MetSegRec).MFactP = HspfTable.NumFmtRE(lMetSeg.MetSegRecs(MetSegRec).MFactP * aMFactorOrParmValue, 5) + If aParm.pParmMultFactor = 1 Then + lMetSeg.MetSegRecs(lMetSegRec).MFactP = HspfTable.NumFmtRE(lMetSeg.MetSegRecs(lMetSegRec).MFactP * aMFactorOrParmValue, 5) - lMetSeg.MetSegRecs(MetSegRec).MFactR = HspfTable.NumFmtRE(lMetSeg.MetSegRecs(MetSegRec).MFactR * aMFactorOrParmValue, 5) + lMetSeg.MetSegRecs(lMetSegRec).MFactR = HspfTable.NumFmtRE(lMetSeg.MetSegRecs(lMetSegRec).MFactR * aMFactorOrParmValue, 5) Else - lMetSeg.MetSegRecs(MetSegRec).MFactP = HspfTable.NumFmtRE(aMFactorOrParmValue, 5) + lMetSeg.MetSegRecs(lMetSegRec).MFactP = HspfTable.NumFmtRE(aMFactorOrParmValue, 5) - lMetSeg.MetSegRecs(MetSegRec).MFactR = HspfTable.NumFmtRE(aMFactorOrParmValue, 5) + lMetSeg.MetSegRecs(lMetSegRec).MFactR = HspfTable.NumFmtRE(aMFactorOrParmValue, 5) End If Catch ex As Exception - Logger.Msg("Could not find the Table " & aParm.ParmTable & - " Parameter " & aParm.ParmName & " for " & lMetSeg.Name, MsgBoxStyle.Critical) + Logger.Msg("Could not find the Table " & aParm.pParmTable & + " Parameter " & aParm.pParmName & " for " & lMetSeg.Name, MsgBoxStyle.Critical) End End Try Next Case Else - For Each lOper As HspfOperation In aUCI.OpnBlks(aParm.ParmOperationType).Ids - If (lOper.Id = aParm.ParmOperationNumber OrElse lOper.Description = aParm.ParmOperationName OrElse + For Each lOper As HspfOperation In aUCI.OpnBlks(aParm.pParmOperationType).Ids + If (lOper.Id = aParm.pParmOperationNumber OrElse lOper.Description = aParm.pParmOperationName OrElse (lOper.Id >= lOperLowerRange AndAlso lOper.Id <= lOperUpperRange) OrElse - (aParm.ParmOperationNumber = 0 AndAlso aParm.ParmOperationName = "")) Then + (aParm.pParmOperationNumber = 0 AndAlso aParm.pParmOperationName = "")) Then Try Dim lTable As HspfTable - If aParm.ParmOccurence = 0 Or aParm.ParmOccurence = 1 Then - lTable = lOper.Tables(aParm.ParmTable) + If aParm.pParmOccurence = 0 Or aParm.pParmOccurence = 1 Then + lTable = lOper.Tables(aParm.pParmTable) Else - lTable = lOper.Tables(aParm.ParmTable & ":" & aParm.ParmOccurence) + lTable = lOper.Tables(aParm.pParmTable & ":" & aParm.pParmOccurence) End If @@ -442,27 +439,27 @@ You can edit this specification file and add more parameters and outputs.", vbOK For Mon = 0 To 11 'For monthly parameters, only a multiplication factor can be provided lTable.Parms(Mon).Value = HspfTable.NumFmtRE(lTable.Parms(Mon).Value * aMFactorOrParmValue, 5) - If (lTable.Parms(Mon).Value < aParm.ParmLow) Then - lTable.Parms(Mon).Value = aParm.ParmLow - ElseIf (lTable.Parms(Mon).Value > aParm.ParmHigh) Then - lTable.Parms(Mon).Value = aParm.ParmHigh + If (lTable.Parms(Mon).Value < aParm.pParmLow) Then + lTable.Parms(Mon).Value = aParm.pParmLow + ElseIf (lTable.Parms(Mon).Value > aParm.pParmHigh) Then + lTable.Parms(Mon).Value = aParm.pParmHigh End If Next Else - If aParm.ParmMultFactor = 1 Then - lTable.ParmValue(aParm.ParmName) = HspfTable.NumFmtRE(lTable.ParmValue(aParm.ParmName) * aMFactorOrParmValue, lTable.Parms(aParm.ParmName).Def.Length) + If aParm.pParmMultFactor = 1 Then + lTable.ParmValue(aParm.pParmName) = HspfTable.NumFmtRE(lTable.ParmValue(aParm.pParmName) * aMFactorOrParmValue, lTable.Parms(aParm.pParmName).Def.Length) Else - lTable.ParmValue(aParm.ParmName) = HspfTable.NumFmtRE(aMFactorOrParmValue, lTable.Parms(aParm.ParmName).Def.Length) + lTable.ParmValue(aParm.pParmName) = HspfTable.NumFmtRE(aMFactorOrParmValue, lTable.Parms(aParm.pParmName).Def.Length) End If - If (lTable.ParmValue(aParm.ParmName) < aParm.ParmLow) Then - lTable.ParmValue(aParm.ParmName) = aParm.ParmLow - ElseIf (lTable.ParmValue(aParm.ParmName) > aParm.ParmHigh) Then - lTable.ParmValue(aParm.ParmName) = aParm.ParmHigh + If (lTable.ParmValue(aParm.pParmName) < aParm.pParmLow) Then + lTable.ParmValue(aParm.pParmName) = aParm.pParmLow + ElseIf (lTable.ParmValue(aParm.pParmName) > aParm.pParmHigh) Then + lTable.ParmValue(aParm.pParmName) = aParm.pParmHigh End If End If Catch ex As Exception - Logger.Msg("Could not find the Table " & aParm.ParmTable & - " Parameter " & aParm.ParmName & " for " & lOper.Id, MsgBoxStyle.Critical) + Logger.Msg("Could not find the Table " & aParm.pParmTable & + " Parameter " & aParm.pParmName & " for " & lOper.Id, MsgBoxStyle.Critical) End End Try @@ -474,34 +471,34 @@ You can edit this specification file and add more parameters and outputs.", vbOK aUCI.Save() End Sub - Private Function ModelRunandReportAnswers(ByVal SimID As Integer, - ByVal lUci As atcUCI.HspfUci, - ByVal uciName As String, - ByVal lExitCode As Integer, - ByVal pBaseName As String, - ByVal pTestPath As String, + Private Function ModelRunandReportAnswers(ByVal aSimID As Integer, + ByVal aUci As atcUCI.HspfUci, + ByVal aUciName As String, + ByVal aExitCode As Integer, + ByVal aBaseName As String, + ByVal aTestPath As String, ByVal aSDateJ As Double, ByVal aEDateJ As Double, - ByVal YearsofSimulation As Single, + ByVal aYearsofSimulation As Single, ByVal aOutputDSN As atcCollection, ByRef aHSPFEchofileName As String, ByRef aOutputTable As DataTable) - lExitCode = LaunchProgram(pHSPFExe, pTestPath, "-1 -1 " & uciName) 'Run HSPF program + aExitCode = LaunchProgram(pHSPFExe, aTestPath, "-1 -1 " & aUciName) 'Run HSPF program - Dim HSPFRan As Boolean = False + Dim lHSPFRan As Boolean = False Dim lRunMade As String - Dim echoFileInfo As System.IO.FileInfo + Dim lEchoFileInfo As System.IO.FileInfo If IO.File.Exists(aHSPFEchofileName) Then - echoFileInfo = New System.IO.FileInfo(aHSPFEchofileName) - lRunMade = echoFileInfo.LastWriteTime.ToString - Using echoFileReader As StreamReader = File.OpenText(aHSPFEchofileName) - While Not echoFileReader.EndOfStream - Dim nextLine As String = echoFileReader.ReadLine() - If Not nextLine.ToUpper.Contains("END OF JOB") Then - HSPFRan = False + lEchoFileInfo = New System.IO.FileInfo(aHSPFEchofileName) + lRunMade = lEchoFileInfo.LastWriteTime.ToString + Using lEchoFileReader As StreamReader = File.OpenText(aHSPFEchofileName) + While Not lEchoFileReader.EndOfStream + Dim lNextLine As String = lEchoFileReader.ReadLine() + If Not lNextLine.ToUpper.Contains("END OF JOB") Then + lHSPFRan = False Else - HSPFRan = True + lHSPFRan = True End If End While End Using @@ -513,330 +510,331 @@ You can edit this specification file and add more parameters and outputs.", vbOK Dim lOutputline As String = "" - If HSPFRan Then - Dim lWdmFileName As String = pBaseName & ".wdm" - Dim lOutWDMFileName As String = "MultiSim_" & pBaseName & ".wdm" + If lHSPFRan Then + Dim lWdmFileName As String = aBaseName & ".wdm" + Dim lOutWDMFileName As String = "MultiSim_" & aBaseName & ".wdm" Dim lWdmDataSource As atcWDM.atcDataSourceWDM Dim lWdmDataSource2 As atcWDM.atcDataSourceWDM - If atcDataManager.DataSources.Contains(pTestPath & lWdmFileName) Then - atcDataManager.RemoveDataSource(pTestPath & lWdmFileName) + If atcDataManager.DataSources.Contains(aTestPath & lWdmFileName) Then + atcDataManager.RemoveDataSource(aTestPath & lWdmFileName) End If - If atcDataManager.DataSources.Contains(pTestPath & lOutWDMFileName) Then - atcDataManager.RemoveDataSource(pTestPath & lOutWDMFileName) + If atcDataManager.DataSources.Contains(aTestPath & lOutWDMFileName) Then + atcDataManager.RemoveDataSource(aTestPath & lOutWDMFileName) End If - atcDataManager.OpenDataSource(pTestPath & lWdmFileName) - lWdmDataSource = atcDataManager.DataSourceBySpecification(pTestPath & lWdmFileName) - atcDataManager.OpenDataSource(pTestPath & lOutWDMFileName) - lWdmDataSource2 = atcDataManager.DataSourceBySpecification(pTestPath & lOutWDMFileName) + atcDataManager.OpenDataSource(aTestPath & lWdmFileName) + lWdmDataSource = atcDataManager.DataSourceBySpecification(aTestPath & lWdmFileName) + atcDataManager.OpenDataSource(aTestPath & lOutWDMFileName) + lWdmDataSource2 = atcDataManager.DataSourceBySpecification(aTestPath & lOutWDMFileName) If lWdmDataSource2 Is Nothing Then lWdmDataSource2 = New atcWDM.atcDataSourceWDM - lWdmDataSource2.Open(pTestPath & lOutWDMFileName) + lWdmDataSource2.Open(aTestPath & lOutWDMFileName) End If Dim lYearlyAttributes As New atcDataAttributes - Dim DatasetID As Integer = lWdmDataSource2.DataSets.Count - For Each WDMDataset As Integer In aOutputDSN + Dim lDatasetID As Integer = lWdmDataSource2.DataSets.Count + For Each lWDMDataset As Integer In aOutputDSN Try - Dim SimulatedTS As atcTimeseries = SubsetByDate(lWdmDataSource.DataSets.ItemByKey(WDMDataset), aSDateJ, aEDateJ, Nothing) + Dim lSimulatedTS As atcTimeseries = SubsetByDate(lWdmDataSource.DataSets.ItemByKey(lWDMDataset), aSDateJ, aEDateJ, Nothing) - DatasetID += 1 - If DatasetID < 10000 Then - SimulatedTS.Attributes.SetValue("ID", DatasetID) - SimulatedTS.Attributes.SetValue("Scenario", "SIMID" & SimID) + lDatasetID += 1 + If lDatasetID < 10000 Then + lSimulatedTS.Attributes.SetValue("ID", lDatasetID) + lSimulatedTS.Attributes.SetValue("Scenario", "SIMID" & aSimID) - lWdmDataSource2.AddDataset(SimulatedTS) + lWdmDataSource2.AddDataset(lSimulatedTS) End If - Dim AnnSimulatedTS As atcTimeseries = Aggregate(SimulatedTS, atcTimeUnit.TUYear, 1, atcTran.TranMax) + Dim lAnnSimulatedTS As atcTimeseries = Aggregate(lSimulatedTS, atcTimeUnit.TUYear, 1, atcTran.TranMax) - Dim row As DataRow - row = aOutputTable.NewRow - For Each TableColumn As DataColumn In aOutputTable.Columns - Dim ColumnName As String = TableColumn.ColumnName - Select Case ColumnName + Dim lRow As DataRow + lRow = aOutputTable.NewRow + For Each lTableColumn As DataColumn In aOutputTable.Columns + Dim lColumnName As String = lTableColumn.ColumnName + Select Case lColumnName Case "SimID" - row(ColumnName) = SimID + lRow(lColumnName) = aSimID Case "ID" - row(ColumnName) = WDMDataset + lRow(lColumnName) = lWDMDataset Case "AvAnnPeak" - row(ColumnName) = AnnSimulatedTS.Attributes.GetDefinedValue("Mean").Value + lRow(lColumnName) = lAnnSimulatedTS.Attributes.GetDefinedValue("Mean").Value Case "10%High" - row(ColumnName) = SimulatedTS.Attributes.GetDefinedValue("Sum").Value - SimulatedTS.Attributes.GetDefinedValue("%Sum90").Value + lRow(lColumnName) = lSimulatedTS.Attributes.GetDefinedValue("Sum").Value - lSimulatedTS.Attributes.GetDefinedValue("%Sum90").Value Case "25%High" - row(ColumnName) = SimulatedTS.Attributes.GetDefinedValue("Sum").Value - SimulatedTS.Attributes.GetDefinedValue("%Sum75").Value + lRow(lColumnName) = lSimulatedTS.Attributes.GetDefinedValue("Sum").Value - lSimulatedTS.Attributes.GetDefinedValue("%Sum75").Value Case "50%High" - row(ColumnName) = SimulatedTS.Attributes.GetDefinedValue("Sum").Value - SimulatedTS.Attributes.GetDefinedValue("%Sum50").Value + lRow(lColumnName) = lSimulatedTS.Attributes.GetDefinedValue("Sum").Value - lSimulatedTS.Attributes.GetDefinedValue("%Sum50").Value Case "max(30-day GeoMean)" - Dim lDailyTs As atcTimeseries = Aggregate(SimulatedTS, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) + Dim lDailyTs As atcTimeseries = Aggregate(lSimulatedTS, atcTimeUnit.TUDay, 1, atcTran.TranAverSame) If lDailyTs.Values.Count >= 30 Then - Dim GeoMean As New List(Of Double) + Dim lGeoMean As New List(Of Double) Dim lCount As Integer = 0 - Dim Test As Double = 0.0 + Dim lTest As Double = 0.0 For i As Integer = 1 To lDailyTs.Values.Count - 1 If lDailyTs.Value(i) > 0 Then - Test += Math.Log10(lDailyTs.Value(i)) + lTest += Math.Log10(lDailyTs.Value(i)) End If If i >= 30 Then - If lDailyTs.Value(i - 30) > 0 Then Test -= Math.Log10(lDailyTs.Value(i - 30)) + If lDailyTs.Value(i - 30) > 0 Then lTest -= Math.Log10(lDailyTs.Value(i - 30)) - GeoMean.Add(10 ^ (Test / 30)) + lGeoMean.Add(10 ^ (lTest / 30)) End If Next i - Test = 0.0 - For Each lValue As Double In GeoMean - If lValue > Test Then Test = lValue + lTest = 0.0 + For Each lValue As Double In lGeoMean + If lValue > lTest Then lTest = lValue Next - row(ColumnName) = Test + lRow(lColumnName) = lTest End If Case Else Try - row(ColumnName) = SimulatedTS.Attributes.GetDefinedValue(ColumnName).Value + lRow(lColumnName) = lSimulatedTS.Attributes.GetDefinedValue(lColumnName).Value Catch ex As Exception - Logger.Dbg("The " & ColumnName & " could not be calculated for DSN " & WDMDataset) + Logger.Dbg("The " & lColumnName & " could not be calculated for DSN " & lWDMDataset) End Try End Select - Next TableColumn - aOutputTable.Rows.Add(row) + Next lTableColumn + aOutputTable.Rows.Add(lRow) Catch - Logger.Dbg("Could not compute statistics for SimID:" & SimID & " And DatasetID:" & WDMDataset) + Logger.Dbg("Could not compute statistics for SimID:" & aSimID & " And DatasetID:" & lWDMDataset) End Try - Next WDMDataset + Next lWDMDataset lWdmDataSource.Clear() lWdmDataSource2.Clear() Else - Logger.Dbg("The simulation " & SimID & " didn't complete successfully!") + Logger.Dbg("The simulation " & aSimID & " didn't complete successfully!") End If - Logger.Status("Number of simulations complete: " & SimID) + Logger.Status("Number of simulations complete: " & aSimID) Return aOutputTable End Function + Private Function Observed() 'Possible function to save observed values in future. Return "Observed" End Function Private Function AddOutputTableColumns(ByRef aDataTable As Data.DataTable) As DataTable - Dim column As DataColumn - column = New DataColumn() - column.DataType = Type.GetType("System.Int32") - column.ColumnName = "SimID" - column.Caption = "Simulation ID" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Int32") - column.ColumnName = "ID" - column.Caption = "DataSet ID" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "Sum" - column.Caption = "Sum" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "mean" - column.Caption = "Mean" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "SumAnnual" - column.Caption = "Annual Sum" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "geometric mean" - column.Caption = "Geometric Mean" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "max(30-day GeoMean)" - column.Caption = "Max(30-day Geometric Mean)" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "AvAnnPeak" - column.Caption = "Average Annual Peak" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "10%High" - column.Caption = "Sum of 10% High" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "25%High" - column.Caption = "Sum of 25% High" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "50%High" - column.Caption = "Sum of 50% High" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%Sum50" - column.Caption = "Sum of 50% Low" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%Sum25" - column.Caption = "Sum of 25% Low" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%Sum10" - column.Caption = "Sum of 10% Low" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%Sum05" - column.Caption = "Sum of 5% Low" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%Sum02" - column.Caption = "Sum of 2% Low" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%0.10" - column.Caption = "0.1 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%1.00" - column.Caption = "1 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%2.00" - column.Caption = "2 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%2.50" - column.Caption = "2.5 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%5.00" - column.Caption = "5 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%10.00" - column.Caption = "10 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%20.00" - column.Caption = "20 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%30.00" - column.Caption = "30 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%40.00" - column.Caption = "40 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%50.00" - column.Caption = "50 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%60.00" - column.Caption = "60 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%70.00" - column.Caption = "70 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%80.00" - column.Caption = "80 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%90.00" - column.Caption = "90 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%95.00" - column.Caption = "95 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%97.5" - column.Caption = "97.5 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%98.00" - column.Caption = "98 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%99.00" - column.Caption = "99 Percentile" - aDataTable.Columns.Add(column) - - column = New DataColumn() - column.DataType = Type.GetType("System.Double") - column.ColumnName = "%99.90" - column.Caption = "99.9 Percentile" - aDataTable.Columns.Add(column) + Dim lColumn As DataColumn + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Int32") + lColumn.ColumnName = "SimID" + lColumn.Caption = "Simulation ID" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Int32") + lColumn.ColumnName = "ID" + lColumn.Caption = "DataSet ID" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "Sum" + lColumn.Caption = "Sum" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "mean" + lColumn.Caption = "Mean" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "SumAnnual" + lColumn.Caption = "Annual Sum" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "geometric mean" + lColumn.Caption = "Geometric Mean" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "max(30-day GeoMean)" + lColumn.Caption = "Max(30-day Geometric Mean)" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "AvAnnPeak" + lColumn.Caption = "Average Annual Peak" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "10%High" + lColumn.Caption = "Sum of 10% High" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "25%High" + lColumn.Caption = "Sum of 25% High" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "50%High" + lColumn.Caption = "Sum of 50% High" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%Sum50" + lColumn.Caption = "Sum of 50% Low" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%Sum25" + lColumn.Caption = "Sum of 25% Low" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%Sum10" + lColumn.Caption = "Sum of 10% Low" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%Sum05" + lColumn.Caption = "Sum of 5% Low" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%Sum02" + lColumn.Caption = "Sum of 2% Low" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%0.10" + lColumn.Caption = "0.1 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%1.00" + lColumn.Caption = "1 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%2.00" + lColumn.Caption = "2 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%2.50" + lColumn.Caption = "2.5 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%5.00" + lColumn.Caption = "5 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%10.00" + lColumn.Caption = "10 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%20.00" + lColumn.Caption = "20 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%30.00" + lColumn.Caption = "30 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%40.00" + lColumn.Caption = "40 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%50.00" + lColumn.Caption = "50 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%60.00" + lColumn.Caption = "60 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%70.00" + lColumn.Caption = "70 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%80.00" + lColumn.Caption = "80 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%90.00" + lColumn.Caption = "90 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%95.00" + lColumn.Caption = "95 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%97.5" + lColumn.Caption = "97.5 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%98.00" + lColumn.Caption = "98 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%99.00" + lColumn.Caption = "99 Percentile" + aDataTable.Columns.Add(lColumn) + + lColumn = New DataColumn() + lColumn.DataType = Type.GetType("System.Double") + lColumn.ColumnName = "%99.90" + lColumn.Caption = "99.9 Percentile" + aDataTable.Columns.Add(lColumn) Return aDataTable End Function diff --git a/HSPEXP/StartUp.vb b/HSPEXP/StartUp.vb index a80b54efe..22e9f5ef4 100644 --- a/HSPEXP/StartUp.vb +++ b/HSPEXP/StartUp.vb @@ -212,19 +212,19 @@ Public Class StartUp Private Sub StartUp_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load - Dim WinHspfLtDir As String = PathNameOnly(Reflection.Assembly.GetEntryAssembly.Location) & g_PathChar & "WinHSPFLt" - Logger.Dbg("Located WinHSPFLt at " & WinHspfLtDir) + Dim lWinHspfLtDir As String = PathNameOnly(Reflection.Assembly.GetEntryAssembly.Location) & g_PathChar & "WinHSPFLt" + Logger.Dbg("Located WinHSPFLt at " & lWinHspfLtDir) Try 'Set Environmental Variable Dim lEnvPath As String = Environment.GetEnvironmentVariable("PATH") - If Not lEnvPath.ToLowerInvariant.Contains(WinHspfLtDir.ToLowerInvariant) Then - System.Environment.SetEnvironmentVariable("PATH", WinHspfLtDir & ";" & lEnvPath) + If Not lEnvPath.ToLowerInvariant.Contains(lWinHspfLtDir.ToLowerInvariant) Then + System.Environment.SetEnvironmentVariable("PATH", lWinHspfLtDir & ";" & lEnvPath) End If Catch exSetEnv As Exception Logger.Dbg("Could not add WinHspfLtDir to PATH " & exSetEnv.Message) End Try Try - Dim lHassentPath As String = IO.Path.Combine(WinHspfLtDir, "hass_ent.dll") + Dim lHassentPath As String = IO.Path.Combine(lWinHspfLtDir, "hass_ent.dll") If LoadLibraryEx(lHassentPath, IntPtr.Zero, LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH) = 0 Then Logger.Msg("Missing HSPF Library at install location:" & vbCrLf & lHassentPath) End @@ -232,8 +232,8 @@ Public Class StartUp Catch ex As Exception End Try - HSPFOutputReports.pHSPFExe = IO.Path.Combine(WinHspfLtDir, "WinHspfLt.exe") - atcWDM.atcDataSourceWDM.HSPFMsgFilename = IO.Path.Combine(WinHspfLtDir, "hspfmsg.wdm") + HSPFOutputReports.pHSPFExe = IO.Path.Combine(lWinHspfLtDir, "WinHspfLt.exe") + atcWDM.atcDataSourceWDM.HSPFMsgFilename = IO.Path.Combine(lWinHspfLtDir, "hspfmsg.wdm") Logger.Dbg(Now & " Attempting to open hspfmsg.wdm") pHspfMsg = New atcUCI.HspfMsg @@ -347,9 +347,6 @@ Public Class StartUp chkWASP.Enabled = True chkBathtub.Enabled = True End If - - - End Sub ' Reset all the controls to the user's default Control color. diff --git a/HSPEXP/modListUCIParameters.vb b/HSPEXP/modListUCIParameters.vb index 795c83d9a..a4e097fc5 100644 --- a/HSPEXP/modListUCIParameters.vb +++ b/HSPEXP/modListUCIParameters.vb @@ -8,114 +8,113 @@ Public Module modListUCIParameters Private pIMPLND As atcCollection Private pRCHRES As atcCollection Private pBlockDefs As HspfBlockDefs - Sub ListReachParameters(ByVal aHSPFUCI As HspfUci, ByVal lOutputFolder As String) + Sub ListReachParameters(ByVal aHSPFUCI As HspfUci, ByVal aOutputFolder As String) pPERLND = New atcCollection pIMPLND = New atcCollection pRCHRES = New atcCollection - Dim s As String = "" - Dim ModelName As String = IO.Path.GetFileNameWithoutExtension(aHSPFUCI.Name) - Dim ParameterList As System.IO.StreamWriter - Dim NumberOfReaches As Integer = 0 - ParameterList = My.Computer.FileSystem.OpenTextFileWriter(lOutputFolder & "\" & ModelName & "_RCHRES_ParameterList.txt", False) - ParameterList.WriteLine("Parameter list for " & ModelName) + + Dim lModelName As String = IO.Path.GetFileNameWithoutExtension(aHSPFUCI.Name) + Dim lParameterList As System.IO.StreamWriter + Dim lNumberOfReaches As Integer = 0 + lParameterList = My.Computer.FileSystem.OpenTextFileWriter(aOutputFolder & "\" & lModelName & "_RCHRES_ParameterList.txt", False) + lParameterList.WriteLine("Parameter list for " & lModelName) For Each lOperation As HspfOperation In aHSPFUCI.OpnSeqBlock.Opns If lOperation.Name = "RCHRES" AndAlso Not pRCHRES.Contains(lOperation.Id) Then pRCHRES.Add(lOperation.Id) - NumberOfReaches += 1 + lNumberOfReaches += 1 End If Next - ParameterList.WriteLine("Number Of Reaches in the UCI File = " & NumberOfReaches) - ParameterList.WriteLine("OperationType, OperationID, TableName, TableOccurrence, PrameterName, ParameterValue") + lParameterList.WriteLine("Number Of Reaches in the UCI File = " & lNumberOfReaches) + lParameterList.WriteLine("OperationType, OperationID, 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 & ", " & + lParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & lTable.Name & ", " & lTable.OccurIndex & ", " & lparm.Name & ", " & lparm.Value) Next Next End If Next - ParameterList.Close() - + lParameterList.Close() End Sub - Sub ListPERLNDParameters(ByVal aHSPFUCI As HspfUci, ByVal lOutputFolder As String) + + Sub ListPERLNDParameters(ByVal aHSPFUCI As HspfUci, ByVal aOutputFolder As String) pPERLND = New atcCollection pIMPLND = New atcCollection pRCHRES = New atcCollection - Dim s As String = "" - Dim ModelName As String = IO.Path.GetFileNameWithoutExtension(aHSPFUCI.Name) - Dim ParameterList As System.IO.StreamWriter - Dim NumberOfPERLNDOperations As Integer = 0 - ParameterList = My.Computer.FileSystem.OpenTextFileWriter(lOutputFolder & "\" & ModelName & "_PERLND_ParameterList.txt", False) - ParameterList.WriteLine("Parameter list for " & ModelName) + + Dim lModelName As String = IO.Path.GetFileNameWithoutExtension(aHSPFUCI.Name) + Dim lParameterList As System.IO.StreamWriter + Dim lNumberOfPERLNDOperations As Integer = 0 + lParameterList = My.Computer.FileSystem.OpenTextFileWriter(aOutputFolder & "\" & lModelName & "_PERLND_ParameterList.txt", False) + lParameterList.WriteLine("Parameter list for " & lModelName) For Each lOperation As HspfOperation In aHSPFUCI.OpnSeqBlock.Opns If lOperation.Name = "PERLND" AndAlso Not pRCHRES.Contains(lOperation.Id) Then pRCHRES.Add(lOperation.Id) - NumberOfPERLNDOperations += 1 + lNumberOfPERLNDOperations += 1 End If Next - ParameterList.WriteLine("Number Of PERLND Operations in the UCI File = " & NumberOfPERLNDOperations) - ParameterList.WriteLine("OperationType, OperationID, TableName, Table Occurrence Number, Table Occurrence Count, ParameterName, ParameterValue") + lParameterList.WriteLine("Number Of PERLND Operations in the UCI File = " & lNumberOfPERLNDOperations) + lParameterList.WriteLine("OperationType, OperationID, TableName, Table Occurrence Number, Table Occurrence Count, 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 + For Each lParm As HspfParm In lTable.Parms 'If lparm.Value.Contains("ORTHO") Then Stop 'If lTable.OccurIndex > 1 Then Stop - ParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & - lTable.Name & "," & lTable.OccurNum & ", " & lTable.OccurCount & ", " & lparm.Name & ", " & lparm.Value) + lParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & + lTable.Name & "," & lTable.OccurNum & ", " & lTable.OccurCount & ", " & lParm.Name & ", " & lParm.Value) Next Next End If Next - ParameterList.Close() - + lParameterList.Close() End Sub - Sub ListIMPLNDParameters(ByVal aHSPFUCI As HspfUci, ByVal lOutputFolder As String) + + Sub ListIMPLNDParameters(ByVal aHSPFUCI As HspfUci, ByVal aOutputFolder As String) pPERLND = New atcCollection pIMPLND = New atcCollection pRCHRES = New atcCollection - Dim s As String = "" - Dim ModelName As String = IO.Path.GetFileNameWithoutExtension(aHSPFUCI.Name) - Dim ParameterList As System.IO.StreamWriter - Dim NumberOfReaches As Integer = 0 - ParameterList = My.Computer.FileSystem.OpenTextFileWriter(lOutputFolder & "\" & ModelName & "_IMPLND_ParameterList.txt", False) - ParameterList.WriteLine("Parameter list for " & ModelName) + + Dim lModelName As String = IO.Path.GetFileNameWithoutExtension(aHSPFUCI.Name) + Dim lParameterList As System.IO.StreamWriter + Dim lNumberOfReaches As Integer = 0 + lParameterList = My.Computer.FileSystem.OpenTextFileWriter(aOutputFolder & "\" & lModelName & "_IMPLND_ParameterList.txt", False) + lParameterList.WriteLine("Parameter list for " & lModelName) For Each lOperation As HspfOperation In aHSPFUCI.OpnSeqBlock.Opns If lOperation.Name = "IMPLND" AndAlso Not pRCHRES.Contains(lOperation.Id) Then pRCHRES.Add(lOperation.Id) - NumberOfReaches += 1 + lNumberOfReaches += 1 End If Next - ParameterList.WriteLine("Number Of IMPLND Operations in the UCI File = " & NumberOfReaches) - ParameterList.WriteLine("OperationType, OperationID, TableName, Table Occurrence Number, Table Occurrence Count, ParameterName, ParameterValue") + lParameterList.WriteLine("Number Of IMPLND Operations in the UCI File = " & lNumberOfReaches) + lParameterList.WriteLine("OperationType, OperationID, TableName, Table Occurrence Number, Table Occurrence Count, 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 & ", " & + lParameterList.WriteLine(lOperation.Name & ", " & lOperation.Id & ", " & lTable.Name & "," & lTable.OccurNum & ", " & lTable.OccurCount & ", " & lparm.Name & ", " & lparm.Value) Next Next End If Next - ParameterList.Close() - + lParameterList.Close() End Sub