Example #1
0
        public static async Task <CruCl20DataHandler> CreateAsync(IStorageContext dataContext)
        {
            var storageDefinition = dataContext.StorageDefinition;
            var latIntegratorTask = LinearIntegratorsFactory.SmartConstructAsync(dataContext, IntegratorsFactoryHelpers.AutodetectLatName(storageDefinition));
            var lonIntegratorTask = LinearIntegratorsFactory.SmartConstructAsync(dataContext, IntegratorsFactoryHelpers.AutodetectLonName(storageDefinition));

            var timeIntegrator = new TimeAxisAvgProcessing.MonthlyMeansOverExactYearsStepIntegratorFacade(1961, 1990);
            var latIntegrator  = await latIntegratorTask;
            var lonIntegrator  = await lonIntegratorTask;

            var thinningLatIntegrator = new SpatGridIntegatorThinningDecorator(latIntegrator);
            var thinningLonIntegrator = new SpatGridIntegatorThinningDecorator(lonIntegrator);

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

            var bitMaskProvider = new EmbeddedResourceBitMaskProvider(typeof(CruCl20DataHandler), "Microsoft.Research.Science.FetchClimate2.CruDataMask.bf");

            var gaussianFieldUncertaintyEvaluator   = new SequentialTimeSpatialUncertaintyEvaluatorFacade(timeIntegrator, latIntegrator, lonIntegrator, temporalVarianceCalculaator, spatialVarianceCalculator, baseNodeUncertainty);
            var coverageCheckUncertaintyEvaluator   = new GridUncertaintyConventionsDecorator(gaussianFieldUncertaintyEvaluator, latIntegrator, lonIntegrator, timeIntegrator);
            var landMaskEnabledUncertaintyEvaluator = new GridBitmaskDecorator(coverageCheckUncertaintyEvaluator, bitMaskProvider);
            var variablePresenceCheckEvaluator      = new VariablePresenceCheckDecorator(dataContext.StorageDefinition, landMaskEnabledUncertaintyEvaluator);

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

            return(new CruCl20DataHandler(dataContext, variablePresenceCheckEvaluator, clusteringAggregator));
        }
        public void LongTermMonthlyMeansWithExactYears()
        {
            ITimeAxisAvgProcessing a = new TimeAxisAvgProcessing.MonthlyMeansOverExactYearsStepIntegratorFacade(1961, 1990); //the provider checks mongth alignment AND exact years match
            ITimeSegment           t = new TimeRegionExtensions.TimeSegment(2000, 2001, 1, 31, 0, 24);
            var c = a.GetCoverage(t);

            Assert.AreEqual(DataCoverageResult.DataWithoutUncertainty, c);      //years do not match

            t = new TimeRegionExtensions.TimeSegment(2000, 2001, 1, 38, 0, 24); //years do not match and time is not  aligned to month bounds
            c = a.GetCoverage(t);
            Assert.AreEqual(DataCoverageResult.DataWithoutUncertainty, c);

            t = new TimeRegionExtensions.TimeSegment(1961, 1990, 1, 38, 0, 24); //years match but time is not aligned to month bounds
            c = a.GetCoverage(t);
            Assert.AreEqual(DataCoverageResult.DataWithoutUncertainty, c);

            t = new TimeRegionExtensions.TimeSegment(1961, 1990, 1, 31, 0, 24); //years match and time is aligned to month bounds
            c = a.GetCoverage(t);
            Assert.AreEqual(DataCoverageResult.DataWithUncertainty, c);
        }