Ejemplo n.º 1
0
        public static async Task <DataHandler> CreateAsync(IStorageContext dataContext)
        {
            var    storageDefinition = dataContext.StorageDefinition;
            string latAxisName       = IntegratorsFactoryHelpers.AutodetectLatName(storageDefinition);
            string lonAxisName       = IntegratorsFactoryHelpers.AutodetectLonName(storageDefinition);

            var timeAxisDetection = StepFunctionAutoDetectHelper.SmartDetectAxis(dataContext);
            var result            = timeAxisDetection as StepFunctionAutoDetectHelper.AxisFound;

            if (result == null)
            {
                throw new InvalidOperationException("Time axes detection failed");
            }


            var latAxisTask = dataContext.GetDataAsync(latAxisName);
            var lonAxisTask = dataContext.GetDataAsync(lonAxisName);
            var timeAxis    = await dataContext.GetDataAsync(result.AxisName);

            var timeGroupCalc = StepFunctionAutoDetectHelper.ConstructStatisticsCalculator(result.AxisKind, timeAxis, result.BaseOffset);

            var latAxis     = await latAxisTask;
            var latStatCalc = new CoveredPointsStatistics(latAxis);
            var lonAxis     = await lonAxisTask;
            var lonStatCalc = new CoveredPointsStatistics(lonAxis);

            var baseUncertaintyProvider           = new NoUncertaintyEvaluator();
            var coverageCheckUncertaintyEvaluator = new GridUncertaintyConventionsDecorator(baseUncertaintyProvider, latStatCalc, lonStatCalc, timeGroupCalc);
            var variablePresenceCheckEvaluator    = new VariablePresenceCheckDecorator(dataContext.StorageDefinition, coverageCheckUncertaintyEvaluator);

            var gridAggregator       = new GridModeAggregator(dataContext, timeGroupCalc, latStatCalc, lonStatCalc, true);
            var clusteringAggregator = new GridClusteringDecorator(dataContext.StorageDefinition, gridAggregator, timeGroupCalc, latStatCalc, lonStatCalc);

            return(new DataHandler(dataContext, variablePresenceCheckEvaluator, clusteringAggregator));
        }
Ejemplo n.º 2
0
        public void GetBoundingBoxDescAxisTest()
        {
            var target = new CoveredPointsStatistics(new double[] { 15.0, 10.0, 5.0, 0.0 });
            var res    = target.GetBoundingBox(1.1, 1.2);

            Assert.IsTrue(res.IsSingular); //requested region does not cover any data points

            res = target.GetBoundingBox(-1.2, -1.1);
            Assert.IsTrue(res.IsSingular); //requested region does not cover any data points

            res = target.GetBoundingBox(100, 120);
            Assert.IsTrue(res.IsSingular); //requested region does not cover any data points

            res = target.GetBoundingBox(1.1, 6.2);
            Assert.AreEqual(2, res.first);
            Assert.AreEqual(2, res.last);

            res = target.GetBoundingBox(1.1, 11.2);
            Assert.AreEqual(1, res.first);
            Assert.AreEqual(2, res.last);

            res = target.GetBoundingBox(1.1, 211.2);
            Assert.AreEqual(0, res.first);
            Assert.AreEqual(2, res.last);

            res = target.GetBoundingBox(-1.1, 11.2);
            Assert.AreEqual(1, res.first);
            Assert.AreEqual(3, res.last);

            res = target.GetBoundingBox(-1.1, 0.0);
            Assert.AreEqual(3, res.first);
            Assert.AreEqual(3, res.last);

            res = target.GetBoundingBox(15.0, 120.0);
            Assert.AreEqual(0, res.first);
            Assert.AreEqual(0, res.last);

            res = target.GetBoundingBox(5.0, 6.0);
            Assert.AreEqual(2, res.first);
            Assert.AreEqual(2, res.last);

            res = target.GetBoundingBox(4.0, 5.0);
            Assert.AreEqual(2, res.first);
            Assert.AreEqual(2, res.last);
        }
Ejemplo n.º 3
0
        public void GetDataIndicesDescAxisTest()
        {
            var target = new CoveredPointsStatistics(new double[] { 15.0, 10.0, 5.0, 0.0 });
            var res    = target.GetDataIndices(1.1, 1.2);

            Assert.AreEqual(0, res.Length); //requested region does not cover any data points

            res = target.GetDataIndices(-1.2, -1.1);
            Assert.AreEqual(0, res.Length); //requested region does not cover any data points

            res = target.GetDataIndices(100, 120);
            Assert.AreEqual(0, res.Length); //requested region does not cover any data points

            res = target.GetDataIndices(1.1, 6.2);
            CompareArrays(new int[] { 2 }, res);

            res = target.GetDataIndices(1.1, 11.2);
            CompareArrays(new int[] { 2, 1 }, res);

            res = target.GetDataIndices(1.1, 211.2);
            CompareArrays(new int[] { 2, 1, 0 }, res);

            res = target.GetDataIndices(-1.1, 11.2);
            CompareArrays(new int[] { 3, 2, 1 }, res);

            res = target.GetDataIndices(-1.1, 0.0);
            CompareArrays(new int[] { 3 }, res);

            res = target.GetDataIndices(15.0, 120.0);
            CompareArrays(new int[] { 0 }, res);

            res = target.GetDataIndices(5.0, 6.0);
            CompareArrays(new int[] { 2 }, res);

            res = target.GetDataIndices(4.0, 5.0);
            CompareArrays(new int[] { 2 }, res);
        }