Esempio n. 1
0
        public void MarksRequestsTest()
        {
            double[] latmin = null, latmax, lonmin, lonmax = null;
            int[]    startday, stopday, startyear, stopyear, starthour, stophour;

            //ClimateService.ServiceUrl = serviceUri;
            ClimateService.ServiceUrl = serviceUri;
            using (DataSet ds = DataSet.Open(@"Data\423b28bf6a4357f14b64f2b16ab759cb6b5961db.csv?openMode=readOnly"))
            {
                using (DataSet resultDs = ds.Clone("msds:memory"))
                {
                    latmin    = ((double[])ds.Variables["LatMin"].GetData()).Select(e => (double)e).ToArray();
                    latmax    = ((double[])ds.Variables["LatMax"].GetData()).Select(e => (double)e).ToArray();
                    lonmin    = ((double[])ds.Variables["LonMin"].GetData()).Select(e => (double)e).ToArray();
                    lonmax    = ((double[])ds.Variables["LonMax"].GetData()).Select(e => (double)e).ToArray();
                    startday  = ((int[])ds.Variables["StartDay"].GetData());
                    stopday   = ((int[])ds.Variables["StopDay"].GetData());
                    starthour = ((int[])ds.Variables["StartHour"].GetData());
                    stophour  = ((int[])ds.Variables["StartHour"].GetData());
                    startyear = ((int[])ds.Variables["StartYear"].GetData());
                    stopyear  = ((int[])ds.Variables["StartYear"].GetData());

                    TimeRegion   tr = new TimeRegion(startyear[0], stopyear[0]);
                    FetchRequest fr = new FetchRequest("prate", FetchDomain.CreatePoints(latmin, lonmax, tr), new string[] { "CRU CL 2.0" });

                    var result = ClimateService.FetchAsync(fr).Result;
                    //resultDs.AddVariable<double>("result",result, "cells_dim");
                    ;
                }
            }
        }
Esempio n. 2
0
        public void CacheTest()
        {
            if (File.Exists("cache.csv"))
            {
                File.Delete("cache.csv");
            }

            var result = ClimateService.FetchAsync(new FetchRequest("airt",
                                                                    FetchDomain.CreatePoints(new double[] { 57 }, new double[] { 0 }, new TimeRegion())), null, "cache.csv").Result;

            Assert.IsTrue(result.Variables.Contains("values"));

            try
            {
                ClimateService.ServiceUrl = "http://notexistentfetchclimateservice.localhost";
                var result2 = ClimateService.FetchAsync(new FetchRequest("airt",
                                                                         FetchDomain.CreatePoints(new double[] { 57 }, new double[] { 0 }, new TimeRegion())), null, "cache.csv").Result;
                Assert.IsTrue(result2.Variables.Contains("values"));

                try
                {
                    var result3 = ClimateService.FetchAsync(new FetchRequest("airt",
                                                                             FetchDomain.CreatePoints(new double[] { 57 }, new double[] { 0 }, new TimeRegion()))).Result;
                    Assert.Fail();
                }
                catch
                {
                    // It is OK to be here
                }
            }
            finally
            {
                ClimateService.ServiceUrl = "http://fetchclimate2.cloudapp.net";
            }
        }
Esempio n. 3
0
        public void CreateIntervalDataGroups_ShouldReturnTwoGroups_GivenThreeReadings59MinutesApart_And15MinuteInterval()
        {
            // ARRANGE
            var readings = new[]
            {
                new TemperatureHumidityReading {
                    TimestampUtc = DateTimeOffset.Parse("2018-10-30 20:01:07 +01:00")
                },
                new TemperatureHumidityReading {
                    TimestampUtc = DateTimeOffset.Parse("2018-10-30 20:51:47 +01:00")
                },
                new TemperatureHumidityReading {
                    TimestampUtc = DateTimeOffset.Parse("2018-10-30 20:11:07 +01:00")
                }
            };

            // ACT
            var result = ClimateService.SortDataIntoGroups("abc123", readings, TimeSpan.FromMinutes(15));

            // ASSERT
            result.Count().Should().Be(2);
            result.First().Count.Should().Be(2);
            result.First().From.Should().Be(DateTimeOffset.Parse("2018-10-30 20:00:00 +01:00"));
            result.First().To.Should().Be(DateTimeOffset.Parse("2018-10-30 20:15:00 +01:00"));
            result.Skip(1).First().Count.Should().Be(1);
            result.Skip(1).First().From.Should().Be(DateTimeOffset.Parse("2018-10-30 20:45:00 +01:00"));
            result.Skip(1).First().To.Should().Be(DateTimeOffset.Parse("2018-10-30 21:00:00 +01:00"));
        }
