Пример #1
0
        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.
        }
Пример #2
0
        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.
        }