示例#1
0
        public void GHCNtempInterpolationPointsTest()
        {
            FetchDomain  fd = FetchDomain.CreatePoints(new double[] { 1.5 }, new double[] { 1.0 }, new TimeRegion(firstYear: 1970, lastYear: 1970, firstDay: 60, lastDay: 90)); //mar
            FetchRequest fr = new FetchRequest("temp", fd);

            GhcnStorageContext storage = new GhcnStorageContext(fr);
            GHCNDataHandler    sotdh   = new GHCNDataHandler(storage);

            var compCont = new ComputationalContext();

            var evRes = sotdh.EvaluateAsync(storage, compCont).Result;

            var result = (double[])sotdh.AggregateAsync(storage, compCont).Result; //val = 3/5*lat-1 = 3/5*(1.5)-1 = -0.1

            Assert.AreEqual(-0.1, result[0], TestConstants.DoublePrecision);

            fd = FetchDomain.CreatePoints(new double[] { -2.5 }, new double[] { 1.0 }, new TimeRegion(firstYear: 1970, lastYear: 1970, firstDay: 60, lastDay: 90)); //mar
            fr = new FetchRequest("temp", fd);

            storage = new GhcnStorageContext(fr);
            sotdh   = new GHCNDataHandler(storage);

            compCont = new ComputationalContext();

            evRes = sotdh.EvaluateAsync(storage, compCont).Result;

            result = (double[])sotdh.AggregateAsync(storage, compCont).Result; //val =  3/5*lat =  3/5*(-2.5) = -1.5
            Assert.AreEqual(-1.5, result[0], TestConstants.DoublePrecision);
        }
示例#2
0
        public void GHCNprateInterpolationPointsTest()
        {
            FetchDomain  fd = FetchDomain.CreatePoints(new double[] { 0.5 }, new double[] { 1.0 }, new TimeRegion(firstYear: 1970, lastYear: 1970, firstDay: 91, lastDay: 120)); //april
            FetchRequest fr = new FetchRequest("prate", fd);

            GhcnStorageContext storage = new GhcnStorageContext(fr);
            GHCNDataHandler    sotdh   = new GHCNDataHandler(storage);

            var compCont = new ComputationalContext();

            var evRes = sotdh.EvaluateAsync(storage, compCont).Result;

            var result = (double[])sotdh.AggregateAsync(storage, compCont).Result; //val = 6/5*lat = 6/5*(0.5) = -3

            Assert.AreEqual(0.6, result[0], TestConstants.DoublePrecision);

            fd = FetchDomain.CreatePoints(new double[] { -5.0 }, new double[] { 1.0 }, new TimeRegion(firstYear: 1970, lastYear: 1970, firstDay: 91, lastDay: 120)); //april
            fr = new FetchRequest("prate", fd);

            storage = new GhcnStorageContext(fr);
            sotdh   = new GHCNDataHandler(storage);

            compCont = new ComputationalContext();

            evRes = sotdh.EvaluateAsync(storage, compCont).Result;

            result = (double[])sotdh.AggregateAsync(storage, compCont).Result; //val = 6/5*lat = 6/5*(-2.5) = -3
            Assert.AreEqual(0.0, result[0], TestConstants.DoublePrecision);    //as prate can't be negative, it is coerced to zero
        }
示例#3
0
        public void GHCNnanForOutOfObsConvexHullTest()
        {
            FetchDomain  fd = FetchDomain.CreatePoints(new double[] { -10 }, new double[] { 1.0 }, new TimeRegion(firstYear: 1970, lastYear: 1970, firstDay: 60, lastDay: 90)); //mar
            FetchRequest fr = new FetchRequest("prate", fd);

            GhcnStorageContext storage = new GhcnStorageContext(fr);
            GHCNDataHandler    sotdh   = new GHCNDataHandler(storage);

            var compCont = new ComputationalContext();

            var evRes = (double[])sotdh.EvaluateAsync(storage, compCont).Result;

            Assert.IsTrue(double.IsNaN(evRes[0]));

            var result = (double[])sotdh.AggregateAsync(storage, compCont).Result; //must be NAN as requested point out of observations convex hull

            Assert.IsTrue(double.IsNaN(result[0]));
        }