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 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)); }