Пример #1
0
        public void DetailedM11Test()
        {
            var _karup = new Model(@"..\..\..\TestData\Karup_Example_DemoMode1.she").Results;

            var m11obs = _karup.Mike11Observations;

            Assert.AreEqual(1, m11obs.Count);

            var scaled = TSTools.ChangeZoomLevel(m11obs.First().Simulation, TimeStepUnit.Month, true);
        }
Пример #2
0
        public void ChangeZoomLevelTimespan()
        {
            TimeSpanSeries ts = new TimeSpanSeries();

            ts.Items.Add(new TimeSpanValue(new DateTime(2010, 1, 1, 12, 0, 0), new DateTime(2010, 1, 1, 12, 15, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2010, 1, 1, 12, 15, 0), new DateTime(2010, 1, 1, 12, 30, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2010, 10, 1, 12, 0, 0), new DateTime(2010, 10, 1, 12, 15, 0), 10));
            ts.TimeStepSize = TimeStepUnit.Minute;

            TimeSpanSeries ts2 = new TimeSpanSeries(TSTools.ChangeZoomLevel(ts, TimeStepUnit.Month, true));

            Assert.AreEqual(20, ts2.Max);
            Assert.AreEqual(2, ts2.Count);
        }
Пример #3
0
        public void TestMethod1()
        {
            DFS0 df      = new DFS0(@"C:\Users\Jacob\Downloads\gridKlima20148.dfs0");
            var  monthly = TSTools.ChangeZoomLevel(df.GetTimeSpanSeries(1), TimeStepUnit.Month, true);

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(@"C:\Users\Jacob\Downloads\Monthly_20148.csv"))
            {
                sw.WriteLine("Year,Month,Precip");
                foreach (var v in monthly.Items)
                {
                    sw.WriteLine(v.Time.Year + "," + v.Time.Month + "," + v.Value);
                }
            }
        }
Пример #4
0
        public void ChangeZoomLevelTest()
        {
            FixedTimeStepSeries Data = new FixedTimeStepSeries()
            {
                TimeStepSize = TimeStepUnit.Month
            };

            Data.AddRange(new DateTime(2010, 1, 1), new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 });

            var actual = TSTools.ChangeZoomLevel(Data, TimeStepUnit.Year, true);

            Assert.AreEqual(78, actual.GetValue(Data.StartTime));
            actual = TSTools.ChangeZoomLevel(Data, TimeStepUnit.Year, false);
            Assert.AreEqual(6.5, actual.GetValue(Data.StartTime), 1e-10);
            Assert.AreEqual(Data.DeleteValue, actual.GetValue(Data.StartTime.AddDays(400)));
        }
        public void LoadTest()
        {
            FixedTimeStepSeries fxt = new FixedTimeStepSeries();

            fxt.StartTime    = new DateTime(1990, 1, 1);
            fxt.TimeStepSize = TimeStepUnit.Month;

            using (StreamReader sr = new StreamReader(@"D:\OldWork\HydroNumerics\Core\UnitTest\ts.csv"))
            {
                sr.ReadLine();
                while (!sr.EndOfStream)
                {
                    fxt.Items.Add(new ValueDouble(double.Parse(sr.ReadLine().Split(';')[1])));
                }
            }
            var yearly = TSTools.ChangeZoomLevel(fxt, TimeStepUnit.Year, true);

            Assert.AreEqual(4733123.6582, yearly.GetValue(new DateTime(2010, 5, 5)), 0.1);
            Assert.AreEqual(4733123.6582, yearly.GetValue(new DateTime(2010, 1, 1)), 0.1);
            Assert.AreEqual(4733123.6582, yearly.GetValue(new DateTime(2010, 12, 31)), 0.1);
        }
Пример #6
0
        public void ChangeZoomLevelTest3()
        {
            FixedTimeStepSeries Data = new FixedTimeStepSeries()
            {
                TimeStepSize = TimeStepUnit.Month
            };

            Data.StartTime = new DateTime(2010, 1, 1);

            for (int i = 0; i < 36; i++)
            {
                Data.Add(i);
            }

            Assert.AreEqual(new DateTime(2012, 12, 1), Data.EndTime);

            var yearly = TSTools.ChangeZoomLevel(Data, TimeStepUnit.Year, false);

            Assert.AreEqual(5.5, yearly.Items[0].Value);
            Assert.AreEqual(17.5, yearly.Items[1].Value);
            Assert.AreEqual(29.5, yearly.Items[2].Value);
        }
        public void ConstructorTest()
        {
            TimeSpanSeries ts = new TimeSpanSeries();

            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 1, 12, 0, 0), new DateTime(2014, 1, 1, 12, 12, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 1, 13, 1, 0), new DateTime(2014, 1, 1, 13, 12, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 2, 12, 0, 0), new DateTime(2014, 1, 2, 12, 12, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 3, 12, 0, 0), new DateTime(2014, 1, 3, 12, 12, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 4, 12, 0, 0), new DateTime(2014, 1, 4, 12, 12, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 4, 12, 12, 0), new DateTime(2014, 1, 4, 12, 24, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 12, 12, 12, 0), new DateTime(2014, 1, 12, 12, 24, 0), 10));

            FixedTimeStepSeries fx = new FixedTimeStepSeries(ts, true);

            var daily = TSTools.ChangeZoomLevel(fx, TimeStepUnit.Day, true);

            Assert.AreEqual(5, daily.TimeSpanValues.Count());

            var monthly = TSTools.ChangeZoomLevel(fx, TimeStepUnit.Month, true);
            var yearly  = TSTools.ChangeZoomLevel(fx, TimeStepUnit.Year, true);

            Assert.AreEqual(ts.Sum, monthly.Sum);

            ts = new TimeSpanSeries()
            {
                TimeStepSize = TimeStepUnit.Minute
            };
            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 1, 12, 15, 0), new DateTime(2014, 1, 1, 12, 30, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 1, 12, 30, 0), new DateTime(2014, 1, 1, 12, 45, 0), 10));
            ts.Items.Add(new TimeSpanValue(new DateTime(2014, 1, 1, 14, 45, 0), new DateTime(2014, 1, 1, 15, 00, 0), 10));
            ts.GapFill(InterpolationMethods.DeleteValue, TimeSpan.FromMinutes(15));

            fx = new FixedTimeStepSeries(ts, false);

            Assert.AreEqual(10, fx.Items[0].Value);
        }