Beispiel #1
0
        private double Compare(int startYear, int endYear, SourceType source, int id, string var)
        {
            DataTable dtSQLite = _extractSQLite.Extract(startYear, endYear, source, id, var);
            DataTable dtText   = _extractText.Extract(startYear, endYear, source, id, var);

            Console.WriteLine(string.Format("Extract time for {0}-{1}-{2}-{3}-{4}: SQLite = {5:F4} ms, Text = {6:F4} ms",
                                            startYear, endYear, source, id, var, _extractSQLite.ExtractTime, _extractText.ExtractTime));

            //the join table structure
            DataTable dt = new DataTable();

            dt.Columns.Add("TIME", typeof(DateTime));
            dt.Columns.Add("SQLite", typeof(double));
            dt.Columns.Add("Text", typeof(double));

            //join these two tables using Linq
            var results = from table1 in dtSQLite.AsEnumerable()
                          join table2 in dtText.AsEnumerable() on table1["TIME"] equals table2["TIME"]
                          select dt.LoadDataRow(new object[]
            {
                table1["TIME"],
                table1[var],
                table2[var]
            }, false);

            results.CopyToDataTable();

            return(CalculateR2(dt, "SQLite", "Text", ""));
        }
Beispiel #2
0
        static void TestExtractFromText()
        {
            Console.WriteLine("********************Text********************");
            ExtractSWAT_Text extract = new ExtractSWAT_Text(
                @"C:\zhiqiang\ModelTestWithSWATSQLite\LaSalle\LaSalle2012\Scenarios", "default");

            Console.WriteLine("******************** First Try ********************");
            extract.Extract(SourceType.REACH, 1, "FLOW_OUTcms");//case sensitive
            extract.Extract(1993, SourceType.REACH, 1, "FLOW_OUTcms");
            extract.Extract(2000, SourceType.REACH, 1, "FLOW_OUTcms");
            extract.Extract(2007, SourceType.REACH, 1, "FLOW_OUTcms");
            extract.Extract(SourceType.HRU, 1, "ETmm");
            extract.Extract(1993, SourceType.HRU, 1, "ETmm");
            extract.Extract(2000, SourceType.HRU, 1, "ETmm");
            extract.Extract(2007, SourceType.HRU, 1, "ETmm");

            Console.WriteLine("******************** Second Try ********************");
            extract.Extract(SourceType.REACH, 1, "FLOW_OUTcms");//case sensitive
            extract.Extract(1993, SourceType.REACH, 1, "FLOW_OUTcms");
            extract.Extract(2000, SourceType.REACH, 1, "FLOW_OUTcms");
            extract.Extract(2007, SourceType.REACH, 1, "FLOW_OUTcms");
            extract.Extract(SourceType.HRU, 1, "ETmm");
            extract.Extract(1993, SourceType.HRU, 1, "ETmm");
            extract.Extract(2000, SourceType.HRU, 1, "ETmm");
            extract.Extract(2007, SourceType.HRU, 1, "ETmm");
        }