Example #1
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);
            }
        }
Example #2
0
        public void PiecewisePolynomialRatingEquationLindCouleeWasteway1()
        {
            PolynomialEquation eq1 = new PolynomialEquation(
                new double[] { 0.0 }, -1.0, 1.86, "-1 < stage <= 1.86 ");

            PolynomialEquation eq2 = new PolynomialEquation(
                new double[] { -28.4314, 15.2857 }, 1.861, 2.00, " 1.86 < stage <= 2.0");

            PolynomialEquation eq3 = new PolynomialEquation(
                new double[] { -0.3522, 88.1421, -96.6995, 31.4217, -2.3978 }, 2.001, 6.00, " 2.0 < stage <= 6.0 ");

            PolynomialEquation eq4 = new PolynomialEquation(
                new double[] { -769.4138, 249.0490 }, 6.001, 10.00, " 6.0 < stage ");

            PolynomialEquation[] equationList = { eq1, eq2, eq3, eq4 };

            Series s       = TestData.LindCouleeWW1DailyAverageStage2004;
            Series instant = TestData.LindCouleeWW1InstantanousStage2004;

            DateTime t1 = new DateTime(2004, 1, 2);
            DateTime t2 = new DateTime(2004, 12, 18); // at 12:00 am.. will capture 17th..not 18 th

            // compute polynomial based on daily average stage.
            Series p = Math.Polynomial(s, equationList, t1, t2);

            // compute instantanious flow first
            Series p2 = Math.Polynomial(instant, equationList, t1, t2);
            // get average second
            Series avg = Math.TimeWeightedDailyAverage(p2);

            SeriesList list = new SeriesList();

            list.Add(s);
            list.Add(p);
            list.Add(avg);

            list.WriteToConsole();
            //p.WriteToConsole();
        }
Example #3
0
        public void PiecewisePolynomialRatingEquationLindCouleeWasteway1()
        {
            PolynomialEquation eq1 = new PolynomialEquation(
            new double[]{0.0},-1.0, 1.86 ,"-1 < stage <= 1.86 ");

              PolynomialEquation eq2 = new PolynomialEquation(
            new double[]{-28.4314,15.2857},1.861, 2.00," 1.86 < stage <= 2.0");

              PolynomialEquation eq3 = new PolynomialEquation(
            new double[]{-0.3522,88.1421,-96.6995,31.4217,-2.3978},2.001, 6.00," 2.0 < stage <= 6.0 ");

              PolynomialEquation eq4 = new PolynomialEquation(
            new double[]{-769.4138,249.0490},6.001, 10.00," 6.0 < stage ");

              PolynomialEquation[] equationList = {eq1,eq2,eq3,eq4};

              Series s  = TestData.LindCouleeWW1DailyAverageStage2004;
              Series instant = TestData.LindCouleeWW1InstantanousStage2004;

              DateTime t1 = new DateTime(2004,1,2);
              DateTime t2 = new DateTime(2004,12,18); // at 12:00 am.. will capture 17th..not 18 th

              // compute polynomial based on daily average stage.
              Series p = Math.Polynomial(s,equationList,t1,t2);

              // compute instantanious flow first
              Series p2 = Math.Polynomial(instant,equationList,t1,t2);
              // get average second
              Series avg = Math.TimeWeightedDailyAverage(p2);

              SeriesList list = new SeriesList();
              list.Add(s);
              list.Add(p);
              list.Add(avg);

              list.WriteToConsole();
               //p.WriteToConsole();
        }
Example #4
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);
              }
        }