Esempio n. 4
0
        public void CellsEquivalence()
        {
            using (var ds = DataSet.Open("msds:memory"))
            {
                ds.AddAxisCells("Lat", "Degrees", 12.0, 15.0, 0.5);
                ds.AddAxisCells("Lon", "Degrees", 8.0, 11.0, 0.25);
                ds.AddClimatologyAxisYearly(yearStep: 29);
                ds.Commit();
                ds.Fetch(ClimateParameter.FC_TEMPERATURE, "air0");
                ds.Commit();
                double[, ,] temp = (double[, , ])ds.Variables["air0"].GetData();
                Assert.AreEqual(ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, 12.0, 12.5, 8.0, 8.25), temp[0, 0, 0], 1e-8);
                Assert.AreEqual(ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, 13.5, 14.0, 9.25, 9.5), temp[0, 3, 5], 1e-8);
                Assert.AreEqual(ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, 14.5, 15.0, 10.75, 11.0), temp[0, 5, 11], 1e-8);
            }

            using (var ds = DataSet.Open("msds:memory"))
            {
                ds.AddAxisCells("Lat", "Degrees", 12.0f, 15.0f, 0.5f);
                ds.AddAxisCells("Lon", "Degrees", 8.0, 11.0, 0.25);
                ds.AddClimatologyAxisYearly(yearStep: 30);
                ds.Commit();
                ds.Fetch(ClimateParameter.FC_TEMPERATURE, "air0");
                ds.Commit();
                double[, ,] temp = (double[, , ])ds.Variables["air0"].GetData();
                Assert.AreEqual(ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, 12.0, 12.5, 8.0, 8.25), temp[0, 0, 0], 1e-8);
                Assert.AreEqual(ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, 13.5, 14.0, 9.25, 9.5), temp[0, 3, 5], 1e-8);
                Assert.AreEqual(ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, 14.5, 15.0, 10.75, 11.0), temp[0, 5, 11], 1e-8);
            }
        }
Esempio n. 5
0
        public void CreateIntervalDataGroups_ShouldReturnThreeGroups_GivenTwoReadings150SecondsApartInReverseOrder()
        {
            // ARRANGE
            var readings = new[]
            {
                new TemperatureHumidityReading {
                    TimestampUtc = DateTimeOffset.Parse("2018-10-30 20:20:47 +01:00")
                },
                new TemperatureHumidityReading {
                    TimestampUtc = DateTimeOffset.Parse("2018-10-30 20:18:17 +01:00")
                }
            };

            // ACT
            var result = ClimateService.SortDataIntoGroups("abc123", readings, TimeSpan.FromMinutes(1));

            // ASSERT
            result.Count().Should().Be(2);
            result.First().Count.Should().Be(1);
            result.First().From.Should().Be(DateTimeOffset.Parse("2018-10-30 20:18:00 +01:00"));
            result.First().To.Should().Be(DateTimeOffset.Parse("2018-10-30 20:19:00 +01:00"));
            result.Skip(1).First().Count.Should().Be(1);
            result.Skip(1).First().From.Should().Be(DateTimeOffset.Parse("2018-10-30 20:20:00 +01:00"));
            result.Skip(1).First().To.Should().Be(DateTimeOffset.Parse("2018-10-30 20:21:00 +01:00"));
        }
Esempio n. 6
0
        public void CreateIntervalDataGroups_ShouldReturnEmptyArray_GivenEmptyArray()
        {
            // ARRANGE

            // ACT
            var result = ClimateService.SortDataIntoGroups("abc123", new TemperatureHumidityReading[0], TimeSpan.FromMinutes(1));

            // ASSERT
            result.Should().BeEmpty();
        }
Esempio n. 7
0
        public void CreateIntervalDataGroups_ShouldReturnEmptyArray_GivenNull()
        {
            // ARRANGE

            // ACT
            var result = ClimateService.SortDataIntoGroups("abc123", null, TimeSpan.FromMinutes(1));

            // ASSERT
            result.Should().BeEmpty();
        }
