private ArcSWAT.SWATUnitColumnYearResult getResult(ArcSWAT.ScenarioResult result)
        {
            if (_unitType == ArcSWAT.SWATUnitType.UNKNOWN)
            {
                return(null);
            }

            //get the unit
            ArcSWAT.SWATUnit unit = result.getSWATUnit(_unitType, _id);
            if (unit == null)
            {
                return(null);
            }

            //get unit results
            foreach (ArcSWAT.SWATUnitResult unitResult in unit.Results.Values)
            {
                ArcSWAT.SWATUnitColumnYearResult r = unitResult.getResult(_col, -1);
                if (r != null)
                {
                    return(r);
                }
            }
            return(null);
        }
示例#2
0
        /// <summary>
        /// Compare result and observed data
        /// </summary>
        /// <param name="result"></param>
        public SWATUnitColumnYearCompareResult(SWATUnitColumnYearResult result)
        {
            if (result == null)
            {
                return;
            }
            SWATUnitColumnYearObservationData observed = result.ObservedData;

            if (observed == null)
            {
                return;
            }

            _result1 = result;
            _data2   = observed;

            _interval = _result1.UnitResult.Interval;
            _chartColumns.Add(_result1.ColumnCompare);
            _chartColumns.Add(_data2.ColumnCompare);

            _tableColumns.Add(_result1.ColumnCompare);
            _tableColumns.Add(_data2.ColumnCompare);
            //_tableColumns.Add("ABSOLUTE");
            //_tableColumns.Add("RELATIVE");

            _statistic = new StatisticCompare(this, SeasonType.WholeYear);
        }
示例#3
0
        /// <summary>
        /// Used to get observed data corresponding to specific result
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public SWATUnitColumnYearObservationData getObservedData(SWATUnitColumnYearResult result)
        {
            //check if the database is there
            if (!_exist)
            {
                return(null);
            }

            //see if the column has correponding observed data
            string[] columns = getObservationDataColumns(result.UnitResult.Unit.Type);
            if (columns == null)
            {
                return(null);
            }
            if (System.Array.IndexOf(columns, getObservationColumnFromSWAT(result.Column)) == -1)
            {
                return(null);
            }

            //find the data
            string uniqueID = getUniqueId(result.UnitResult.Unit.Type, result.UnitResult.Unit.ID, result.Column);

            if (_allData.ContainsKey(uniqueID))
            {
                uniqueID = getUniqueId(result);
                if (!_allData.ContainsKey(uniqueID))
                {
                    _allData.Add(uniqueID, new SWATUnitObservationData(result, this));
                }
                SWATUnitObservationData unitData = _allData[uniqueID];
                return(unitData.getObservedData(result.Year));
            }
            return(null);
        }
示例#4
0
        /// <summary>
        /// Compare two results
        /// </summary>
        /// <param name="result1"></param>
        /// <param name="result2"></param>
        public SWATUnitColumnYearCompareResult(SWATUnitColumnYearResult result1, SWATUnitColumnYearResult result2)
        {
            if (result1 == null || result2 == null)
            {
                return;
            }

            if (result1.UnitResult.Unit.Scenario.Scenario.Name.Equals(result2.UnitResult.Unit.Scenario.Scenario.Name)) //same scenario
            {
                if (result1.UnitResult.Unit.Scenario.ModelType == result2.UnitResult.Unit.Scenario.ModelType)          //same model type
                {
                    return;
                }
            }
            else //different scenario
            {
                if (result1.UnitResult.Unit.Scenario.ModelType != result2.UnitResult.Unit.Scenario.ModelType) //different model type
                {
                    return;
                }
            }

            if (result1.UnitResult.Unit.Type != result2.UnitResult.Unit.Type ||
                result1.UnitResult.Unit.ID != result2.UnitResult.Unit.ID)
            {
                return;                                                           //differnt unit type or id
            }
            if (!result1.UnitResult.Name.Equals(result2.UnitResult.Name) ||
                result1.UnitResult.Interval != result2.UnitResult.Interval)
            {
                return;                                                             //differnt data table or interval
            }
            if (!result1.Column.Equals(result2.Column) || result1.Year != result2.Year)
            {
                return;                                                                         //different data column or year
            }
            _result1 = result1;
            _data2   = result2;

            _interval = _result1.UnitResult.Interval;
            _chartColumns.Add(_result1.ColumnCompare);
            _chartColumns.Add(_data2.ColumnCompare);

            _tableColumns.Add(_result1.ColumnCompare);
            _tableColumns.Add(_data2.ColumnCompare);
            //_tableColumns.Add("ABSOLUTE");
            //_tableColumns.Add("RELATIVE");

            if (_result1.ObservedData != null)
            {
                _chartColumns.Add(_result1.ObservedData.ColumnCompare);
                _tableColumns.Add(_result1.ObservedData.ColumnCompare);
            }

            _statistic = new StatisticCompare(this, SeasonType.WholeYear);
        }
