public double Statistic(string filter, StatisticCompareType statisticType) { switch (statisticType) { case StatisticCompareType.NSE: return(NSE(filter)); case StatisticCompareType.R2: return(R2(filter)); case StatisticCompareType.Bias: return(BIAS(filter)); case StatisticCompareType.RMSE: return(RMSE(filter)); case StatisticCompareType.CVRMSE: return(CVRMSE(filter)); case StatisticCompareType.NRMSE: return(NRMSE(filter)); default: return(ScenarioResultStructure.EMPTY_VALUE); } }
/// <summary> /// For used in performance view /// </summary> /// <param name="splitYear"></param> /// <param name="before"></param> /// <param name="after"></param> public void Statistic(int splitYear, StatisticCompareType statisticType, out double before, out double after) { if (_result.FirstDay.Year == _result.LastDay.Year) { before = NSE(""); after = ScenarioResultStructure.EMPTY_VALUE; return; } if (splitYear > _result.LastDay.Year || splitYear <= _result.FirstDay.Year) { before = NSE(""); after = ScenarioResultStructure.EMPTY_VALUE; return; } string filter1 = string.Format("{0} < '{1}-01-01'", SWATUnitResult.COLUMN_NAME_DATE, splitYear); string filter2 = string.Format("{0} >= '{1}-01-01'", SWATUnitResult.COLUMN_NAME_DATE, splitYear); before = Statistic(filter1,statisticType); after = Statistic(filter2,statisticType); }
public DataTable getPerformanceTable(int splitYear, StatisticCompareType statisticType) { string tableName = string.Format("performance_{0}_{1}_{2}_{3}", this.Scenario.Name, this.ModelType, splitYear, statisticType); if (!_performanceTables.ContainsKey(tableName)) { bool withSplitYear = false; DataTable dt = createPerformanceTable(splitYear, statisticType, out withSplitYear); getPerformanceTableForType(splitYear, withSplitYear, dt, SWATUnitType.RCH, statisticType); getPerformanceTableForType(splitYear, withSplitYear, dt, SWATUnitType.RES, statisticType); _performanceTables.Add(tableName, dt); } return(_performanceTables[tableName]); }
/// <summary> /// For used in performance view /// </summary> /// <param name="splitYear"></param> /// <param name="before"></param> /// <param name="after"></param> public void Statistic(int splitYear, StatisticCompareType statisticType, out double before, out double after) { if (_result.FirstDay.Year == _result.LastDay.Year) { before = NSE(""); after = ScenarioResultStructure.EMPTY_VALUE; return; } if (splitYear > _result.LastDay.Year || splitYear <= _result.FirstDay.Year) { before = NSE(""); after = ScenarioResultStructure.EMPTY_VALUE; return; } string filter1 = string.Format("{0} < '{1}-01-01'", SWATUnitResult.COLUMN_NAME_DATE, splitYear); string filter2 = string.Format("{0} >= '{1}-01-01'", SWATUnitResult.COLUMN_NAME_DATE, splitYear); before = Statistic(filter1, statisticType); after = Statistic(filter2, statisticType); }
private DataTable createPerformanceTable(int splitYear, StatisticCompareType statisticType, out bool withSplitYear) { withSplitYear = false; string tableName = string.Format("performance_{0}_{1}_{2}_{3}", this.Scenario.Name, this.ModelType, splitYear, statisticType); DataTable dt = new DataTable(tableName); dt.Columns.Add("TYPE", typeof(string)); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("VAR", typeof(string)); dt.Columns.Add(string.Format("{2}({0}-{1})", StartYear, EndYear, statisticType), typeof(double)); if (splitYear > StartYear && splitYear <= EndYear) { withSplitYear = true; dt.Columns.Add(string.Format("{2}({0}-{1})", StartYear, splitYear - 1, statisticType), typeof(double)); dt.Columns.Add(string.Format("{2}({0}-{1})", splitYear, EndYear, statisticType), typeof(double)); } return(dt); }
public double Statistic(string filter, StatisticCompareType statisticType) { switch (statisticType) { case StatisticCompareType.NSE: return NSE(filter); case StatisticCompareType.R2: return R2(filter); case StatisticCompareType.Bias: return BIAS(filter); case StatisticCompareType.RMSE: return RMSE(filter); case StatisticCompareType.CVRMSE: return CVRMSE(filter); case StatisticCompareType.NRMSE: return NRMSE(filter); default: return ScenarioResultStructure.EMPTY_VALUE; } }
private void getPerformanceTableForType(int splitYear, bool withSplitYear, DataTable dt, SWATUnitType type, StatisticCompareType statisticType) { Dictionary <int, SWATUnit> units = null; if (type == SWATUnitType.RCH) { units = _reaches; } else if (type == SWATUnitType.RES) { units = _reservoirs; } if (units == null) { return; } StringCollection ids = new StringCollection(); foreach (SWATUnit oneUnit in units.Values) { foreach (SWATUnitResult unitResult in oneUnit.Results.Values) { foreach (string col in unitResult.Columns) { SWATUnitColumnYearResult oneResult = unitResult.getResult(col, -1); if (oneResult.CompareWithObserved == null) { continue; } //avoid repeat records, like TSS string id = string.Format("{0}_{1}_{2}", unitResult.Unit.Type, unitResult.Unit.ID, col); if (ids.Contains(id)) { continue; } ids.Add(id); //create a new row DataRow r = dt.NewRow(); r[0] = unitResult.Unit.Type.ToString(); r[1] = unitResult.Unit.ID; r[2] = ObservationData.getObservationColumnFromSWAT(col); double total = oneResult.CompareWithObserved.Statistics.Statistic("", statisticType); r[3] = Math.Round(total, 4); if (withSplitYear) { double before = ScenarioResultStructure.EMPTY_VALUE; double after = ScenarioResultStructure.EMPTY_VALUE; oneResult.CompareWithObserved.Statistics.Statistic(splitYear, statisticType, out before, out after); r[4] = Math.Round(before, 4); r[5] = Math.Round(after, 4); } dt.Rows.Add(r); } } } }
private void getPerformanceTableForType(int splitYear, bool withSplitYear, DataTable dt, SWATUnitType type, StatisticCompareType statisticType) { Dictionary<int, SWATUnit> units = null; if (type == SWATUnitType.RCH) units = _reaches; else if (type == SWATUnitType.RES) units = _reservoirs; if (units == null) return; StringCollection ids = new StringCollection(); foreach (SWATUnit oneUnit in units.Values) { foreach (SWATUnitResult unitResult in oneUnit.Results.Values) { foreach (string col in unitResult.Columns) { SWATUnitColumnYearResult oneResult = unitResult.getResult(col, -1); if (oneResult.CompareWithObserved == null) continue; //avoid repeat records, like TSS string id = string.Format("{0}_{1}_{2}", unitResult.Unit.Type, unitResult.Unit.ID, col); if (ids.Contains(id)) continue; ids.Add(id); //create a new row DataRow r = dt.NewRow(); r[0] = unitResult.Unit.Type.ToString(); r[1] = unitResult.Unit.ID; r[2] = ObservationData.getObservationColumnFromSWAT(col); double total = oneResult.CompareWithObserved.Statistics.Statistic("",statisticType); r[3] = Math.Round(total, 4); if (withSplitYear) { double before = ScenarioResultStructure.EMPTY_VALUE; double after = ScenarioResultStructure.EMPTY_VALUE; oneResult.CompareWithObserved.Statistics.Statistic(splitYear,statisticType, out before, out after); r[4] = Math.Round(before, 4); r[5] = Math.Round(after, 4); } dt.Rows.Add(r); } } } }
private DataTable createPerformanceTable(int splitYear, StatisticCompareType statisticType, out bool withSplitYear) { withSplitYear = false; string tableName = string.Format("performance_{0}_{1}_{2}_{3}", this.Scenario.Name, this.ModelType, splitYear,statisticType); DataTable dt = new DataTable(tableName); dt.Columns.Add("TYPE", typeof(string)); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("VAR", typeof(string)); dt.Columns.Add(string.Format("{2}({0}-{1})", StartYear, EndYear, statisticType), typeof(double)); if (splitYear > StartYear && splitYear <= EndYear) { withSplitYear = true; dt.Columns.Add(string.Format("{2}({0}-{1})",StartYear,splitYear-1,statisticType), typeof(double)); dt.Columns.Add(string.Format("{2}({0}-{1})",splitYear,EndYear,statisticType), typeof(double)); } return dt; }
public DataTable getPerformanceTable(int splitYear, StatisticCompareType statisticType) { string tableName = string.Format("performance_{0}_{1}_{2}_{3}", this.Scenario.Name, this.ModelType, splitYear, statisticType); if (!_performanceTables.ContainsKey(tableName)) { bool withSplitYear = false; DataTable dt = createPerformanceTable(splitYear,statisticType,out withSplitYear); getPerformanceTableForType(splitYear, withSplitYear, dt, SWATUnitType.RCH, statisticType); getPerformanceTableForType(splitYear, withSplitYear, dt, SWATUnitType.RES, statisticType); _performanceTables.Add(tableName, dt); } return _performanceTables[tableName]; }