Beispiel #1
0
        /// <summary>
        /// get compare table for given scenario and model type
        /// </summary>
        /// <param name="scenario"></param>
        /// <param name="modelType"></param>
        /// <returns></returns>
        private SWATUnitColumnYearResult getCompareResult(Scenario scenario, SWATModelType modelType)
        {
            //get scenario result
            ScenarioResult compareResult = scenario.getModelResult(modelType, _result.Interval);

            if (compareResult == null)
            {
                throw new Exception("Can't find model " + modelType.ToString() + " in scenario " + scenario.Name);
            }
            if (compareResult.Status == ScenarioResultStatus.UNKNOWN)
            {
                throw new Exception("The status of model " + modelType.ToString() + " in scenario " + scenario.Name + " is unknown.");
            }
            if (compareResult.Status == ScenarioResultStatus.UNSUCCESS)
            {
                throw new Exception("The simulation of " + modelType.ToString() + " in scenario " + scenario.Name + " is not successful. Please check the model first.");
            }
            if (compareResult.Status == ScenarioResultStatus.NO_EXIST)
            {
                throw new Exception("The simulation result of " + modelType.ToString() + " in scenario " + scenario.Name + " doesn't exist. Please run the model first.");
            }


            //get unit
            SWATUnit unit = compareResult.getSWATUnit(_result.Unit.Type, _result.Unit.ID);

            if (unit == null)
            {
                throw new Exception("Can't find " + _result.Unit.Type + " " + _result.Unit.ID.ToString() + " in scenario " + scenario.Name + ",model " + modelType.ToString());
            }

            SWATUnitResult unitResult = unit.getResult(_result.Name);

            if (unitResult == null)
            {
                throw new Exception("Can't find result  " + _result.Name + " for " + _result.Unit.Type + " " + _result.Unit.ID.ToString() + " in scenario " + scenario.Name + ",model " + modelType.ToString());
            }
            if (unitResult.Interval != _result.Interval)
            {
                throw new Exception("The interval for " + _result.Name + " for " + _result.Unit.Type + " " + _result.Unit.ID.ToString() + " in scenario " + scenario.Name + ",model " + modelType.ToString() + " is different from current result.");
            }

            return(unitResult.getResult(_col, _year));
        }
Beispiel #2
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());
                }
            }
        }
Beispiel #3
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());
                }
            }
        }