示例#5
0
        private string getUniqueId(SWATUnitColumnYearResult result)
        {
            int          startYear = result.UnitResult.Unit.Scenario.StartYear;
            int          endYear   = result.UnitResult.Unit.Scenario.EndYear;
            SWATUnitType unitType  = result.UnitResult.Unit.Type;
            int          id        = result.UnitResult.Unit.ID;
            string       col       = result.Column;

            return(getUniqueId(unitType, id, col, startYear, endYear));
        }
        public SWATUnitObservationData(SWATUnitColumnYearResult result, ObservationData parent)
        {
            _parentData = parent;

            _id = result.UnitResult.Unit.ID;
            _unitType = result.UnitResult.Unit.Type;
            _col = result.Column;
            _startYear = result.UnitResult.Unit.Scenario.StartYear;
            _endYear = result.UnitResult.Unit.Scenario.EndYear;
        }
        public SWATUnitObservationData(SWATUnitColumnYearResult result, ObservationData parent)
        {
            _parentData = parent;

            _id        = result.UnitResult.Unit.ID;
            _unitType  = result.UnitResult.Unit.Type;
            _col       = result.Column;
            _startYear = result.UnitResult.Unit.Scenario.StartYear;
            _endYear   = result.UnitResult.Unit.Scenario.EndYear;
        }
