diff --git a/instat/dlgClimaticCheckDataRain.vb b/instat/dlgClimaticCheckDataRain.vb index e7eebcc101f..9aa3211483a 100644 --- a/instat/dlgClimaticCheckDataRain.vb +++ b/instat/dlgClimaticCheckDataRain.vb @@ -23,7 +23,7 @@ Public Class dlgClimaticCheckDataRain Private clsGroupByFunc, clsRainFilterFunc, clsRunCalcFunc, clsListFunc, clsGroupByMonth As New RFunction 'Large Private clsLargeTestCalcFunc As New RFunction - Private clsLargeOperator, clsOrLargeOperator, clsLargeLessOperator, clsOutlierOperator, clsRainyDaysOperator As New ROperator + Private clsLargeOperator, clsOrLargeOperator, clsLargeLessOperator, clsRainyDaysOperator As New ROperator Private clsManipList As New RFunction Private strLargeTest As String = "Large" 'Same @@ -44,8 +44,14 @@ Public Class dlgClimaticCheckDataRain Private clsOrOperator As New ROperator Private clsListSubCalc As New RFunction 'Outlier - Private clsListForOutlierManipulations, clsRainyDaysFunc, clsOutlierLimitFunc, clsOutlierLimitValueCalcFunc, clsOutlierlimitTestFunc, clsListOutlier As New RFunction - Private strOutlierTest As String = "Outlier" + Private clsListForOutlierManipulations, clsRainyDaysFunc, clsUpperOutlierLimitFunc, clsUpperOutlierLimitValueCalcFunc, clsUpperOutlierlimitTestFunc, clsUpperListOutlier As New RFunction + Private clsUpperOutlierOperator As New ROperator + Private strUpperOutlierTest As String = "upper_outlier" + + Private clsLowerOutlierLimitValueCalcFunc, clsLowerOutlierlimitTestFunc, clsLowerListOutlier, clsLowerOutlierLimitFunc As New RFunction + Private clsLowerOutlierOperator As New ROperator + Private strLowerOutlierTest As String = "lower_outlier" + Private clsOutliersOperator As New ROperator Private Sub dlgRain_Load(sender As Object, e As EventArgs) Handles MyBase.Load If bFirstload Then @@ -73,7 +79,6 @@ Public Class dlgClimaticCheckDataRain ucrChkDryMonth.Enabled = False ucrChkOmitZero.Checked = True - ucrReceiverStation.Selector = ucrSelectorRain ucrReceiverStation.SetClimaticType("station") ucrReceiverStation.bAutoFill = True @@ -114,10 +119,10 @@ Public Class dlgClimaticCheckDataRain ucrNudSame.SetParameter(New RParameter("right", 1, bNewIncludeArgumentName:=False)) ucrNudWetDays.SetParameter(New RParameter("right", 1, bNewIncludeArgumentName:=False)) - ucrChkOutlier.SetParameter(New RParameter("outlier.limit", strOutlierTest, 1), bNewChangeParameterValue:=False) + ucrChkOutlier.SetParameter(New RParameter("outlier.limit", strUpperOutlierTest, 1), bNewChangeParameterValue:=False) ucrChkOutlier.SetText("Outlier") - ucrNudCoeff.SetParameter(New RParameter("coeff", 1)) + ucrNudCoeff.SetParameter(New RParameter("coef", 1)) ucrNudCoeff.DecimalPlaces = 1 ucrNudCoeff.Increment = 0.1 ucrNudCoeff.SetRDefault("1.5") @@ -155,7 +160,8 @@ Public Class dlgClimaticCheckDataRain Private Sub SetDefaults() Dim strLengths As String = "lengths" - Dim strOutlier_Limit As String = "outlier_limit" + Dim strUpperOutlierLimit As String = "outlier_upper_limit" + Dim strLowerOutlierLimit As String = "outlier_lower_limit" clsRleFunc = New RFunction clsRepFunc = New RFunction clsAsNumericFunc = New RFunction @@ -167,7 +173,7 @@ Public Class dlgClimaticCheckDataRain clsLargeLessOperator = New ROperator clsRainyDaysOperator.Clear() - clsOutlierOperator.Clear() + clsUpperOutlierOperator.Clear() clsOrLargeOperator.Clear() clsGreaterSameOperator.Clear() clsGreatOperator.Clear() @@ -178,11 +184,11 @@ Public Class dlgClimaticCheckDataRain clsCumulativeTestFunc.Clear() clsSameTestFunc.Clear() clsCumulativeCalcFunc.Clear() - clsOutlierlimitTestFunc.Clear() - 'clsOutlierLimitValueCalcFunc.Cleear() + clsUpperOutlierlimitTestFunc.Clear() + clsListForOutlierManipulations.Clear() ucrSelectorRain.Reset() - ucrReceiverStation.SetMeAsReceiver() + ucrReceiverElement.SetMeAsReceiver() 'Group Function clsGroupByFunc.SetRCommand("instat_calculation$new") @@ -300,6 +306,7 @@ Public Class dlgClimaticCheckDataRain clsCumulativeList.SetRCommand("list") clsCumulativeList.AddParameter("sub1", clsRFunctionParameter:=clsCumulativeCalcFunc, bIncludeArgumentName:=False) + 'Group By Month clsGroupByMonth.SetRCommand("instat_calculation$new") clsGroupByMonth.AddParameter("type", Chr(34) & "by" & Chr(34), iPosition:=0) @@ -307,7 +314,7 @@ Public Class dlgClimaticCheckDataRain clsListForOutlierManipulations.SetRCommand("list") clsListForOutlierManipulations.AddParameter("sub1", clsRFunctionParameter:=clsGroupByMonth, bIncludeArgumentName:=False, iPosition:=0) - clsListForOutlierManipulations.AddParameter("sub2", clsRFunctionParameter:=clsRainyDaysFunc, bIncludeArgumentName:=False, iPosition:=1) + 'clsListForOutlierManipulations.AddParameter("sub2", clsRFunctionParameter:=clsRainyDaysFunc, bIncludeArgumentName:=False, iPosition:=1) 'Rainy Days Operator clsRainyDaysOperator.SetOperation(">") @@ -321,32 +328,64 @@ Public Class dlgClimaticCheckDataRain clsRainyDaysFunc.AddParameter("function_exp", clsROperatorParameter:=clsRainyDaysOperator, iPosition:=0) clsRainyDaysFunc.SetAssignTo("rainydays_filter") - 'Outlier Limit function - clsOutlierLimitValueCalcFunc.SetRCommand("instat_calculation$new") - clsOutlierLimitValueCalcFunc.AddParameter("type", Chr(34) & "calculation" & Chr(34), iPosition:=0) - clsOutlierLimitValueCalcFunc.AddParameter("function_exp", clsRFunctionParameter:=clsOutlierLimitFunc, iPosition:=1) - clsOutlierLimitValueCalcFunc.AddParameter("result_name", Chr(34) & strOutlier_Limit & Chr(34), iPosition:=4) - clsOutlierLimitValueCalcFunc.AddParameter("save", "0", iPosition:=5) - clsOutlierLimitValueCalcFunc.SetAssignTo("outlier_limit") - clsOutlierLimitFunc.SetRCommand("summary_outlier_limit") - clsOutlierLimitFunc.bToScriptAsRString = True - clsOutlierLimitFunc.AddParameter("bskewedcalc", "TRUE") + 'upper Outlier Limit function + clsUpperOutlierLimitValueCalcFunc.SetRCommand("instat_calculation$new") + clsUpperOutlierLimitValueCalcFunc.AddParameter("type", Chr(34) & "calculation" & Chr(34), iPosition:=0) + clsUpperOutlierLimitValueCalcFunc.AddParameter("function_exp", clsRFunctionParameter:=clsUpperOutlierLimitFunc, iPosition:=1) + clsUpperOutlierLimitValueCalcFunc.AddParameter("result_name", Chr(34) & strUpperOutlierLimit & Chr(34), iPosition:=4) + clsUpperOutlierLimitValueCalcFunc.SetAssignTo("outlier_upper_limit") + clsUpperOutlierLimitFunc.SetRCommand("summary_outlier_limit") + clsUpperOutlierLimitFunc.bToScriptAsRString = True + clsUpperOutlierLimitFunc.AddParameter("bskewedcalc", "TRUE") + + 'Outlier Operator + clsUpperOutlierOperator.SetOperation(">") + clsUpperOutlierOperator.AddParameter("right", strUpperOutlierLimit, iPosition:=1) + clsUpperOutlierOperator.bBrackets = False + clsUpperOutlierOperator.bToScriptAsRString = True + + clsUpperOutlierlimitTestFunc.SetRCommand("instat_calculation$new") + clsUpperOutlierlimitTestFunc.AddParameter("type", Chr(34) & "calculation" & Chr(34), iPosition:=0) + clsUpperOutlierlimitTestFunc.AddParameter("function_exp", clsROperatorParameter:=clsUpperOutlierOperator, iPosition:=1) + clsUpperOutlierlimitTestFunc.AddParameter("result_name", Chr(34) & strUpperOutlierTest & Chr(34)) + clsUpperOutlierlimitTestFunc.AddParameter("sub_calculations", clsRFunctionParameter:=clsUpperListOutlier) + clsUpperOutlierlimitTestFunc.SetAssignTo("outlier_upper_test_calculation") + + clsUpperListOutlier.SetRCommand("list") + clsUpperListOutlier.AddParameter("sub1", clsRFunctionParameter:=clsUpperOutlierLimitValueCalcFunc, bIncludeArgumentName:=False) + + 'lower Outlier Limit function + clsLowerOutlierLimitValueCalcFunc.SetRCommand("instat_calculation$new") + clsLowerOutlierLimitValueCalcFunc.AddParameter("type", Chr(34) & "calculation" & Chr(34), iPosition:=0) + clsLowerOutlierLimitValueCalcFunc.AddParameter("function_exp", clsRFunctionParameter:=clsLowerOutlierLimitFunc, iPosition:=1) + clsLowerOutlierLimitValueCalcFunc.AddParameter("result_name", Chr(34) & strLowerOutlierLimit & Chr(34), iPosition:=4) + clsLowerOutlierLimitValueCalcFunc.SetAssignTo("outlier_lower_limit") + + clsLowerOutlierLimitFunc.SetRCommand("summary_outlier_limit") + clsLowerOutlierLimitFunc.bToScriptAsRString = True + clsLowerOutlierLimitFunc.AddParameter("bskewedcalc", "FALSE") 'Outlier Operator - clsOutlierOperator.SetOperation(">") - clsOutlierOperator.AddParameter("right", strOutlier_Limit, iPosition:=1) - clsOutlierOperator.bBrackets = False - clsOutlierOperator.bToScriptAsRString = True + clsLowerOutlierOperator.SetOperation("<") + clsLowerOutlierOperator.AddParameter("right", strLowerOutlierLimit, iPosition:=1) + clsLowerOutlierOperator.bBrackets = False + clsLowerOutlierOperator.bToScriptAsRString = True - clsOutlierlimitTestFunc.SetRCommand("instat_calculation$new") - clsOutlierlimitTestFunc.AddParameter("type", Chr(34) & "calculation" & Chr(34), iPosition:=0) - clsOutlierlimitTestFunc.AddParameter("function_exp", clsROperatorParameter:=clsOutlierOperator, iPosition:=1) - clsOutlierlimitTestFunc.AddParameter("result_name", Chr(34) & strOutlierTest & Chr(34)) - clsOutlierlimitTestFunc.AddParameter("sub_calculations", clsRFunctionParameter:=clsListOutlier) - clsOutlierlimitTestFunc.SetAssignTo("outlier_test_calculation") + clsLowerOutlierlimitTestFunc.SetRCommand("instat_calculation$new") + clsLowerOutlierlimitTestFunc.AddParameter("type", Chr(34) & "calculation" & Chr(34), iPosition:=0) + clsLowerOutlierlimitTestFunc.AddParameter("function_exp", clsROperatorParameter:=clsLowerOutlierOperator, iPosition:=1) + clsLowerOutlierlimitTestFunc.AddParameter("result_name", Chr(34) & strLowerOutlierTest & Chr(34)) + clsLowerOutlierlimitTestFunc.AddParameter("sub_calculations", clsRFunctionParameter:=clsLowerListOutlier) + clsLowerOutlierlimitTestFunc.SetAssignTo("outlier_lower_test_calculation") - clsListOutlier.SetRCommand("list") - clsListOutlier.AddParameter("sub1", clsRFunctionParameter:=clsOutlierLimitValueCalcFunc, bIncludeArgumentName:=False) + clsLowerListOutlier.SetRCommand("list") + clsLowerListOutlier.AddParameter("sub1", clsRFunctionParameter:=clsLowerOutlierLimitValueCalcFunc, bIncludeArgumentName:=False) + + clsOutliersOperator.SetOperation(",") + clsOutliersOperator.AddParameter("sub1", clsRFunctionParameter:=clsUpperOutlierlimitTestFunc, bIncludeArgumentName:=False) + + 'Removed this sub_claculation because lower limit is not of interest for rainfall data. + 'clsOutliersOperator.AddParameter("sub2", clsRFunctionParameter:=clsLowerOutlierlimitTestFunc, bIncludeArgumentName:=False) 'Combined filters clsOrOperator.SetOperation("|") @@ -361,24 +400,29 @@ Public Class dlgClimaticCheckDataRain End Sub Private Sub setRcodeForControls(bReset) - ucrReceiverElement.AddAdditionalCodeParameterPair(clsGreaterOperator, New RParameter("left", 0), iAdditionalPairNo:=1) - ucrReceiverElement.AddAdditionalCodeParameterPair(clsAsNumericFunc, New RParameter("left", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=2) - ucrReceiverElement.AddAdditionalCodeParameterPair(clsLargeLessOperator, New RParameter("left", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=3) - ucrReceiverElement.AddAdditionalCodeParameterPair(clsOutlierOperator, New RParameter("left", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=4) - ucrReceiverElement.AddAdditionalCodeParameterPair(clsOutlierLimitFunc, New RParameter("x", 0), iAdditionalPairNo:=5) - ucrReceiverElement.AddAdditionalCodeParameterPair(clsRainyDaysOperator, New RParameter("left", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=6) - ucrReceiverElement.SetRCode(clsLargeOperator, bReset) + ucrReceiverElement.AddAdditionalCodeParameterPair(clsGreaterOperator, New RParameter("rain", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=1) + ucrReceiverElement.AddAdditionalCodeParameterPair(clsAsNumericFunc, New RParameter("rain", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=2) + ucrReceiverElement.AddAdditionalCodeParameterPair(clsLargeLessOperator, New RParameter("rain", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=3) + ucrReceiverElement.AddAdditionalCodeParameterPair(clsUpperOutlierOperator, New RParameter("rain", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=4) + ucrReceiverElement.AddAdditionalCodeParameterPair(clsUpperOutlierLimitFunc, New RParameter("rain", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=5) + ucrReceiverElement.AddAdditionalCodeParameterPair(clsRainyDaysOperator, New RParameter("rain", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=6) + ucrReceiverElement.AddAdditionalCodeParameterPair(clsLowerOutlierLimitFunc, New RParameter("rain", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=7) + ucrReceiverElement.AddAdditionalCodeParameterPair(clsLowerOutlierOperator, New RParameter("rain", 0, bNewIncludeArgumentName:=False), iAdditionalPairNo:=8) ucrChkLarge.AddAdditionalCodeParameterPair(clsListSubCalc, New RParameter("large", strParamValue:=clsLargeTestCalcFunc, bNewIncludeArgumentName:=False), iAdditionalPairNo:=1) ucrChkSame.AddAdditionalCodeParameterPair(clsListSubCalc, New RParameter("same", strParamValue:=clsSameTestFunc, bNewIncludeArgumentName:=False), iAdditionalPairNo:=1) ucrChkWetDays.AddAdditionalCodeParameterPair(clsListSubCalc, New RParameter("wet_days", strParamValue:=clsCumulativeTestFunc, bNewIncludeArgumentName:=False), iAdditionalPairNo:=1) - ucrChkOutlier.AddAdditionalCodeParameterPair(clsListSubCalc, New RParameter("outlier", strParamValue:=clsOutlierlimitTestFunc, bNewIncludeArgumentName:=False), iAdditionalPairNo:=1) - ucrChkCalculatedColumns.AddAdditionalCodeParameterPair(clsCumulativeCalcFunc, New RParameter("save"), iAdditionalPairNo:=1) + ucrChkOutlier.AddAdditionalCodeParameterPair(clsListSubCalc, New RParameter("outlier", clsOutliersOperator, bNewIncludeArgumentName:=False), iAdditionalPairNo:=1) + 'ucrChkCalculatedColumns.AddAdditionalCodeParameterPair(, New RParameter("save"), iAdditionalPairNo:=1) + ucrChkCalculatedColumns.AddAdditionalCodeParameterPair(clsUpperOutlierLimitValueCalcFunc, New RParameter("save"), iAdditionalPairNo:=1) + ucrChkCalculatedColumns.AddAdditionalCodeParameterPair(clsLowerOutlierLimitValueCalcFunc, New RParameter("save"), iAdditionalPairNo:=2) ucrChkLogicalColumns.AddAdditionalCodeParameterPair(clsSameTestFunc, New RParameter("save"), iAdditionalPairNo:=1) ucrChkLogicalColumns.AddAdditionalCodeParameterPair(clsCumulativeTestFunc, New RParameter("save"), iAdditionalPairNo:=2) - ucrChkLogicalColumns.AddAdditionalCodeParameterPair(clsOutlierlimitTestFunc, New RParameter("save"), iAdditionalPairNo:=3) + ucrChkLogicalColumns.AddAdditionalCodeParameterPair(clsUpperOutlierlimitTestFunc, New RParameter("save"), iAdditionalPairNo:=3) + ucrChkLogicalColumns.AddAdditionalCodeParameterPair(clsLowerOutlierlimitTestFunc, New RParameter("save"), iAdditionalPairNo:=4) + ucrReceiverElement.SetRCode(clsLargeOperator, bReset) ucrNudLarge.SetRCode(clsLargeOperator, bReset) ucrNudSame.SetRCode(clsGreaterSameOperator, bReset) ucrNudWetDays.SetRCode(clsGreatOperator, bReset) @@ -387,13 +431,13 @@ Public Class dlgClimaticCheckDataRain ucrChkSame.SetRCode(clsOrOperator, bReset) ucrChkWetDays.SetRCode(clsOrOperator, bReset) ucrChkOmitZero.SetRCode(clsRainyDaysFunc) - ucrNudCoeff.SetRCode(clsOutlierLimitFunc, bReset) + ucrNudCoeff.SetRCode(clsUpperOutlierLimitFunc, bReset) ucrChkOutlier.SetRCode(clsOrOperator, bReset) - ucrNudSkewnessWeight.SetRCode(clsOutlierLimitFunc, bReset) + ucrNudSkewnessWeight.SetRCode(clsUpperOutlierLimitFunc, bReset) ucrChkLogicalColumns.SetRCode(clsLargeTestCalcFunc, bReset) - ucrChkCalculatedColumns.SetRCode(clsSameCalcFunc, bReset) + ucrChkCalculatedColumns.SetRCode(clsCumulativeCalcFunc, bReset) End Sub Private Sub TestOkEnabled() @@ -419,7 +463,10 @@ Public Class dlgClimaticCheckDataRain clsLargeTestCalcFunc.AddParameter("calculated_from", "list(" & strCurrDataName & "=" & ucrReceiverElement.GetVariableNames & ")", iPosition:=2) clsSameCalcFunc.AddParameter("calculated_from", "list(" & strCurrDataName & "= " & ucrReceiverElement.GetVariableNames & ")", iPosition:=2) clsCumulativeCalcFunc.AddParameter("calculated_from", "list(" & strCurrDataName & "= " & ucrReceiverElement.GetVariableNames & ")", iPosition:=2) - clsOutlierlimitTestFunc.AddParameter("calculated_from", "list(" & strCurrDataName & "= " & ucrReceiverElement.GetVariableNames & ")", iPosition:=2) + clsUpperOutlierlimitTestFunc.AddParameter("calculated_from", "list(" & strCurrDataName & "= " & ucrReceiverElement.GetVariableNames & ")", iPosition:=2) + clsLowerOutlierlimitTestFunc.AddParameter("calculated_from", "list(" & strCurrDataName & "= " & ucrReceiverElement.GetVariableNames & ")", iPosition:=2) + clsLowerOutlierLimitValueCalcFunc.AddParameter("calculated_from", "list(" & strCurrDataName & "= " & ucrReceiverElement.GetVariableNames & ")", iPosition:=2) + End Sub Private Sub GroupByOptions() @@ -434,9 +481,11 @@ Public Class dlgClimaticCheckDataRain Private Sub GroupByMonth() If Not ucrReceiverMonth.IsEmpty Then clsGroupByMonth.AddParameter("calculated_from", "list(" & strCurrDataName & "=" & ucrReceiverMonth.GetVariableNames & ")", iPosition:=1) - clsOutlierLimitValueCalcFunc.AddParameter("manipulations", clsRFunctionParameter:=clsListForOutlierManipulations, iPosition:=3) + clsUpperOutlierLimitValueCalcFunc.AddParameter("manipulations", clsRFunctionParameter:=clsListForOutlierManipulations, iPosition:=3) + clsLowerOutlierLimitValueCalcFunc.AddParameter("manipulations", clsRFunctionParameter:=clsListForOutlierManipulations, iPosition:=3) Else - clsOutlierLimitValueCalcFunc.RemoveParameterByName("manipulations") + clsUpperOutlierLimitValueCalcFunc.RemoveParameterByName("manipulations") + clsLowerOutlierLimitValueCalcFunc.RemoveParameterByName("manipulations") End If End Sub @@ -445,7 +494,7 @@ Public Class dlgClimaticCheckDataRain End Sub Private Sub OutlierLimitCalc() - clsOutlierLimitValueCalcFunc.AddParameter("calculated_from", "list(" & strCurrDataName & "=" & ucrReceiverElement.GetVariableNames & ")", iPosition:=2) + clsUpperOutlierLimitValueCalcFunc.AddParameter("calculated_from", "list(" & strCurrDataName & "=" & ucrReceiverElement.GetVariableNames & ")", iPosition:=2) End Sub Private Sub ucrBase_ClickReset(sender As Object, e As EventArgs) Handles ucrBase.ClickReset