Esempio n. 8
0
        public void CalculateIntervalStartTime_TestCase(string timestamp, int intervalLengthInSeconds, string expectedResult)
        {
            // ARRANGE

            // ACT
            var result = ClimateService.CalculateIntervalStartTime(DateTimeOffset.Parse(timestamp), TimeSpan.FromSeconds(intervalLengthInSeconds));

            // ASSERT
            result.Should().Be(DateTimeOffset.Parse(expectedResult));
        }
Esempio n. 9
0
        public void CalculateInterval_Should(int intervalLengthInSeconds, int expectedResultInSeconds)
        {
            // ARRANGE

            // ACT
            var result = ClimateService.CalculateIntervalLength(TimeSpan.FromSeconds(intervalLengthInSeconds));

            // ASSERT
            result.TotalSeconds.Should().Be(expectedResultInSeconds);
        }
Esempio n. 10
0
 public void CellsToGridFallBack()
 {
     using (var ds = DataSet.Open("msds:memory"))
     {
         ds.AddAxisCells("Lat", "Degrees", 12.0f, 15.0f, 0.5f); //here is cells
         ds.AddAxis("Lon", "Degrees", 8.0f, 11.0f, 0.25f);      //here is grid
         ds.AddClimatologyAxisYearly(yearStep: 30);
         ds.Fetch(ClimateParameter.FC_TEMPERATURE, "air0");
         ds.Commit();
         double[, ,] temp = (double[, , ])ds.Variables["air0"].GetData();
         Assert.AreEqual(ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, 12.0, 12.0, 8.0, 8.0), temp[0, 0, 0], 1e-8);
         Assert.AreEqual(ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, 13.5, 13.5, 9.25, 9.25), temp[0, 3, 5], 1e-8);
         Assert.AreEqual(ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, 15.0, 15.0, 11.0, 11.0), temp[0, 6, 12], 1e-8);
     }
 }
Esempio n. 11
0
        static private DataSet Fetch(string request, string result, DateTime timestamp)
        {
            var r = JsonConvert.DeserializeObject <Microsoft.Research.Science.FetchClimate2.Serializable.FetchRequest>(File.ReadAllText(request));

            if (timestamp != DateTime.MaxValue)
            {
                r.ReproducibilityTimestamp = timestamp;
            }
            var dataset = ClimateService.FetchAsync(r.ConvertFromSerializable(), s => Console.WriteLine(s)).Result;

            if (result != null)
            {
                dataset = dataset.Clone(result);
            }
            return(dataset);
        }
Esempio n. 12
0
        public async Task ClimateService_GetClimateByNonExistentId_ReturnsNull()
        {
            // Arrange
            var mockClimateRepository = await new MockClimateRepository().MockGetById(null);

            var mockUnitOfWork = new MockUnitOfWork().MockGetClimateRepository(mockClimateRepository.Object);

            var climateService = new ClimateService(mockUnitOfWork.Object);

            // Act
            var climate = await climateService.GetClimateById(1);

            // Assert
            Assert.Null(climate);
            mockUnitOfWork.VerifyGetClimateRepository(Times.Once());
            mockClimateRepository.VerifyGetById(Times.Once());
        }
Esempio n. 13
0
        public void CreateIntervalDataGroups_ShouldReturnOneGroup_GivenOneReading()
        {
            // ARRANGE
            var readings = new[]
            {
                new TemperatureHumidityReading {
                    TimestampUtc = DateTimeOffset.Parse("2018-10-30 20:18:17 +01:00")
                }
            };

            // ACT
            var result = ClimateService.SortDataIntoGroups("abc123", readings, TimeSpan.FromMinutes(1));

            // ASSERT
            result.Count().Should().Be(1);
            result.First().Count.Should().Be(1);
            result.First().From.Should().Be(DateTimeOffset.Parse("2018-10-30 20:18:00 +01:00"));
            result.First().To.Should().Be(DateTimeOffset.Parse("2018-10-30 20:19:00 +01:00"));
        }