示例#8
0
        public SWATUnitColumnYearResult getResult(string col, int year)
        {
            if (!Columns.Contains(col))
            {
                return(null);
            }

            //see if the result is already there
            string id = SWATUnitColumnYearResult.getUniqueResultID(col, year);

            if (!_results.ContainsKey(id))
            {
                _results.Add(id, new SWATUnitColumnYearResult(col, year, this));
            }
            return(_results[id]);
        }
        /// <summary>
        /// Compare two results
        /// </summary>
        /// <param name="result1"></param>
        /// <param name="result2"></param>
        public SWATUnitColumnYearCompareResult(SWATUnitColumnYearResult result1, SWATUnitColumnYearResult result2)
        {
            if(result1 == null || result2 == null) return;

            if (result1.UnitResult.Unit.Scenario.Scenario.Name.Equals(result2.UnitResult.Unit.Scenario.Scenario.Name)) //same scenario
            {
                if (result1.UnitResult.Unit.Scenario.ModelType == result2.UnitResult.Unit.Scenario.ModelType) //same model type
                    return;
            }
            else //different scenario
            {
                if (result1.UnitResult.Unit.Scenario.ModelType != result2.UnitResult.Unit.Scenario.ModelType) //different model type
                    return;
            }

            if (result1.UnitResult.Unit.Type != result2.UnitResult.Unit.Type ||
                result1.UnitResult.Unit.ID != result2.UnitResult.Unit.ID) return; //differnt unit type or id

            if (!result1.UnitResult.Name.Equals(result2.UnitResult.Name) ||
                result1.UnitResult.Interval != result2.UnitResult.Interval) return; //differnt data table or interval

            if (!result1.Column.Equals(result2.Column) || result1.Year != result2.Year) return; //different data column or year

            _result1 = result1;
            _data2 = result2;

            _interval = _result1.UnitResult.Interval;
            _chartColumns.Add(_result1.ColumnCompare);
            _chartColumns.Add(_data2.ColumnCompare);

            _tableColumns.Add(_result1.ColumnCompare);
            _tableColumns.Add(_data2.ColumnCompare);
            //_tableColumns.Add("ABSOLUTE");
            //_tableColumns.Add("RELATIVE");

            if (_result1.ObservedData != null)
            {
                _chartColumns.Add(_result1.ObservedData.ColumnCompare);
                _tableColumns.Add(_result1.ObservedData.ColumnCompare);
            }

            _statistic = new StatisticCompare(this,SeasonType.WholeYear);
        }
        /// <summary>
        /// Compare result and observed data
        /// </summary>
        /// <param name="result"></param>
        public SWATUnitColumnYearCompareResult(SWATUnitColumnYearResult result)
        {
            if (result == null) return;
            SWATUnitColumnYearObservationData observed = result.ObservedData;
            if (observed == null) return;

            _result1 = result;
            _data2 = observed;

            _interval = _result1.UnitResult.Interval;
            _chartColumns.Add(_result1.ColumnCompare);
            _chartColumns.Add(_data2.ColumnCompare);

            _tableColumns.Add(_result1.ColumnCompare);
            _tableColumns.Add(_data2.ColumnCompare);
            //_tableColumns.Add("ABSOLUTE");
            //_tableColumns.Add("RELATIVE");

            _statistic = new StatisticCompare(this,SeasonType.WholeYear);
        }
示例#11
0
        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();
            };
        }
示例#12
0
        private string getUniqueId(SWATUnitColumnYearResult result)
        {
            int startYear = result.UnitResult.Unit.Scenario.StartYear;
            int endYear = result.UnitResult.Unit.Scenario.EndYear;
            SWATUnitType unitType = result.UnitResult.Unit.Type;
            int id = result.UnitResult.Unit.ID;
            string col = result.Column;

            return getUniqueId(unitType, id, col, startYear, endYear);
        }
示例#13
0
        private void updateTableAndChart()
        {
            _statistics = "No Statistics Data Available";
            if (onDataStatisticsChanged != null)
            {
                onDataStatisticsChanged(this, new EventArgs());
            }

            if (_resultType == null || _col == null)
            {
                return;
            }

            if (!this._scenario.Watershed.Results.ContainsKey(_resultType))
            {
                return;
            }

            ArcSWAT.SWATUnitResult result = this._scenario.Watershed.Results[_resultType];
            if (!result.Columns.Contains(_col))
            {
                return;
            }

            int year = -1;

            if ((result.Interval == ArcSWAT.SWATResultIntervalType.DAILY || result.Interval == ArcSWAT.SWATResultIntervalType.MONTHLY) && yearCtrl1.DisplayByYear)
            {
                year = yearCtrl1.Year;
            }

            if (_compareResult == null) //don't compare
            {
                ArcSWAT.SWATUnitColumnYearResult oneResult = result.getResult(_col, year);

                this.tableView1.Result          = oneResult;
                this.outputDisplayChart1.Result = oneResult;
                _statistics = oneResult.Statistics.ToString();
                if (onDataStatisticsChanged != null)
                {
                    onDataStatisticsChanged(this, new EventArgs());
                }
            }
            else //compare
            {
                try
                {
                    ArcSWAT.SWATUnitColumnYearCompareResult compare =
                        result.getResult(_col, year).Compare(_compareResult);
                    this.tableView1.CompareResult          = compare;
                    this.outputDisplayChart1.CompareResult = compare;
                    _statistics = compare.Statistics.ToString();
                    if (onDataStatisticsChanged != null)
                    {
                        onDataStatisticsChanged(this, new EventArgs());
                    }
                }
                catch (System.Exception e)
                {
                    SWAT_SQLite.showInformationWindow(e.ToString());
                }
            }
        }
