public void SelectOnlySpecificValuesUsingAggregationFilterFromBottom() // TODO: migrate to fit tests
        {
            IRegularGridCoverage grid2D = new RegularGridCoverage(4, 4, 1, 1);

            var values = new[, ]
            {
                { 1.1, 2.1, 3.1, 4.1 },
                { 1.2, 2.2, 3.2, 4.2 },
                { 1.3, 2.3, 3.3, 4.3 },                // <-
                { 1.4, 2.4, 3.4, 4.4 },                // <-
            };

            grid2D.SetValues(values);

            var subSelection = grid2D.GetValues <double>(new VariableAggregationFilter(grid2D.Y, 1, 2, 3));

            Assert.IsTrue(subSelection.SequenceEqual(new[] { 1.3, 2.3, 3.3, 4.3, 1.4, 2.4, 3.4, 4.4 }));
        }
        private static IRegularGridCoverage CreatePressureTimeDependentRegularGridCoverage(out DateTime time1, out DateTime time2)
        {
            IRegularGridCoverage grid2D = new RegularGridCoverage(2, 3, 100, 50)
            {
                // default constructor will set x[0] to 0.0 and y[0] to 0.0
                Name = "pressure"
            };

            var time = new Variable <DateTime>("time");

            grid2D.Time = time;

            time1 = DateTime.Now;
            var values1 = new[]
            {
                1.0, 2.0,
                3.0, 4.0,
                5.0, 6.0
            };

            grid2D.SetValues(values1, new VariableValueFilter <DateTime>(time, time1));
            Assert.AreEqual(6, grid2D.GetValues <double>().Count);

            time2 = time1.AddDays(1);
            var values2 = new[]
            {
                10.0, 20.0,
                30.0, 40.0,
                50.0, 60.0
            };

            grid2D.SetValues(values2, new VariableValueFilter <DateTime>(time, time2));

            // resulting dynamic coverage is
            //                   t = now                  t = now + 1day
            //              x =   0   x = 100             x =   0   x = 100
            //
            // y =   0   |    1.0       2.0        |        10.0       20.0
            // y =  50   |    3.0       4.0        |        30.0       40.0
            // y = 100   |    5.0       6.0        |        50.0       60.0
            //
            //
            return(grid2D);
        }
        public void SelectOnlySpecificValuesUsingAggregationFilter() // TODO: migrate to fit tests
        {
            IRegularGridCoverage grid2D = new RegularGridCoverage(4, 4, 1, 1);

            var values = new[, ]
            {
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                { 1.0, 2.0, 3.0, 4.0 },
                //    ^         ^
            };

            grid2D.SetValues(values);

            var subSelection = grid2D.GetValues <double>(new VariableAggregationFilter(grid2D.X, 2, 0, 3));

            Assert.IsTrue(subSelection.SequenceEqual(new[] { 1.0, 3.0, 1.0, 3.0, 1.0, 3.0, 1.0, 3.0 }));
        }
        public void AggregateInTime()
        {
            var grid2D = new RegularGridCoverage(2, 3, 100, 50)
            {
                Name = "pressure"
            };

            var time = new Variable <DateTime>("time");

            grid2D.Time = time;

            DateTime time1   = DateTime.Now;
            var      values1 = new[]
            {
                1.0, 1.0,
                1.0, 1.0,
                50.0, 60.0
            };

            grid2D.SetValues(values1, new VariableValueFilter <DateTime>(time, time1));
            Assert.AreEqual(6, grid2D.GetValues <double>().Count);

            DateTime time2   = time1.AddDays(1);
            var      values2 = new[]
            {
                1.0, 1.0,
                4.0, 4.0,
                50.0, 60.0
            };

            grid2D.SetValues(values2, new VariableValueFilter <DateTime>(time, time2));

            Func <int, double, int> aggregator = ((seed, h) => (h > 3) ? (seed + 1) : seed);
            var result = grid2D.Aggregate(time, 0, aggregator);

            var aggregatedValues = (IEnumerable <int>)result.Components[0].GetValues();

            Assert.IsTrue(new[] { 0, 0, 1, 1, 2, 2 }.SequenceEqual(aggregatedValues));
        }
        public void SelectOnlySpecificValuesUsingAggregationFilterFromBottom() // TODO: migrate to fit tests
        {
            IRegularGridCoverage grid2D = new RegularGridCoverage(4, 4, 1, 1);

            var values = new[,]
                             {
                                 {1.1, 2.1, 3.1, 4.1},
                                 {1.2, 2.2, 3.2, 4.2},
                                 {1.3, 2.3, 3.3, 4.3}, // <-
                                 {1.4, 2.4, 3.4, 4.4}, // <-
                             };

            grid2D.SetValues(values);

            var subSelection = grid2D.GetValues<double>(new VariableAggregationFilter(grid2D.Y, 1, 2, 3));

            Assert.IsTrue(subSelection.SequenceEqual(new[] {1.3, 2.3, 3.3, 4.3, 1.4, 2.4, 3.4, 4.4}));
        }
        public void SelectOnlySpecificValuesUsingAggregationFilter() // TODO: migrate to fit tests
        {
            IRegularGridCoverage grid2D = new RegularGridCoverage(4, 4, 1, 1);

            var values = new[,]
                             {
                                 {1.0, 2.0, 3.0, 4.0},
                                 {1.0, 2.0, 3.0, 4.0},
                                 {1.0, 2.0, 3.0, 4.0},
                                 {1.0, 2.0, 3.0, 4.0},
                                 //    ^         ^
                             };

            grid2D.SetValues(values);

            var subSelection = grid2D.GetValues<double>(new VariableAggregationFilter(grid2D.X, 2, 0, 3));

            Assert.IsTrue(subSelection.SequenceEqual(new[] {1.0, 3.0, 1.0, 3.0, 1.0, 3.0, 1.0, 3.0}));
        }
        public void AggregateInTime()
        {
            var grid2D = new RegularGridCoverage(2, 3, 100, 50)
                             {
                                 Name = "pressure"
                             };

            var time = new Variable<DateTime>("time");
            grid2D.Time = time;

            DateTime time1 = DateTime.Now;
            var values1 = new[]
                              {
                                  1.0, 1.0,
                                  1.0, 1.0,
                                  50.0, 60.0
                              };
            grid2D.SetValues(values1, new VariableValueFilter<DateTime>(time, time1));
            Assert.AreEqual(6, grid2D.GetValues<double>().Count);

            DateTime time2 = time1.AddDays(1);
            var values2 = new[]
                              {
                                  1.0, 1.0,
                                  4.0, 4.0,
                                  50.0, 60.0
                              };
            grid2D.SetValues(values2, new VariableValueFilter<DateTime>(time, time2));

            Func<int, double, int> aggregator = ((seed, h) => (h > 3) ? (seed + 1) : seed);
            var result = grid2D.Aggregate(time, 0, aggregator);

            var aggregatedValues = (IEnumerable<int>) result.Components[0].GetValues();
            Assert.IsTrue(new[] {0, 0, 1, 1, 2, 2}.SequenceEqual(aggregatedValues));
        }
        private static IRegularGridCoverage CreatePressureTimeDependentRegularGridCoverage(out DateTime time1, out DateTime time2)
        {
            IRegularGridCoverage grid2D = new RegularGridCoverage(2, 3, 100, 50)
                                              {
                                                  // default constructor will set x[0] to 0.0 and y[0] to 0.0
                                                  Name = "pressure"
                                              };

            var time = new Variable<DateTime>("time");
            grid2D.Time = time;

            time1 = DateTime.Now;
            var values1 = new[]
                              {
                                  1.0, 2.0,
                                  3.0, 4.0,
                                  5.0, 6.0
                              };
            grid2D.SetValues(values1, new VariableValueFilter<DateTime>(time, time1));
            Assert.AreEqual(6, grid2D.GetValues<double>().Count);

            time2 = time1.AddDays(1);
            var values2 = new[]
                              {
                                  10.0, 20.0,
                                  30.0, 40.0,
                                  50.0, 60.0
                              };
            grid2D.SetValues(values2, new VariableValueFilter<DateTime>(time, time2));

            // resulting dynamic coverage is 
            //                   t = now                  t = now + 1day
            //              x =   0   x = 100             x =   0   x = 100
            //
            // y =   0   |    1.0       2.0        |        10.0       20.0
            // y =  50   |    3.0       4.0        |        30.0       40.0
            // y = 100   |    5.0       6.0        |        50.0       60.0
            //
            //
            return grid2D;
        }