Esempio n. 14
0
        /// <summary>
        /// Method to get the list of precipitation and temparature values.
        /// </summary>
        /// <param name="latMin">Min latitude.</param>
        /// <param name="latMax">Max latitude.</param>
        /// <param name="longMin">Min longitude.</param>
        /// <param name="longMax">Max longitude.</param>
        /// <param name="dlat">Delta latitude.</param>
        /// <param name="dlong">Delta longitude.</param>
        /// <returns>List of FetchClimateOutputModel objects.</returns>
        public static List <FetchClimateOutputModel> GetPrecipitationAndTemp(double latMin, double latMax, double longMin, double longMax, double dlat, double dlong)
        {
            List <FetchClimateOutputModel> lstFetchClimateValues = new List <FetchClimateOutputModel>();
            double longMinTemp = longMin;

            try
            {
                // Creating collection of latitude and longitude values dependingon the user inputs.
                while (latMin < latMax)
                {
                    while (longMin < longMax)
                    {
                        lstFetchClimateValues.Add(new FetchClimateOutputModel(latMin, latMin + dlat, longMin, longMin + dlong, 0.00, 0.00));
                        longMin += dlong;
                    }

                    latMin += dlat;
                    longMin = longMinTemp;
                }

                // Getting list of precipitation values from fetch climate API
                double[] precipitation = ClimateService.FetchClimate(ClimateParameter.FC_PRECIPITATION, lstFetchClimateValues.Select(o => o.MinLatitude).ToArray(), lstFetchClimateValues.Select(o => o.MaxLatitude).ToArray(), lstFetchClimateValues.Select(o => o.MinLongitude).ToArray(), lstFetchClimateValues.Select(o => o.MaxLongitude).ToArray());

                // Getting list of temparature values from fetch climate API
                double[] temp = ClimateService.FetchClimate(ClimateParameter.FC_TEMPERATURE, lstFetchClimateValues.Select(o => o.MinLatitude).ToArray(), lstFetchClimateValues.Select(o => o.MaxLatitude).ToArray(), lstFetchClimateValues.Select(o => o.MinLongitude).ToArray(), lstFetchClimateValues.Select(o => o.MaxLongitude).ToArray());

                // Assigning precipitation and temparature values.
                lstFetchClimateValues.ForEach(location =>
                {
                    int index = lstFetchClimateValues.IndexOf(location);
                    location.Precipitation = precipitation[index];
                    location.Temperature   = temp[index];
                });
            }
            catch
            {
                lstFetchClimateValues = null;
            }

            return(lstFetchClimateValues);
        }
