Пример #1
0
        public void TextFileHydromet()
        {
            string path = TestData.DataPath + "\\";
            string fn1  = path + "LuckyPeakWaterLevel.txt";

            Console.WriteLine("reading " + fn1);
            TextSeries s = new TextSeries(fn1);

            s.Read();
            Assert.IsTrue(s.Count > 0);
            DateTime t1 = Convert.ToDateTime("10/13/2004");
            double   v  = s.Lookup(t1);

            Assert.IsTrue(System.Math.Abs(v - 2907.2) < 0.01, "expected 2907.2. got " + v);

            // save to text file..
            string fn = Path.GetTempFileName();

            //fn = TestData.OutputPath+"\\"+fn;
            s.WriteCsv(fn);

            TextSeries s1 = new TextSeries(fn);

            s1.Read();
            Assert.IsTrue(s.Count == s1.Count);
            v = s1.Lookup(t1);
            Assert.IsTrue(System.Math.Abs(v - 2907.2) < 0.01, "expected 2907.2. got " + v);

            File.Delete(fn);
            Console.WriteLine("finished TextFileHydromet");
        }
Пример #2
0
        public void TextFileDigitizedChart()
        {
            string     fn = TestData.DataPath + "\\el68d_DigitizedChart.txt";
            TextSeries s  = new TextSeries(fn);

            s.Read();
            //s.Save(TestData.DataPath +"\\el68d_DigitizedChart2.txt");
            //1999/01/02 12:40:11,   4.969
            DateTime t1 = Convert.ToDateTime("1999/01/02 12:40:11");

            Assert.IsTrue(System.Math.Abs(s.Lookup(t1) - 4.969) < 0.001);
        }
Пример #3
0
        public void SubsetByMonth()
        {
            // skip october (10th month)
            int[] months = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12 };

            string path = TestData.DataPath + "\\";
            string fn1  = path + "LuckyPeakWaterLevel.txt";

            Console.WriteLine("reading " + fn1);
            TextSeries s = new TextSeries(fn1);

            s.Read();

            DateTime d = DateTime.Parse("10/1/2004");

            Console.WriteLine(d);
            //10/1/2004	2926.91

            Assert.AreEqual(127, s.IndexOf(d), "test data [DateTime] has changed?");
            Assert.AreEqual(2926.91, s.Lookup(d), "test data [Value] has changed?");
            Series s2 = Reclamation.TimeSeries.Math.Subset(s, months);

            Assert.AreEqual(-1, s2.IndexOf(d), "October 1, 2004 was not removed");
        }