public static async Task <CESM1BGCDataHandler> CreateAsync(IStorageContext dataContext) { var storageDefinition = dataContext.StorageDefinition; var timeAxis = await dataContext.GetDataAsync("time"); var timeIntegrator = new TimeAxisAvgProcessing.TimeAxisAvgFacade( timeAxis, new TimeAxisProjections.ContinuousDays(new DateTime(2005, 1, 1)), new WeightProviders.StepFunctionInterpolation(), new DataCoverageEvaluators.ContinousMeansCoverageEvaluator() ); 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 thinningTimeIntegrator = new TimeAxisIntegratorThinningDecorator(timeIntegrator); var thinningLatIntegrator = new SpatGridIntegatorThinningDecorator(latIntegrator); var thinningLonIntegrator = new SpatGridIntegatorThinningDecorator(lonIntegrator); 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(thinningTimeIntegrator, thinningLatIntegrator, thinningLonIntegrator, temporalVarianceCalculaator, spatialVarianceCalculator, baseNodeUncertainty); var coverageCheckUncertaintyEvaluator = new GridUncertaintyConventionsDecorator(gaussianFieldUncertaintyEvaluator, latIntegrator, lonIntegrator, timeIntegrator); var scaledUncertaintyEvaluator = new Microsoft.Research.Science.FetchClimate2.UncertaintyEvaluators.LinearTransformDecorator(coverageCheckUncertaintyEvaluator); var variablePresenceCheckEvaluator = new VariablePresenceCheckDecorator(dataContext.StorageDefinition, scaledUncertaintyEvaluator); //we do not need DegK to DegC in uncertainty as uncertainty is based on defference and does not depend on constant ofsets scaledUncertaintyEvaluator.SetTranform("pr", new Func <double, double>(v => v * 2592000.0)); //kg/m^2/s to mm/month (assuming month is 30 days) var gridAggregator = new GridMeanAggregator(dataContext, timeIntegrator, latIntegrator, lonIntegrator, false); var clusteringAggregator = new GridClusteringDecorator(dataContext.StorageDefinition, gridAggregator, timeIntegrator, latIntegrator, lonIntegrator); var scaledAggregator = new Microsoft.Research.Science.FetchClimate2.ValueAggregators.LinearTransformDecorator(dataContext, clusteringAggregator); scaledAggregator.SetAdditionalTranform("tas", new Func <double, double>(v => v - 273.15)); // DegK to DegC scaledAggregator.SetAdditionalTranform("pr", new Func <double, double>(v => v * 2592000.0)); //kg/m^2/s to mm/month (assuming month is 30 days) return(new CESM1BGCDataHandler(dataContext, variablePresenceCheckEvaluator, scaledAggregator)); }
public static async Task <MLDDataHandler> CreateAsync(IStorageContext dataContext) { var storageDefinition = dataContext.StorageDefinition; var latIntegratorTask = LinearIntegratorsFactory.SmartConstructAsync(dataContext, IntegratorsFactoryHelpers.AutodetectLatName(storageDefinition)); var lonIntegratorTask = LinearIntegratorsFactory.SmartConstructAsync(dataContext, IntegratorsFactoryHelpers.AutodetectLonName(storageDefinition)); var timeAxis = await dataContext.GetDataAsync("days since 1998-1-1 0:0:0"); var timeIntegrator = new TimeAxisAvgProcessing.TimeAxisAvgFacade( timeAxis, new TimeAxisProjections.ContinuousDays(new DateTime(1998, 1, 1)), new WeightProviders.StepFunctionInterpolation(), new DataCoverageEvaluators.ContinousMeansCoverageEvaluator()); var latIntegrator = await latIntegratorTask; var lonIntegrator = await lonIntegratorTask; var thinningLatIntegrator = new SpatGridIntegatorThinningDecorator(latIntegrator); var thinningLonIntegrator = new SpatGridIntegatorThinningDecorator(lonIntegrator); var thinningTimeIntegrator = new TimeAxisIntegratorThinningDecorator(timeIntegrator); 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(thinningTimeIntegrator, thinningLatIntegrator, thinningLonIntegrator, temporalVarianceCalculaator, spatialVarianceCalculator, baseNodeUncertainty); var coverageCheckUncertaintyEvaluator = new GridUncertaintyConventionsDecorator(gaussianFieldUncertaintyEvaluator, 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); gridAggregator.SetMissingValue("data", -9999); return(new MLDDataHandler(dataContext, variablePresenceCheckEvaluator, clusteringAggregator)); }