Esempio n. 15
0
        public async Task ClimateService_GetAllClimates_ReturnsIEnumerableClimates()
        {
            // Arrange
            var mockClimates = new List <Climate> {
                new Climate(),
            };

            var mockClimateRepository = await new MockClimateRepository().MockGetAll(mockClimates);

            var mockUnitOfWork = new MockUnitOfWork().MockGetClimateRepository(mockClimateRepository.Object);

            var climateService = new ClimateService(mockUnitOfWork.Object);

            // Act
            var climate = await climateService.GetClimates();

            // Assert
            Assert.NotNull(climate);
            mockUnitOfWork.VerifyGetClimateRepository(Times.Once());
            mockClimateRepository.VerifyGetAll(Times.Once());
        }
 /// <summary>
 /// Creates new variable with data from the FetchClimate service for the current lat/lon coordinate system and given time.
 /// </summary>
 /// <param name="ds">Target DataSet.</param>
 /// <param name="parameter">A climate parameter to fetch.</param>
 /// <param name="name">Name of the variable.</param>
 /// <param name="time">Time moment to fetch data for.</param>
 /// <returns>New variable instance.</returns>
 /// <remarks>
 /// <para>
 /// The method looks up the <paramref name="ds"/> for the lat/lon coordinate system.
 /// An axis is considered as a latitude grid if at least one of the following conditions are satisfied
 /// (case is ignored in all rules):
 /// <list type="bullet">
 /// <item><description>axis name starts with either "lat" or "_lat";</description></item>
 /// <item><description>axis name contains substring "latitude";</description></item>
 /// <item><description>axis has attribute Units containing substring "degree" and ends with "n" or "north".</description></item>
 /// </list>
 /// Similar rules for longitude axis:
 /// <list type="bullet">
 /// <item><description>axis name starts with either "lon" or "_lon";</description></item>
 /// <item><description>axis name contains substring "longitude";</description></item>
 /// <item><description>axis has attribute Units containing substring "degree" and ends with "e" or "east".</description></item>
 /// </list>
 /// </para>
 /// <para>If the axes not found, an exception is thrown.</para>
 /// <para>When a coordinate system is found, the Fetch Climate service is requested using a single batch request;
 /// result is added to the DataSet as 2d-variable depending on lat/lon axes.
 /// The DisplayName, long_name, Units, MissingValue, Provenance and Time attributes of the variable are set.
 /// </para>
 /// <example>
 /// <code>
 ///  // Fetching climate parameters for fixed time moment
 ///  using (var ds = DataSet.Open("msds:memory"))
 ///  {
 ///      Console.WriteLine("Filling dataset...");
 ///      ds.AddAxis("lon", "degrees East", -12.5, 20.0, 0.5);
 ///      ds.AddAxis("lat", "degrees North", 35.0, 60.0, 0.5);
 ///
 ///      ds.Fetch(ClimateParameter.FC_TEMPERATURE, "airt", new DateTime(2000, 7, 19, 11, 0, 0)); // time is fixed hence airt is 2d (depends on lat and lon)
 ///      ds.Fetch(ClimateParameter.FC_SOIL_MOISTURE, "soilm", new DateTime(2000, 7, 19, 11, 0, 0));
 ///
 ///      Console.WriteLine("Running DataSet Viewer...");
 ///      ds.View(@"airt(lon,lat) Style:Colormap; Palette:-5=Blue,White=0,#F4EF2F=5,Red=20; MapType:Aerial; Transparency:0.57000000000000006;;soilm(lon,lat) Style:Colormap; Palette:0=#00000000,#827DAAEC=300,#0000A0=800; Transparency:0; MapType:Aerial");
 ///  }
 ///
 ///  // Fetching climate parameters for different time moments
 ///  using (var ds = DataSet.Open("msds:memory"))
 ///  {
 ///      Console.WriteLine("Filling dataset...");
 ///      ds.AddAxis("lon", "degrees East", -12.5, 20.0, 2.0);
 ///      ds.AddAxis("lat", "degrees North", 35.0, 60.0, 2.0);
 ///      ds.AddAxis("time", new DateTime(2000, 7, 19, 0, 0, 0), new DateTime(2000, 7, 19, 23, 0, 0), TimeSpan.FromHours(2));
 ///
 ///      ds.Fetch(ClimateParameter.FC_TEMPERATURE, "airt"); // airt depends on lat,lon,time
 ///      ds.Fetch(ClimateParameter.FC_SOIL_MOISTURE, "soilm");
 ///
 ///      Console.WriteLine("Running DataSet Viewer...");
 ///      ds.View(@"airt(lon,lat) Style:Colormap; Palette:-5=Blue,White=0,#F4EF2F=5,Red=20; MapType:Aerial; Transparency:0.57000000000000006;;soilm(lon,lat) Style:Colormap; Palette:0=#00000000,#827DAAEC=300,#0000A0=800; Transparency:0; MapType:Aerial");
 ///  }
 /// </code>
 /// </example>
 /// </remarks>
 public static Variable Fetch(this DataSet ds, ClimateParameter parameter, string name, DateTime time, string nameUncertainty = null, string nameProvenance = null, EnvironmentalDataSource dataSource = EnvironmentalDataSource.ANY)
 {
     return(Fetch(ds, ClimateService.ClimateParameterToFC2VariableName(parameter), name, time, nameUncertainty, nameProvenance, ClimateService.EnvironmentalDataSourceToArrayOfFC2DataSources(dataSource)));
 }
Esempio n. 17
0
 public DashboardController(IHubContext <ClimateHub> hub, ClimateService climateService)
 {
     this._climateService = climateService;
     _hub = hub;
 }
 public HistoricalController(ClimateService climateService)
 {
     this._climateService = climateService;
 }
