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 static async Task <WorldClim14DataSource> 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.MonthlyMeansOverEnoughYearsStepIntegratorFacade(50); // http://www.worldclim.org/methods says: "in most cases these records will represent the 1950-2000" var latIntegrator = await latIntegratorTask; var lonIntegrator = await lonIntegratorTask; var thinningLatIntegrator = new SpatGridIntegatorThinningDecorator(latIntegrator); var thinningLonIntegrator = new SpatGridIntegatorThinningDecorator(lonIntegrator); var baseNodeUncertainty = new WorldClimBaseNodeUnceratinty(); var temporalVarianceCalculaator = new LinearCombination1DVarianceCalc(new StorageContextMetadataTimeVarianceExtractor(storageDefinition, 12.0), timeIntegrator); var spatialVarianceCalculator = new LinearCombinationOnSphereVarianceCalculator(new StorageContextMetadataSpatialVarianceExtractor(storageDefinition), latIntegrator, lonIntegrator); var bitMaskProvider = new EmbeddedResourceBitMaskProvider(typeof(WorldClim14DataSource), "Microsoft.Research.Science.FetchClimate2.WcDataMask.bf"); var gaussianFieldUncertaintyEvaluator = new SequentialTimeSpatialUncertaintyEvaluatorFacade(timeIntegrator, thinningLatIntegrator, thinningLonIntegrator, 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); var scaledAggregator = new Microsoft.Research.Science.FetchClimate2.ValueAggregators.LinearTransformDecorator(dataContext, clusteringAggregator); return(new WorldClim14DataSource(dataContext, variablePresenceCheckEvaluator, scaledAggregator)); }