예제 #1
0
        public static async Task <DataHandler> CreateAsync(IStorageContext dataContext)
        {
            var timeAxisDetection = StepFunctionAutoDetectHelper.SmartDetectAxis(dataContext);
            var detected          = timeAxisDetection as StepFunctionAutoDetectHelper.AxisFound;

            if (detected == null)
            {
                throw new InvalidOperationException("Can't autodetect time axis. See logs for particular failure reason");
            }
            var axis = await dataContext.GetDataAsync(detected.AxisName);

            var timeIntegrator    = StepFunctionAutoDetectHelper.ConstructAverager(detected.AxisKind, axis, detected.BaseOffset);
            var storageDefinition = dataContext.StorageDefinition;
            var latIntegratorTask = LinearIntegratorsFactory.SmartConstructAsync(dataContext, IntegratorsFactoryHelpers.AutodetectLatName(storageDefinition));
            var lonIntegratorTask = LinearIntegratorsFactory.SmartConstructAsync(dataContext, IntegratorsFactoryHelpers.AutodetectLonName(storageDefinition));

            var latIntegrator = await latIntegratorTask;
            var lonIntegrator = await lonIntegratorTask;

            //var baseNodeUncertainty = new NoBaseUncertaintyProvider();
            //var temporalVarianceCalculaator = new LinearCombination1DVarianceCalc(new StorageContextMetadataTimeVarianceExtractor(storageDefinition), timeIntegrator);
            //var spatialVarianceCalculator = new LinearCombinationOnSphereVarianceCalculator(new StorageContextMetadataSpatialVarianceExtractor(storageDefinition), latIntegrator, lonIntegrator);

            //var gaussianFieldUncertaintyEvaluator = new SequentialTimeSpatialUncertaintyEvaluatorFacade(timeIntegrator, latIntegrator, lonIntegrator, temporalVarianceCalculaator, spatialVarianceCalculator, baseNodeUncertainty);
            var percentileEvaluator = new PercentileGridAggregator(dataContext, timeIntegrator, latIntegrator, lonIntegrator, true);
            var coverageCheckUncertaintyEvaluator = new GridUncertaintyConventionsDecorator(percentileEvaluator, latIntegrator, lonIntegrator, timeIntegrator);
            var scaledUncertaintyEvaluator        = new Microsoft.Research.Science.FetchClimate2.UncertaintyEvaluators.LinearTransformDecorator(coverageCheckUncertaintyEvaluator);
            var variablePresenceCheckEvaluator    = new VariablePresenceCheckDecorator(dataContext.StorageDefinition, scaledUncertaintyEvaluator);

            var gridAggregator       = new GridMeanAggregator(dataContext, timeIntegrator, latIntegrator, lonIntegrator, true);
            var clusteringAggregator = new GridClusteringDecorator(dataContext.StorageDefinition, gridAggregator, timeIntegrator, latIntegrator, lonIntegrator);
            var scaledAggregator     = new Microsoft.Research.Science.FetchClimate2.ValueAggregators.LinearTransformDecorator(dataContext, clusteringAggregator);

            return(new DataHandler(dataContext, variablePresenceCheckEvaluator, scaledAggregator));
        }
예제 #2
0
        public static async Task <GenericLinearGridStepFunctionDataHandler> CreateAsync(IStorageContext dataContext)
        {
            var timeAxisDeterction = StepFunctionAutoDetectHelper.SmartDetectAxis(dataContext);
            var detected           = timeAxisDeterction as StepFunctionAutoDetectHelper.AxisFound;

            if (detected == null)
            {
                throw new InvalidOperationException("Can't autodetect time axis. See logs for particular failure reason");
            }
            var axis = await dataContext.GetDataAsync(detected.AxisName);

            var timeIntegrator = StepFunctionAutoDetectHelper.ConstructAverager(detected.AxisKind, axis, detected.BaseOffset);
            var a = await GenericLinearGridDataHandlerHelper.EasyConstructAsync(dataContext, timeIntegrator);

            var uncertatintyEvaluator = a.Item1;
            var valuesAggregator      = a.Item2;

            return(new GenericLinearGridStepFunctionDataHandler(dataContext, uncertatintyEvaluator, valuesAggregator));
        }
예제 #3
0
        public static async Task <DataHandler> CreateAsync(IStorageContext dataContext)
        {
            var storageDefinition = dataContext.StorageDefinition;
            var latIntegratorTask = LinearIntegratorsFactory.SmartConstructAsync(dataContext, IntegratorsFactoryHelpers.AutodetectLatName(storageDefinition));
            var lonIntegratorTask = LinearIntegratorsFactory.SmartConstructAsync(dataContext, 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 timeAxis = await dataContext.GetDataAsync(result.AxisName);

            if (timeAxis.Length < 2)
            {
                throw new InvalidOperationException("time axis length must be at least 2");
            }
            if (timeAxis.GetType().GetElementType() != typeof(Int16))
            {
                throw new InvalidOperationException("NDVI Yearly data handler now supports only Int16 time axis");
            }
            Int16[] typedTimeAxis = (Int16[])timeAxis;
            Int16   step          = (Int16)(typedTimeAxis[typedTimeAxis.Length - 1] - typedTimeAxis[typedTimeAxis.Length - 2]);

            Int16[] extendedAxis = typedTimeAxis.Concat(new Int16[] { (Int16)(typedTimeAxis[typedTimeAxis.Length - 1] + step) }).ToArray();

            var latIntegrator  = await latIntegratorTask;
            var lonIntegrator  = await lonIntegratorTask;
            var timeIntegrator = StepFunctionAutoDetectHelper.ConstructAverager(result.AxisKind, extendedAxis, result.BaseOffset);

            var baseUncertaintyProvider           = new NoUncertaintyEvaluator();
            var coverageCheckUncertaintyEvaluator = new GridUncertaintyConventionsDecorator(baseUncertaintyProvider, latIntegrator, lonIntegrator, timeIntegrator);
            var variablePresenceCheckEvaluator    = new VariablePresenceCheckDecorator(dataContext.StorageDefinition, coverageCheckUncertaintyEvaluator);

            var gridAggregator       = new GridMeanAggregator(dataContext, timeIntegrator, latIntegrator, lonIntegrator, true);
            var clusteringAggregator = new GridClusteringDecorator(dataContext.StorageDefinition, gridAggregator, timeIntegrator, latIntegrator, lonIntegrator);

            return(new DataHandler(dataContext, variablePresenceCheckEvaluator, clusteringAggregator));
        }