Esempio n. 19
0
        public void TestParameterIgnoringProvenance(ClimateParameter p, EnvironmentalDataSource ds)
        {
            ClimateService.ServiceUrl = "http://fetchclimate2.cloudapp.net/";

            const double MoscowLat = 55.7;
            const double MoscowLon = 37.5;

            const double PacificLat = -20;
            const double PacificLon = 170;

            const double PacificLatA = -15;
            const double PacificLonA = 175;

            const double KrasnoyarskLat = 56.017;
            const double KrasnoyarskLon = 92.867;

            const double AroundKrasnoyarskLatMin = 55;
            const double AroundKrasnoyarskLonMin = 91;

            const double AroundKrasnoyarskLatMax = 60;
            const double AroundKrasnoyarskLonMax = 95;

            const double SriLankaLatMin = 5;
            const double SriLankaLonMin = 70;

            const double SriLankaLatMax = 20;
            const double SriLankaLonMax = 87;

            string varName = ClimateService.ClimateParameterToFC2VariableName(p);

            Assert.AreNotEqual("", varName, string.Format("Mapping for {0} does not exist.", p.ToString()));

            string[] sources = ClimateService.EnvironmentalDataSourceToArrayOfFC2DataSources(ds);

            //Single point fetch
            var tr1 = new TimeRegion(1961, 1990);
            var tr2 = new TimeRegion(1990, 2000);
            //Moscow
            var request1 = new FetchRequest(
                varName,
                FetchDomain.CreatePoints(
                    new double[] { MoscowLat },
                    new double[] { MoscowLon },
                    tr1),
                sources);
            var    result1 = ClimateService.FetchAsync(request1).Result;
            double sd1     = ((double[])result1["sd"].GetData())[0];
            double value1  = ((double[])result1["values"].GetData())[0];

            Assert.AreEqual(sd1, ClimateService.FetchClimateUncertainty(p, MoscowLat, MoscowLat, MoscowLon, MoscowLon, dataSource: ds));
            Assert.AreEqual(value1, ClimateService.FetchClimate(p, MoscowLat, MoscowLat, MoscowLon, MoscowLon, dataSource: ds));

            //somewhere in Pacific Ocean
            var request2 = new FetchRequest(
                varName,
                FetchDomain.CreatePoints(
                    new double[] { PacificLat },
                    new double[] { PacificLon },
                    tr1),
                sources);
            var    result2 = ClimateService.FetchAsync(request2).Result;
            double sd2     = ((double[])result2["sd"].GetData())[0];
            double value2  = ((double[])result2["values"].GetData())[0];

            Assert.AreEqual(sd2, ClimateService.FetchClimateUncertainty(p, PacificLat, PacificLat, PacificLon, PacificLon, dataSource: ds));
            Assert.AreEqual(value2, ClimateService.FetchClimate(p, PacificLat, PacificLat, PacificLon, PacificLon, dataSource: ds));

            //Cell around Krasnoyarsk
            var request3 = new FetchRequest(
                varName,
                FetchDomain.CreateCells(
                    new double[] { AroundKrasnoyarskLatMin },
                    new double[] { AroundKrasnoyarskLonMin },
                    new double[] { AroundKrasnoyarskLatMax },
                    new double[] { AroundKrasnoyarskLonMax },
                    tr2),
                sources);
            var    result3 = ClimateService.FetchAsync(request3).Result;
            double sd3     = ((double[])result3["sd"].GetData())[0];
            double value3  = ((double[])result3["values"].GetData())[0];

            Assert.AreEqual(sd3, ClimateService.FetchClimateUncertainty(p, AroundKrasnoyarskLatMin, AroundKrasnoyarskLatMax, AroundKrasnoyarskLonMin, AroundKrasnoyarskLonMax, startyear: 1990, stopyear: 2000, dataSource: ds));
            Assert.AreEqual(value3, ClimateService.FetchClimate(p, AroundKrasnoyarskLatMin, AroundKrasnoyarskLatMax, AroundKrasnoyarskLonMin, AroundKrasnoyarskLonMax, startyear: 1990, stopyear: 2000, dataSource: ds));

            //Cell somewhere in Pacific Ocean
            var request4 = new FetchRequest(
                varName,
                FetchDomain.CreateCells(
                    new double[] { PacificLat },
                    new double[] { PacificLon },
                    new double[] { PacificLatA },
                    new double[] { PacificLonA },
                    tr2),
                sources);
            var    result4 = ClimateService.FetchAsync(request4).Result;
            double sd4     = ((double[])result4["sd"].GetData())[0];
            double value4  = ((double[])result4["values"].GetData())[0];

            Assert.AreEqual(sd4, ClimateService.FetchClimateUncertainty(p, PacificLat, PacificLatA, PacificLon, PacificLonA, startyear: 1990, stopyear: 2000, dataSource: ds));
            Assert.AreEqual(value4, ClimateService.FetchClimate(p, PacificLat, PacificLatA, PacificLon, PacificLonA, startyear: 1990, stopyear: 2000, dataSource: ds));

            //batch request
            double[] batchLonMin    = new double[] { PacificLon, AroundKrasnoyarskLonMin };
            double[] batchLonMax    = new double[] { PacificLon, AroundKrasnoyarskLonMax };
            double[] batchLatMin    = new double[] { PacificLat, AroundKrasnoyarskLatMin };
            double[] batchLatMax    = new double[] { PacificLat, AroundKrasnoyarskLatMax };
            int[]    batchStartYear = new int[] { 1961, 1990 };
            int[]    batchStopYear  = new int[] { 1990, 2000 };

            double[] sdGuess1    = ClimateService.FetchClimateUncertainty(p, batchLatMin, batchLatMax, batchLonMin, batchLonMax, null, null, null, null, batchStartYear, batchStopYear, ds);
            double[] valueGuess1 = ClimateService.FetchClimate(p, batchLatMin, batchLatMax, batchLonMin, batchLonMax, null, null, null, null, batchStartYear, batchStopYear, ds);

            Assert.AreEqual(sd2, sdGuess1[0]);
            Assert.AreEqual(sd3, sdGuess1[1]);
            Assert.AreEqual(value2, valueGuess1[0]);
            Assert.AreEqual(value3, valueGuess1[1]);

            //grid request
            var request5 = new FetchRequest(
                varName,
                FetchDomain.CreateCellGrid(
                    Enumerable.Range(0, (int)Math.Round((SriLankaLatMax - SriLankaLatMin) / 1) + 1).Select(i => SriLankaLatMin + i).ToArray(),
                    Enumerable.Range(0, (int)Math.Round((SriLankaLonMax - SriLankaLonMin) / 1) + 1).Select(i => SriLankaLonMin + i).ToArray(),
                    tr2),
                sources);
            var result5 = ClimateService.FetchAsync(request5).Result;

            double[,] gridSds    = (double[, ])result5["sd"].GetData();
            double[,] gridValues = (double[, ])result5["values"].GetData();
            int len0 = gridSds.GetLength(0), len1 = gridSds.GetLength(1);

            double[,] sdGuess2    = ClimateService.FetchUncertaintyGrid(p, SriLankaLatMin, SriLankaLatMax, SriLankaLonMin, SriLankaLonMax, 1, 1, yearmin: 1990, yearmax: 2000, dataSource: ds);
            double[,] valueGuess2 = ClimateService.FetchClimateGrid(p, SriLankaLatMin, SriLankaLatMax, SriLankaLonMin, SriLankaLonMax, 1, 1, yearmin: 1990, yearmax: 2000, dataSource: ds);

            //in FC2 grid is lon x lat while in FC1 it was lat x lon
            Assert.AreEqual(len0, sdGuess2.GetLength(1));
            Assert.AreEqual(len1, sdGuess2.GetLength(0));
            Assert.AreEqual(len0, valueGuess2.GetLength(1));
            Assert.AreEqual(len1, valueGuess2.GetLength(0));
            for (int i = 0; i < len0; ++i)
            {
                for (int j = 0; j < len1; ++j)
                {
                    Assert.AreEqual(gridSds[i, j], sdGuess2[j, i]);
                    Assert.AreEqual(gridValues[i, j], valueGuess2[j, i]);
                }
            }

            //Yearly TimeSeries for Krasnoyarsk
            var tr3      = new TimeRegion().GetYearlyTimeseries(1990, 2000);
            var request6 = new FetchRequest(
                varName,
                FetchDomain.CreatePoints(
                    new double[] { KrasnoyarskLat },
                    new double[] { KrasnoyarskLon },
                    tr3),
                sources);
            var result6 = ClimateService.FetchAsync(request6).Result;

            double[,] seriesSds1    = (double[, ])result6["sd"].GetData();
            double[,] seriesValues1 = (double[, ])result6["values"].GetData();

            double[] seriesSdsGuess1    = ClimateService.FetchClimateYearlyUncertainty(p, KrasnoyarskLat, KrasnoyarskLat, KrasnoyarskLon, KrasnoyarskLon, yearmin: 1990, yearmax: 2000, dataSource: ds);
            double[] seriesValuesGuess1 = ClimateService.FetchClimateYearly(p, KrasnoyarskLat, KrasnoyarskLat, KrasnoyarskLon, KrasnoyarskLon, yearmin: 1990, yearmax: 2000, dataSource: ds);

            Assert.AreEqual(seriesSds1.Length, seriesSdsGuess1.Length);
            Assert.AreEqual(seriesValues1.Length, seriesValuesGuess1.Length);
            for (int i = 0; i < seriesValues1.Length; ++i)
            {
                Assert.AreEqual(seriesSds1[0, i], seriesSdsGuess1[i]);
                Assert.AreEqual(seriesValues1[0, i], seriesValuesGuess1[i]);
            }

            //Monthly TimeSeries for Krasnoyarsk
            var tr4      = new TimeRegion(1990, 1991).GetSeasonlyTimeseries(30, 40);
            var request7 = new FetchRequest(
                varName,
                FetchDomain.CreatePoints(
                    new double[] { KrasnoyarskLat },
                    new double[] { KrasnoyarskLon },
                    tr4),
                sources);
            var result7 = ClimateService.FetchAsync(request7).Result;

            double[,] seriesSds2    = (double[, ])result7["sd"].GetData();
            double[,] seriesValues2 = (double[, ])result7["values"].GetData();

            double[] seriesSdsGuess2    = ClimateService.FetchClimateSeasonlyUncertainty(p, KrasnoyarskLat, KrasnoyarskLat, KrasnoyarskLon, KrasnoyarskLon, daymin: 30, daymax: 40, yearmin: 1990, yearmax: 1991, dataSource: ds);
            double[] seriesValuesGuess2 = ClimateService.FetchClimateSeasonly(p, KrasnoyarskLat, KrasnoyarskLat, KrasnoyarskLon, KrasnoyarskLon, daymin: 30, daymax: 40, yearmin: 1990, yearmax: 1991, dataSource: ds);

            Assert.AreEqual(seriesSds2.Length, seriesSdsGuess2.Length);
            Assert.AreEqual(seriesValues2.Length, seriesValuesGuess2.Length);
            for (int i = 0; i < seriesValues2.Length; ++i)
            {
                Assert.AreEqual(seriesSds2[0, i], seriesSdsGuess2[i]);
                Assert.AreEqual(seriesValues2[0, i], seriesValuesGuess2[i]);
            }

            //Hourly TimeSeries for Krasnoyarsk
            var tr5      = new TimeRegion(1990, 1991, 30, 31).GetHourlyTimeseries(isIntervalTimeseries: true);
            var request8 = new FetchRequest(
                varName,
                FetchDomain.CreatePoints(
                    new double[] { KrasnoyarskLat },
                    new double[] { KrasnoyarskLon },
                    tr5),
                sources);
            var result8 = ClimateService.FetchAsync(request8).Result;

            double[,] seriesSds3    = (double[, ])result8["sd"].GetData();
            double[,] seriesValues3 = (double[, ])result8["values"].GetData();

            double[] seriesSdsGuess3    = ClimateService.FetchClimateHourlyUncertainty(p, KrasnoyarskLat, KrasnoyarskLat, KrasnoyarskLon, KrasnoyarskLon, daymin: 30, daymax: 31, yearmin: 1990, yearmax: 1991, dataSource: ds);
            double[] seriesValuesGuess3 = ClimateService.FetchClimateHourly(p, KrasnoyarskLat, KrasnoyarskLat, KrasnoyarskLon, KrasnoyarskLon, daymin: 30, daymax: 31, yearmin: 1990, yearmax: 1991, dataSource: ds);

            Assert.AreEqual(seriesSds3.Length, seriesSdsGuess3.Length);
            Assert.AreEqual(seriesValues3.Length, seriesValuesGuess3.Length);
            for (int i = 0; i < seriesValues3.Length; ++i)
            {
                Assert.AreEqual(seriesSds3[0, i], seriesSdsGuess3[i]);
                Assert.AreEqual(seriesValues3[0, i], seriesValuesGuess3[i]);
            }
        }