示例#14
0
        /// <summary>
        /// Used to get observed data corresponding to specific result
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public SWATUnitColumnYearObservationData getObservedData(SWATUnitColumnYearResult result)
        {
            //check if the database is there
            if (!_exist) return null;

            //see if the column has correponding observed data
            string[] columns = getObservationDataColumns(result.UnitResult.Unit.Type);
            if (columns == null) return null;
            if (System.Array.IndexOf(columns, getObservationColumnFromSWAT(result.Column)) == -1) return null;

            //find the data
            string uniqueID = getUniqueId(result.UnitResult.Unit.Type, result.UnitResult.Unit.ID,result.Column);
            if (_allData.ContainsKey(uniqueID))
            {
                uniqueID = getUniqueId(result);
                if(!_allData.ContainsKey(uniqueID))
                    _allData.Add(uniqueID, new SWATUnitObservationData(result, this));
                SWATUnitObservationData unitData = _allData[uniqueID];
                return unitData.getObservedData(result.Year);
            }
            return null;
        }
示例#15
0
        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);
                    }
                }
            }
        }
示例#16
0
        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 void draw(ArcSWAT.SWATUnitColumnYearResult result, ArcSWAT.SeasonType season)
        {
            setup();
            clear();

            if (result.ColumnDisplay.Equals("Flow"))
            {
                return;                                      //don't display for flow
            }
            //scatter
            DataTable dt = result.CompareWithObserved.SeasonTableForStatistics(season); //already removed missing value

            string col_observed  = result.CompareWithObserved.ChartColumns[1];
            string col_simulated = result.CompareWithObserved.ChartColumns[0];

            _dt = dt.Copy();
            foreach (DataRow r in _dt.Rows)
            {
                double observed  = double.Parse(r[col_observed].ToString());
                double simulated = double.Parse(r[col_simulated].ToString());

                if (observed > 0)
                {
                    r[col_observed] = Math.Log(observed);
                }
                if (simulated > 0)
                {
                    r[col_simulated] = Math.Log(simulated);
                }
            }
            _scatter.XValueMember  = col_observed;
            _scatter.YValueMembers = col_simulated;
            this.DataSource        = _dt.Rows;

            _xColName = col_observed;
            _yColName = col_simulated;

            //1:1 line
            double max = Compute(_dt, "Max(" + col_observed + ")", "");

            max = Math.Max(max, Compute(_dt, "Max(" + col_simulated + ")", ""));
            double round = Math.Round(max);

            if (round < max)
            {
                round += 1;
            }
            max = round;

            _line.Points.Add(new DataPoint(0, 0));
            _line.Points.Add(new DataPoint(max, max));

            //set x,y max
            _chartArea.AxisX.Maximum = max;
            _chartArea.AxisY.Maximum = max;
            _chartArea.AxisX.Minimum = 0;
            _chartArea.AxisY.Minimum = 0;

            //
            if (result.IsFlow)
            {
                _chartArea.AxisX.Title = string.Format("Ln({0} observed ({1}))", result.ColumnDisplay, result.Unit);
                _chartArea.AxisY.Title = string.Format("Ln({0} simulated ({1}))", result.ColumnDisplay, result.Unit);
            }
            else //loading
            {
                string interval = "day";
                if (result.UnitResult.Interval == SWATResultIntervalType.MONTHLY)
                {
                    interval = "month";
                }
                else if (result.UnitResult.Interval == SWATResultIntervalType.YEARLY)
                {
                    interval = "year";
                }
                _chartArea.AxisX.Title = string.Format("Ln({0} observed ({1}/{2}))", result.ColumnDisplay, result.Unit, interval);
                _chartArea.AxisY.Title = string.Format("Ln({0} simulated ({1}/{2}))", result.ColumnDisplay, result.Unit, interval);
            }
        }
