示例#1
0
        public void Site68OnefullDay()
        {
            Series s = TestData.Site68OneFullDayInstantaneous;

            Series avg = Math.TimeWeightedDailyAverage(s);

            avg.WriteToConsole();
            Assert.AreEqual(1, avg.Count); // should have 1 daily average
        }
示例#2
0
        public void PartialDay()
        {
            string fn = Path.Combine(TestData.DataPath, "wilson.xls");
            var    s  = new ExcelDataReaderSeries(fn, "wilson", "A", "B");

            s.Read();

            Series avg = Math.TimeWeightedDailyAverage(s);
        }
示例#3
0
        public void LindCoulee2004()
        {
            Series s = TestData.LindCouleeWW1InstantanousStage2004;
            //Point pt =  Math.Calculator.AverageForDay(s,DateTime.Parse("2004-12-20"));
            Series avg = Math.TimeWeightedDailyAverage(s);

            // Console.WriteLine("avg");
            //avg.WriteToConsole();
            Console.WriteLine(avg[0].DateTime.ToString("yyyy-MM-dd HH:mm:ss.ffff"));

            Console.WriteLine("Math.Calculator.DailyAverage(s).Count = " + avg.Count);

            Series dbAverage = TestData.LindCouleeWW1DailyAverageStage2004;

            Console.WriteLine("TestData.LindCouleeWW1DailyAverageStage2004.Count = " + dbAverage.Count);


            Series     diff = avg - dbAverage;
            SeriesList list = new SeriesList();

            list.Add(avg);
            list.Add(dbAverage);
            list.Add(diff);
            list.WriteToConsole();

            Console.WriteLine("summing difference");
            double d = Math.Sum(diff);

            Assert.AreEqual(0, d, 0.1); // actual is about 0.05
            Console.WriteLine("sum of differences = " + d);
            Console.WriteLine("sum of daily " + Math.Sum(avg));
            Assert.AreEqual(dbAverage.Count - 1, avg.Count);
            for (int i = 0; i < avg.Count; i++)
            {
                // database has one (missing) value at beginning we skip that in comparison
                Assert.AreEqual(dbAverage[i + 1].ToString(), avg[i].ToString());
                Assert.AreEqual(dbAverage[i + 1].Value, avg[i].Value, 0.0001);
                Assert.AreEqual(dbAverage[i + 1].DateTime.Ticks, avg[i].DateTime.Ticks, "on line " + i);
            }
        }
示例#4
0
        public void MultipleDayAverageBanks()
        {
            Console.WriteLine("MultipleDayAverageBanks Test");
            Series input = TestData.Banks;

            Series ts = Math.TimeWeightedDailyAverage(input);

            /*
             * type of series is PeriodAver
             * units:feet
             * 5/17/2005, 1568.52804869882
             * 5/18/2005, 1568.38618500667
             * 5/19/2005, 1568.12503620462
             * 5/20/2005, 1567.96182203232
             * 5/21/2005, 1568.07234682992
             * 5/22/2005, 1568.56578340813
             * 5/23/2005, 1568.78610831966
             * 5/24/2005, 1568.68114810308
             * */
            double[] goodValues = { 1568.52804869882,
                                    1568.38618500667,
                                    1568.12503620462,
                                    1567.96182203232,
                                    1568.07234682992,
                                    1568.56578340813,
                                    1568.78610831966,
                                    1568.68114810308 };
            DateTime date = new DateTime(2005, 5, 17);

            for (int i = 0; i < ts.Count; i++)
            {
                double val = ts.Lookup(date);
                Assert.AreEqual(goodValues[i], val, 0.1);
                date = date.AddDays(1);
            }
        }