/// <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]); }
public PerformanceView() { InitializeComponent(); this.Resize += (s, e) => { this.splitContainer1.SplitterDistance = this.Height - 250; }; //always set the height of chart as 250 cmbSplitYear.SelectedIndexChanged += (s, e) => { updatePerformanceTable(); }; this.dataGridView1.ReadOnly = true; this.dataGridView1.RowEnter += (s, e) => { if (e.RowIndex < 0) { return; } try { //get selected unit type and id string unitType = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); if (unitType == ArcSWAT.SWATUnitType.RCH.ToString()) { _unitType = ArcSWAT.SWATUnitType.RCH; } else if (unitType == ArcSWAT.SWATUnitType.RES.ToString()) { _unitType = ArcSWAT.SWATUnitType.RES; } else { return; } //get the id _id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString()); //get column _col = ArcSWAT.ObservationData.getObservationSWATColumn(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString()); //get current result _currentResult = getResult(_result); //get statistic info for each hydrological year _statisticTable = _currentResult.UnitResult.getYearlyPerformanceTable(_col, _statisticType); this.dataGridView2.DataSource = _statisticTable; //---- //show scatter plot this.outputDisplayChart_Scatter1.draw(_currentResult, ArcSWAT.SeasonType.WholeYear); } catch { } }; this.dataGridView2.ReadOnly = true; this.dataGridView2.RowEnter += (s, e) => { if (e.RowIndex < 0) { return; } if (_currentResult == null) { return; } try { //get year _year = Convert.ToInt32(dataGridView2.Rows[e.RowIndex].Cells[0].Value.ToString()); //show the compared data chart this.outputDisplayChart1.Result = _currentResult.UnitResult.getResult(_col, _year); } catch { } }; //change the season type of chart when choose different column this.dataGridView2.ColumnHeaderMouseClick += (s, e) => { if (e.ColumnIndex <= 0) { return; } this.outputDisplayChart1.Season = (ArcSWAT.SeasonType)(e.ColumnIndex); if (this.outputDisplayChart1.DataSource != null) { this.outputDisplayChart1.Result = _currentResult.UnitResult.getResult(_col, _year); } }; compareCtrl1.onCompareResultChanged += (s, e) => { if (compareCtrl1.CompareResult == null) { return; } ArcSWAT.SWATUnitColumnYearResult r = getResult(compareCtrl1.CompareResult); if (r == null) { return; } _comparedStatisticTable = r.UnitResult.getYearlyPerformanceTable(_col, _statisticType); updateComparedTable(); }; seasonCtrl1.onSeasonTypeChanged += (s, e) => { updateComparedTable(); }; dataGridView3.RowEnter += (s, e) => { try { //get year int year = Convert.ToInt32(dataGridView3.Rows[e.RowIndex].Cells[0].Value.ToString()); //show the compared data chart this.outputDisplayChart1.CompareResult = _currentResult.UnitResult.getResult(_col, year).Compare(compareCtrl1.CompareResult); } catch { } }; this.cmbStatisticTypes.SelectedIndexChanged += (s, e) => { if (cmbStatisticTypes.SelectedIndex == -1) { return; } ArcSWAT.StatisticCompareType type = (ArcSWAT.StatisticCompareType)(cmbStatisticTypes.SelectedIndex); if (type == _statisticType) { return; } _statisticType = type; updatePerformanceTable(); }; }
public PerformanceView() { InitializeComponent(); this.Resize += (s, e) => { this.splitContainer1.SplitterDistance = this.Height - 250; }; //always set the height of chart as 250 cmbSplitYear.SelectedIndexChanged += (s, e) => { updatePerformanceTable(); }; this.dataGridView1.ReadOnly = true; this.dataGridView1.RowEnter += (s, e) => { if (e.RowIndex < 0) return; try { //get selected unit type and id string unitType = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); if (unitType == ArcSWAT.SWATUnitType.RCH.ToString()) _unitType = ArcSWAT.SWATUnitType.RCH; else if (unitType == ArcSWAT.SWATUnitType.RES.ToString()) _unitType = ArcSWAT.SWATUnitType.RES; else return; //get the id _id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString()); //get column _col = ArcSWAT.ObservationData.getObservationSWATColumn(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString()); //get current result _currentResult = getResult(_result); //get statistic info for each hydrological year _statisticTable = _currentResult.UnitResult.getYearlyPerformanceTable(_col,_statisticType); this.dataGridView2.DataSource = _statisticTable; //---- //show scatter plot this.outputDisplayChart_Scatter1.draw(_currentResult, ArcSWAT.SeasonType.WholeYear); } catch { } }; this.dataGridView2.ReadOnly = true; this.dataGridView2.RowEnter += (s, e) => { if (e.RowIndex < 0) return; if (_currentResult == null) return; try { //get year _year = Convert.ToInt32(dataGridView2.Rows[e.RowIndex].Cells[0].Value.ToString()); //show the compared data chart this.outputDisplayChart1.Result = _currentResult.UnitResult.getResult(_col, _year); } catch { } }; //change the season type of chart when choose different column this.dataGridView2.ColumnHeaderMouseClick += (s, e) => { if (e.ColumnIndex <= 0) return; this.outputDisplayChart1.Season = (ArcSWAT.SeasonType)(e.ColumnIndex); if(this.outputDisplayChart1.DataSource != null) this.outputDisplayChart1.Result = _currentResult.UnitResult.getResult(_col, _year); }; compareCtrl1.onCompareResultChanged += (s, e) => { if (compareCtrl1.CompareResult == null) return; ArcSWAT.SWATUnitColumnYearResult r = getResult(compareCtrl1.CompareResult); if(r == null) return; _comparedStatisticTable = r.UnitResult.getYearlyPerformanceTable(_col,_statisticType); updateComparedTable(); }; seasonCtrl1.onSeasonTypeChanged += (s, e) => { updateComparedTable(); }; dataGridView3.RowEnter += (s, e) => { try { //get year int year = Convert.ToInt32(dataGridView3.Rows[e.RowIndex].Cells[0].Value.ToString()); //show the compared data chart this.outputDisplayChart1.CompareResult = _currentResult.UnitResult.getResult(_col, year).Compare(compareCtrl1.CompareResult); } catch { } }; this.cmbStatisticTypes.SelectedIndexChanged += (s, e) => { if (cmbStatisticTypes.SelectedIndex == -1) return; ArcSWAT.StatisticCompareType type = (ArcSWAT.StatisticCompareType)(cmbStatisticTypes.SelectedIndex); if (type == _statisticType) return; _statisticType = type; updatePerformanceTable(); }; }