示例#18
0
        private void updateTableAndChart()
        {
            tableView1.DataTable = null;
            outputDisplayChart1.clear();
            _statistics = "No Statistics Data Available";
            if (onDataStatisticsChanged != null)
            {
                onDataStatisticsChanged(this, new EventArgs());
            }

            if (_resultType == null || _col == null || _unit == null)
            {
                return;
            }

            if (!_unit.Results.ContainsKey(_resultType))
            {
                return;
            }

            ArcSWAT.SWATUnitResult result = _unit.Results[_resultType];
            if (!result.Columns.Contains(_col))
            {
                return;
            }

            //consider year selection
            int year = -1;

            if ((result.Interval == ArcSWAT.SWATResultIntervalType.DAILY || result.Interval == ArcSWAT.SWATResultIntervalType.MONTHLY) && yearCtrl1.DisplayByYear)
            {
                year = yearCtrl1.Year;
            }

            //current working result
            ArcSWAT.SWATUnitColumnYearResult oneResult = result.getResult(_col, year);

            //set compare control
            //compareCtrl1.HasObervedData = (oneResult.ObservedData != null);

            //do the update
            if (compareCtrl1.CompareResult == null) //don't compare
            {
                if (oneResult.Table.Rows.Count == 0 && _type == ArcSWAT.SWATUnitType.HRU)
                {
                    MessageBox.Show("No results for HRU " + _unit.ID.ToString() + ". For more results, please modify file.cio.");
                }

                this.tableView1.Result          = oneResult;
                this.outputDisplayChart1.Result = oneResult;
                this._statistics = oneResult.SeasonStatistics(seasonCtrl1.Season).ToString();
                if (oneResult.ObservedData != null)
                {
                    this._statistics += " || Compare to Observed: " + oneResult.CompareWithObserved.SeasonStatistics(seasonCtrl1.Season).ToString() + ")";
                }
                if (onDataStatisticsChanged != null)
                {
                    onDataStatisticsChanged(this, new EventArgs());
                }
            }
            else //compare
            {
                try
                {
                    ArcSWAT.SWATUnitColumnYearCompareResult compare = null;
                    if (compareCtrl1.CompareResult != null)
                    {
                        compare = oneResult.Compare(compareCtrl1.CompareResult);

                        //compare to scenario
                        this._statistics = string.Format("{0} vs {1}: {2}",
                                                         result.Unit.Scenario.ModelType,
                                                         compareCtrl1.CompareResult.ModelType,
                                                         compare.SeasonStatistics(seasonCtrl1.Season));

                        if (oneResult.ObservedData != null)
                        {
                            //compare to observed
                            this._statistics += " || ";
                            this._statistics += string.Format("{0} vs Observed: {1}",
                                                              result.Unit.Scenario.ModelType,
                                                              oneResult.CompareWithObserved.SeasonStatistics(seasonCtrl1.Season));

                            ArcSWAT.SWATUnitColumnYearResult comparedData = compare.ComparedData as ArcSWAT.SWATUnitColumnYearResult;
                            this._statistics += " || ";
                            this._statistics += string.Format("{0} vs Observed: {1}",
                                                              compareCtrl1.CompareResult.ModelType,
                                                              comparedData.CompareWithObserved.SeasonStatistics(seasonCtrl1.Season));
                        }
                    }
                    else
                    {
                        compare          = oneResult.CompareWithObserved;
                        this._statistics = compare.SeasonStatistics(seasonCtrl1.Season).ToString();
                    }
                    this.tableView1.CompareResult          = compare;
                    this.outputDisplayChart1.CompareResult = compare;
                    if (onDataStatisticsChanged != null)
                    {
                        onDataStatisticsChanged(this, new EventArgs());
                    }
                }
                catch (System.Exception e)
                {
                    SWAT_SQLite.showInformationWindow(e.ToString());
                }
            }
        }