Exemple #1
0
        private static void copyData(SWATResultIntervalType interval, DataTable combineTable, ColumnYearData data)
        {
            //add new column for result2
            combineTable.Columns.Add(data.ColumnCompare, typeof(double));

            //copy data from result2 to the combine table
            int newColIndex = combineTable.Columns.Count - 1;

            for (int i = 0; i < combineTable.Rows.Count; i++)
            {
                if (data is SWATUnitColumnYearResult)
                {
                    ArcSWAT.RowItem item = new ArcSWAT.RowItem(data.Table.Rows[i]);
                    combineTable.Rows[i][newColIndex] = item.getColumnValue_Double(data.Column);
                }
                else if (data is SWATUnitColumnYearObservationData)
                {
                    //see if the oberved data is missing
                    DateTime d = DateTime.Parse(combineTable.Rows[i][SWATUnitResult.COLUMN_NAME_DATE].ToString());

                    DataRow[] rs = null;
                    if (interval == SWATResultIntervalType.MONTHLY)
                    {
                        //in phase I, the monthly data is using day 15 for each month, and I would use day 1 for each month, so here for monthly observed data, use both conditions
                        rs = data.Table.Select(string.Format("{0}='{1:yyyy-MM-01}' or {0}='{1:yyyy-MM-15}'", SWATUnitResult.COLUMN_NAME_DATE, d));
                    }
                    else if (interval == SWATResultIntervalType.DAILY)
                    {
                        rs = data.Table.Select(string.Format("{0}='{1:yyyy-MM-dd}'", SWATUnitResult.COLUMN_NAME_DATE, d));
                    }

                    if (rs != null && rs.Length > 0)
                    {
                        combineTable.Rows[i][newColIndex] = double.Parse(rs[0][data.Column].ToString());
                    }
                    else
                    {
                        combineTable.Rows[i][newColIndex] = ScenarioResultStructure.EMPTY_OBSERVED_VALUE; //missing observed data, shouldn't use 0 as for daily observed data they may be 0
                    }
                    //changed to -0.000001 to make the chart better
                }
            }
        }
        private static void copyData(SWATResultIntervalType interval, DataTable combineTable, ColumnYearData data)
        {
            //add new column for result2
            combineTable.Columns.Add(data.ColumnCompare, typeof(double));

            //copy data from result2 to the combine table
            int newColIndex = combineTable.Columns.Count - 1;
            for (int i = 0; i < combineTable.Rows.Count; i++)
            {
                if (data is SWATUnitColumnYearResult)
                {
                    ArcSWAT.RowItem item = new ArcSWAT.RowItem(data.Table.Rows[i]);
                    combineTable.Rows[i][newColIndex] = item.getColumnValue_Double(data.Column);
                }
                else if (data is SWATUnitColumnYearObservationData)
                {
                    //see if the oberved data is missing
                    DateTime d = DateTime.Parse(combineTable.Rows[i][SWATUnitResult.COLUMN_NAME_DATE].ToString());

                    DataRow[] rs = null;
                    if (interval == SWATResultIntervalType.MONTHLY)
                        //in phase I, the monthly data is using day 15 for each month, and I would use day 1 for each month, so here for monthly observed data, use both conditions
                        rs = data.Table.Select(string.Format("{0}='{1:yyyy-MM-01}' or {0}='{1:yyyy-MM-15}'", SWATUnitResult.COLUMN_NAME_DATE, d));
                    else if (interval == SWATResultIntervalType.DAILY)
                        rs = data.Table.Select(string.Format("{0}='{1:yyyy-MM-dd}'", SWATUnitResult.COLUMN_NAME_DATE, d));

                    if (rs != null && rs.Length > 0)
                        combineTable.Rows[i][newColIndex] = double.Parse(rs[0][data.Column].ToString());
                    else
                        combineTable.Rows[i][newColIndex] = ScenarioResultStructure.EMPTY_OBSERVED_VALUE; //missing observed data, shouldn't use 0 as for daily observed data they may be 0
                    //changed to -0.000001 to make the chart better
                }
            }
        }