/// <summary> /// get the performace table for given column /// </summary> /// <param name="col"></param> /// <returns></returns> public DataTable getYearlyPerformanceTable(string col, ArcSWAT.StatisticCompareType statisticType) { string tableName = string.Format("performance_{0}_{1}", col, statisticType); if (!_performanceTableYearly.ContainsKey(tableName)) { //create the table DataTable dt = new DataTable(tableName); dt.Columns.Add("Year", typeof(Int32)); for (int j = (int)(SeasonType.WholeYear); j <= (int)(SeasonType.HydrologicalYear); j++) { dt.Columns.Add(((SeasonType)j).ToString(), typeof(double)); } for (int i = this.Unit.Scenario.StartYear; i <= this.Unit.Scenario.EndYear; i++) { ArcSWAT.SWATUnitColumnYearResult r = getResult(col, i); if (r != null) { DataRow newRow = dt.NewRow(); newRow[0] = i; for (int j = (int)(SeasonType.WholeYear); j <= (int)(SeasonType.HydrologicalYear); j++) { newRow[j] = Math.Round(r.CompareWithObserved.SeasonStatistics((SeasonType)j).Statistic ("", statisticType), 4); } dt.Rows.Add(newRow); } } _performanceTableYearly[tableName] = dt; } return(_performanceTableYearly[tableName]); }
/// <summary> /// Retrieve difference data table between two scenarios /// </summary> /// <param name="type"></param> /// <param name="resultType"></param> /// <param name="col"></param> /// <param name="compareScenario"></param> /// <returns></returns> public DataTable getDifference(ArcSWAT.SWATUnitType type, string resultType, string col, ArcSWAT.ScenarioResult compareScenario, System.ComponentModel.BackgroundWorker worker = null) { string tableId = string.Format("{0}_{1}_{2}_{3}_{4}", type, resultType, col, compareScenario.ModelType, compareScenario.Scenario.Name); if (!_differenceDataset.Tables.Contains(tableId)) { List <int> ids = getSWATUnitIDs(type); DataTable dt = new System.Data.DataTable(tableId); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("R2", typeof(double)); foreach (int id in ids) { if (worker != null) { worker.ReportProgress(0, string.Format("{0}:{1}", type, id)); } ArcSWAT.SWATUnit unit = getSWATUnit(type, id); if (unit == null) { continue; } ArcSWAT.SWATUnitResult unitResult = unit.getResult(resultType); if (unitResult == null) { continue; } ArcSWAT.SWATUnitColumnYearResult oneUnitResult = unitResult.getResult(col, -1); if (oneUnitResult == null) { continue; } try { DataRow r = dt.NewRow(); r[0] = id; r[1] = oneUnitResult.Compare(compareScenario).Statistics.Statistic("", StatisticCompareType.R2); dt.Rows.Add(r); } catch (System.Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } } _differenceDataset.Tables.Add(dt); } return(_differenceDataset.Tables[tableId]); }