コード例 #1
0
 def test_reduce(self):
     data = numpy.fromfunction(lambda y, x: (y + x), (1000, 1000))
     lons = numpy.fromfunction(lambda y, x: -180 + (360.0 / 1000) * x, (1000, 1000))
     lats = numpy.fromfunction(lambda y, x: -90 + (180.0 / 1000) * y, (1000, 1000))
     grid_lons, grid_lats = self.area_def.get_lonlats()
     lons, lats, data = data_reduce.swath_from_lonlat_grid(grid_lons, grid_lats, lons, lats, data, 7000)
     cross_sum = data.sum()
     expected = 20514375.0
     self.assertAlmostEqual(cross_sum, expected, msg="Reduce data failed")
コード例 #2
0
 def test_reduce(self):
     data = np.fromfunction(lambda y, x: (y + x), (1000, 1000))
     lons = np.fromfunction(lambda y, x: -180 + (360.0 / 1000) * x,
                            (1000, 1000))
     lats = np.fromfunction(lambda y, x: -90 + (180.0 / 1000) * y,
                            (1000, 1000))
     grid_lons, grid_lats = self.area_def.get_lonlats()
     lons, lats, data = swath_from_lonlat_grid(grid_lons, grid_lats, lons,
                                               lats, data, 7000)
     cross_sum = data.sum()
     expected = 20685125.0
     self.assertAlmostEqual(cross_sum, expected)
コード例 #3
0
    def test_reduce_north_pole(self):
        """Test reducing around the poles."""

        from pyresample import utils
        area_id = 'ease_sh'
        description = 'Antarctic EASE grid'
        proj_id = 'ease_sh'
        projection = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
        x_size = 425
        y_size = 425
        area_extent = (-5326849.0625, -5326849.0625, 5326849.0625,
                       5326849.0625)
        area_def = utils.get_area_def(area_id, description, proj_id,
                                      projection, x_size, y_size, area_extent)

        grid_lons, grid_lats = area_def.get_lonlats()

        area_id = 'ease_sh'
        description = 'Antarctic EASE grid'
        proj_id = 'ease_sh'
        projection = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
        x_size = 1000
        y_size = 1000
        area_extent = (-532684.0625, -532684.0625, 532684.0625, 532684.0625)
        smaller_area_def = utils.get_area_def(area_id, description, proj_id,
                                              projection, x_size, y_size,
                                              area_extent)

        data = np.fromfunction(lambda y, x: (y + x), (1000, 1000))
        lons, lats = smaller_area_def.get_lonlats()

        lons, lats, data = swath_from_lonlat_grid(grid_lons, grid_lats, lons,
                                                  lats, data, 7000)

        cross_sum = data.sum()
        expected = 999000000.0
        self.assertAlmostEqual(cross_sum, expected)
コード例 #4
0
    def test_reduce_north_pole(self):
        """Test reducing around the poles."""

        from pyresample import utils
        area_id = 'ease_sh'
        description = 'Antarctic EASE grid'
        proj_id = 'ease_sh'
        projection = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
        x_size = 425
        y_size = 425
        area_extent = (-5326849.0625, -5326849.0625,
                       5326849.0625, 5326849.0625)
        area_def = utils.get_area_def(area_id, description, proj_id,
                                      projection, x_size, y_size, area_extent)

        grid_lons, grid_lats = area_def.get_lonlats()

        area_id = 'ease_sh'
        description = 'Antarctic EASE grid'
        proj_id = 'ease_sh'
        projection = '+proj=laea +lat_0=-90 +lon_0=0 +a=6371228.0 +units=m'
        x_size = 1000
        y_size = 1000
        area_extent = (-532684.0625, -532684.0625, 532684.0625, 532684.0625)
        smaller_area_def = utils.get_area_def(area_id, description, proj_id,
                                              projection, x_size, y_size,
                                              area_extent)

        data = np.fromfunction(lambda y, x: (y + x), (1000, 1000))
        lons, lats = smaller_area_def.get_lonlats()

        lons, lats, data = swath_from_lonlat_grid(grid_lons, grid_lats,
                                                  lons, lats, data, 7000)

        cross_sum = data.sum()
        expected = 999000000.0
        self.assertAlmostEqual(cross_sum, expected)