public void GhcnTempUncertaintyTest() { string etopoLocalUri = TestConstants.UriEtopo; var ghcnStorage = TestDataStorageFactory.GetStorage(TestConstants.UriGHCN); var etopoStorage = TestDataStorageFactory.GetStorage(etopoLocalUri); GHCNDataHandler handler = new GHCNDataHandler(ghcnStorage); ETOPO1DataSource.ETOPO1DataHandler elevationHandler = new ETOPO1DataSource.ETOPO1DataHandler(etopoStorage); TimeRegion tr = new TimeRegion(firstYear: 1921, lastYear: 1921).GetMonthlyTimeseries(firstMonth: 3, lastMonth: 3); //data index 2642 FetchDomain domain = FetchDomain.CreatePoints( new double[] { 36.27 }, //exact station. data index 3776 new double[] { -90.97 }, tr); FetchRequest tempRequest = new FetchRequest("temp", domain); Func <FetchRequest, Array> elevHandling = req => { var rewrittenReq = new FetchRequest("Elevation", req.Domain); return(elevationHandler.AggregateAsync(RequestContextStub.GetStub(etopoStorage, rewrittenReq), null).Result); }; var reqContext = RequestContextStub.GetStub(ghcnStorage, tempRequest, elevHandling); var compCont = new ComputationalContext(); Assert.AreEqual(0.0, (double)handler.EvaluateAsync(reqContext, compCont).Result.GetValue(0), 1e-6); //manual data comparison. }
public async Task Bug1523() { var storage = TestDataStorageFactory.GetStorage(TestConstants.UriEtopo); ETOPO1DataSource.ETOPO1DataHandler etopo = await ETOPO1DataSource.ETOPO1DataHandler.CreateAsync(storage); TimeRegion tr = new TimeRegion().GetMonthlyTimeseries(firstMonth: 1, lastMonth: 1); FetchDomain domain = FetchDomain.CreatePoints( new double[] { -90.0, 60.3 }, new double[] { 0.0, 40.9 }, tr); FetchRequest elevRequest = new FetchRequest("Elevation", domain); var handlerPrivate = new PrivateObject(etopo, new PrivateType(typeof(DataHandlerFacade))); var aggregatorPrivate = new PrivateObject(handlerPrivate, "valuesAggregator"); await(Task <Array>)(aggregatorPrivate.Invoke("AggregateAsync", RequestContextStub.GetStub(storage, elevRequest), null)); }
public void Bug1691() { double BayOfBiscaySELat = 44.5; double BayOfBiscaySELon = -3.5; double InFranceLat = 47; double InFranceLon = 1; Random r = new Random(1); var eps = r.NextDouble() / 10.0; double latDelta = InFranceLat - BayOfBiscaySELat; double lonDelta = InFranceLon - BayOfBiscaySELon; var tr = new TimeRegion(1990, 2001, 1, -1, 0, 24, true, false, true); var request = new FetchRequest( "temp", FetchDomain.CreateCellGrid( Enumerable.Range(0, 31).Select(i => eps + BayOfBiscaySELat + i * latDelta / 31.0).ToArray(), Enumerable.Range(0, 21).Select(i => eps + BayOfBiscaySELon + i * lonDelta / 21.0).ToArray(), tr)); string etopoLocalUri = TestConstants.UriEtopo; var ghcnStorage = TestDataStorageFactory.GetStorage(TestConstants.UriGHCN); var etopoStorage = TestDataStorageFactory.GetStorage(etopoLocalUri); GHCNDataHandler handler = new GHCNDataHandler(ghcnStorage); ETOPO1DataSource.ETOPO1DataHandler elevationHandler = new ETOPO1DataSource.ETOPO1DataHandler(etopoStorage); Func <FetchRequest, Array> elevHandling = req => { var rewrittenReq = new FetchRequest("Elevation", req.Domain); return(elevationHandler.AggregateAsync(RequestContextStub.GetStub(etopoStorage, rewrittenReq), null).Result); }; var reqContext = RequestContextStub.GetStub(ghcnStorage, request, elevHandling); var compCont = new ComputationalContext(); var evRes = handler.EvaluateAsync(reqContext, compCont).Result; Assert.IsTrue(-70.0 < (double)handler.AggregateAsync(reqContext, compCont).Result.GetValue(16, 2, 0)); //manual data comparison. }
public async Task EtopoValuesTest() { var storage = TestDataStorageFactory.GetStorageContext(TestConstants.UriEtopo); ETOPO1DataSource.ETOPO1DataHandler gtopo = await ETOPO1DataSource.ETOPO1DataHandler.CreateAsync(storage); ITimeRegion tr = new TimeRegion().GetMonthlyTimeseries(firstMonth: 1, lastMonth: 1); IFetchDomain domain = FetchDomain.CreatePoints( new double[] { 61.55, 61.55 }, // data index 9093 new double[] { 328.45, -31.55 }, //data index 8907 (the same point, different lon notations) tr); FetchRequest elevRequest = new FetchRequest("Elevation", domain); var handlerPrivate = new PrivateObject(gtopo, new PrivateType(typeof(DataHandlerFacade))); var aggregatorPrivate = new PrivateObject(handlerPrivate, "valuesAggregator"); Assert.AreEqual(-2441.0, (double)(await(Task <Array>)(aggregatorPrivate.Invoke("AggregateAsync", RequestContextStub.GetStub(storage, elevRequest), null))).GetValue(0), 1e-9); //manual data comparision Assert.AreEqual(-2441.0, (double)(await(Task <Array>)(aggregatorPrivate.Invoke("AggregateAsync", RequestContextStub.GetStub(storage, elevRequest), null))).GetValue(1), 1e-9); //manual data comparision }