当前位置: 首页>>代码示例>>Python>>正文


Python kd_tree.resample_gauss函数代码示例

本文整理汇总了Python中pyresample.kd_tree.resample_gauss函数的典型用法代码示例。如果您正苦于以下问题:Python resample_gauss函数的具体用法?Python resample_gauss怎么用?Python resample_gauss使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了resample_gauss函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_gauss_multi_uncert

 def test_gauss_multi_uncert(self):
     data = numpy.fromfunction(lambda y, x: (y + x)*10**-6, (5000, 100))        
     lons = numpy.fromfunction(lambda y, x: 3 + (10.0/100)*x, (5000, 100))
     lats = numpy.fromfunction(lambda y, x: 75 - (50.0/5000)*y, (5000, 100))
     swath_def = geometry.SwathDefinition(lons=lons, lats=lats)
     data_multi = numpy.column_stack((data.ravel(), data.ravel(),\
                                      data.ravel()))
     if sys.version_info < (2, 6):
         res, stddev, counts = kd_tree.resample_gauss(swath_def, data_multi,\
                                             self.area_def, 50000, [25000, 15000, 10000], 
                                             segments=1, with_uncert=True)
     else:
         with warnings.catch_warnings(record=True) as w:
             res, stddev, counts = kd_tree.resample_gauss(swath_def, data_multi,\
                                                 self.area_def, 50000, [25000, 15000, 10000], 
                                                 segments=1, with_uncert=True)
             self.failIf(len(w) != 1, 'Failed to create neighbour radius warning')
             self.failIf(('Possible more' not in str(w[0].message)), 'Failed to create correct neighbour radius warning') 
     cross_sum = res.sum()
     cross_sum_stddev = stddev.sum()
     cross_sum_counts = counts.sum()
     expected = 1461.84313918
     expected_stddev = 0.446204424799
     expected_counts = 4934802.0
     self.assertTrue(res.shape == stddev.shape and stddev.shape == counts.shape and counts.shape == (800, 800, 3))
     self.assertAlmostEqual(cross_sum, expected,
                             msg='Swath multi channel resampling gauss failed on data')
     self.assertAlmostEqual(cross_sum_stddev, expected_stddev,
                             msg='Swath multi channel resampling gauss failed on stddev')
     self.assertAlmostEqual(cross_sum_counts, expected_counts,
                             msg='Swath multi channel resampling gauss failed on counts')
开发者ID:Alwnikrotikz,项目名称:pyresample,代码行数:31,代码来源:test_kd_tree.py

示例2: test_self_map_multi

    def test_self_map_multi(self):
        data = np.column_stack((self.tb37v, self.tb37v, self.tb37v))
        swath_def = geometry.SwathDefinition(lons=self.lons, lats=self.lats)

        if (sys.version_info < (2, 6) or
                (sys.version_info >= (3, 0) and sys.version_info < (3, 4))):
            res = kd_tree.resample_gauss(swath_def, data, swath_def,
                                         radius_of_influence=70000, sigmas=[56500, 56500, 56500])
        else:
            with warnings.catch_warnings(record=True) as w:
                res = kd_tree.resample_gauss(swath_def, data, swath_def,
                                             radius_of_influence=70000, sigmas=[56500, 56500, 56500])
                self.assertFalse(
                    len(w) != 1, 'Failed to create neighbour radius warning')
                self.assertFalse(('Possible more' not in str(
                    w[0].message)), 'Failed to create correct neighbour radius warning')

        if sys.platform == 'darwin':
            # OSX seems to get slightly different results for `_spatial_mp.Cartesian`
            truth_value = 668848.144817
        else:
            truth_value = 668848.082208
        self.assertAlmostEqual(res[:, 0].sum() / 100., truth_value, 1,
                               msg='Failed self mapping swath multi for channel 1')
        self.assertAlmostEqual(res[:, 1].sum() / 100., truth_value, 1,
                               msg='Failed self mapping swath multi for channel 2')
        self.assertAlmostEqual(res[:, 2].sum() / 100., truth_value, 1,
                               msg='Failed self mapping swath multi for channel 3')
开发者ID:cpaulik,项目名称:pyresample,代码行数:28,代码来源:test_swath.py

示例3: test_gauss_uncert

    def test_gauss_uncert(self):
        sigma = utils.fwhm2sigma(41627.730557884883)
        if (sys.version_info < (2, 6) or
                (sys.version_info >= (3, 0) and sys.version_info < (3, 4))):
            res, stddev, count = kd_tree.resample_gauss(self.tswath, self.tdata,
                                                        self.tgrid, 100000, sigma,
                                                        with_uncert=True)
        else:
            with warnings.catch_warnings(record=True) as w:
                res, stddev, count = kd_tree.resample_gauss(self.tswath, self.tdata,
                                                            self.tgrid, 100000, sigma,
                                                            with_uncert=True)
                self.assertFalse(
                    len(w) != 1, 'Failed to create neighbour warning')
                self.assertFalse(('Searching' not in str(
                    w[0].message)), 'Failed to create correct neighbour warning')

        expected_res = 2.20206560694
        expected_stddev = 0.707115076173
        expected_count = 3
        self.assertAlmostEqual(res[0], expected_res, 5,
                               'Failed to calculate gaussian weighting with uncertainty')
        self.assertAlmostEqual(stddev[0], expected_stddev, 5,
                               'Failed to calculate uncertainty for gaussian weighting')
        self.assertEqual(
            count[0], expected_count, 'Wrong data point count for gaussian weighting with uncertainty')
开发者ID:nicolasfauchereau,项目名称:pyresample,代码行数:26,代码来源:test_kd_tree.py

示例4: test_gauss_multi_mp_segments

 def test_gauss_multi_mp_segments(self):
     data = numpy.fromfunction(lambda y, x: (y + x) * 10 ** -6, (5000, 100))
     lons = numpy.fromfunction(
         lambda y, x: 3 + (10.0 / 100) * x, (5000, 100))
     lats = numpy.fromfunction(
         lambda y, x: 75 - (50.0 / 5000) * y, (5000, 100))
     swath_def = geometry.SwathDefinition(lons=lons, lats=lats)
     data_multi = numpy.column_stack((data.ravel(), data.ravel(),
                                      data.ravel()))
     if (sys.version_info < (2, 6) or
             (sys.version_info >= (3, 0) and sys.version_info < (3, 4))):
         res = kd_tree.resample_gauss(swath_def, data_multi,
                                      self.area_def, 50000, [
                                          25000, 15000, 10000],
                                      nprocs=2, segments=1)
     else:
         with warnings.catch_warnings(record=True) as w:
             res = kd_tree.resample_gauss(swath_def, data_multi,
                                          self.area_def, 50000, [
                                              25000, 15000, 10000],
                                          nprocs=2, segments=1)
             self.assertFalse(
                 len(w) != 1, 'Failed to create neighbour radius warning')
             self.assertFalse(('Possible more' not in str(
                 w[0].message)), 'Failed to create correct neighbour radius warning')
     cross_sum = res.sum()
     expected = 1461.84313918
     self.assertAlmostEqual(cross_sum, expected,
                            msg='Swath multi channel segments resampling gauss failed')
开发者ID:nicolasfauchereau,项目名称:pyresample,代码行数:29,代码来源:test_kd_tree.py

示例5: test_gauss_multi_uncert

 def test_gauss_multi_uncert(self):
     data = numpy.fromfunction(lambda y, x: (y + x) * 10 ** -6, (5000, 100))
     lons = numpy.fromfunction(
         lambda y, x: 3 + (10.0 / 100) * x, (5000, 100))
     lats = numpy.fromfunction(
         lambda y, x: 75 - (50.0 / 5000) * y, (5000, 100))
     swath_def = geometry.SwathDefinition(lons=lons, lats=lats)
     data_multi = numpy.column_stack((data.ravel(), data.ravel(),
                                      data.ravel()))
     if (sys.version_info < (2, 6) or
             (sys.version_info >= (3, 0) and sys.version_info < (3, 4))):
         res, stddev, counts = kd_tree.resample_gauss(swath_def, data_multi,
                                                      self.area_def, 50000, [
                                                          25000, 15000, 10000],
                                                      segments=1, with_uncert=True)
     else:
         with warnings.catch_warnings(record=True) as w:
             # The assertion below checks if there is only one warning raised
             # and whether it contains a specific message from pyresample
             # On python 2.7.9+ the resample_gauss method raises multiple deprecation warnings
             # that cause to fail, so we ignore the unrelated warnings.
             # TODO: better way would be to filter UserWarning correctly
             ignore_list = [DeprecationWarning]
             try:
                 from numpy import VisibleDeprecationWarning
             except ImportError:
                 pass
             else:
                 ignore_list.append(VisibleDeprecationWarning)
             warnings.simplefilter('ignore', tuple(ignore_list))
             res, stddev, counts = kd_tree.resample_gauss(swath_def, data_multi,
                                                          self.area_def, 50000, [
                                                              25000, 15000, 10000],
                                                          segments=1, with_uncert=True)
             self.assertFalse(
                 len(w) != 1, 'Failed to create neighbour radius warning')
             self.assertFalse(('Possible more' not in str(
                 w[0].message)), 'Failed to create correct neighbour radius warning')
     cross_sum = res.sum()
     cross_sum_stddev = stddev.sum()
     cross_sum_counts = counts.sum()
     expected = 1461.84313918
     expected_stddev = 0.446204424799
     expected_counts = 4934802.0
     self.assertTrue(res.shape == stddev.shape and stddev.shape ==
                     counts.shape and counts.shape == (800, 800, 3))
     self.assertAlmostEqual(cross_sum, expected,
                            msg='Swath multi channel resampling gauss failed on data')
     self.assertAlmostEqual(cross_sum_stddev, expected_stddev,
                            msg='Swath multi channel resampling gauss failed on stddev')
     self.assertAlmostEqual(cross_sum_counts, expected_counts,
                            msg='Swath multi channel resampling gauss failed on counts')
开发者ID:cpaulik,项目名称:pyresample,代码行数:52,代码来源:test_kd_tree.py

示例6: test_gauss_base

 def test_gauss_base(self):
     if sys.version_info < (2, 6):
         res = kd_tree.resample_gauss(self.tswath, \
                                          self.tdata.ravel(), self.tgrid,\
                                          50000, 25000, reduce_data=False, segments=1)
     else:
         with warnings.catch_warnings(record=True) as w:
             res = kd_tree.resample_gauss(self.tswath, \
                                          self.tdata.ravel(), self.tgrid,\
                                          50000, 25000, reduce_data=False, segments=1)
             self.failIf(len(w) != 1, 'Failed to create neighbour warning')
             self.failIf(('Searching' not in str(w[0].message)), 'Failed to create correct neighbour warning')    
     self.assertAlmostEqual(res[0], 2.2020729, 5, \
                                'Failed to calculate gaussian weighting')
开发者ID:Alwnikrotikz,项目名称:pyresample,代码行数:14,代码来源:test_kd_tree.py

示例7: test_self_map

 def test_self_map(self):
     swath_def = geometry.SwathDefinition(lons=self.lons, lats=self.lats)
     if sys.version_info < (2, 6):
         res = kd_tree.resample_gauss(swath_def, self.tb37v.copy(), swath_def, 
                                      radius_of_influence=70000, sigmas=56500)
     else:
         with warnings.catch_warnings(record=True) as w:
             res = kd_tree.resample_gauss(swath_def, self.tb37v.copy(), swath_def,
                                          radius_of_influence=70000, sigmas=56500)
             self.assertFalse(len(w) != 1, 'Failed to create neighbour radius warning')
             self.assertFalse(('Possible more' not in str(w[0].message)), 'Failed to create correct neighbour radius warning')
    
     self.assertAlmostEqual(res.sum() / 100., 668848.082208, 1, 
                             msg='Failed self mapping swath for 1 channel')
开发者ID:valgur,项目名称:pyresample,代码行数:14,代码来源:test_swath.py

示例8: test_gauss_multi_uncert

    def test_gauss_multi_uncert(self):
        data = np.fromfunction(lambda y, x: (y + x) * 10 ** -6, (5000, 100))
        lons = np.fromfunction(
            lambda y, x: 3 + (10.0 / 100) * x, (5000, 100))
        lats = np.fromfunction(
            lambda y, x: 75 - (50.0 / 5000) * y, (5000, 100))
        swath_def = geometry.SwathDefinition(lons=lons, lats=lats)
        data_multi = np.column_stack((data.ravel(), data.ravel(),
                                      data.ravel()))
        with catch_warnings(UserWarning) as w:
            # The assertion below checks if there is only one warning raised
            # and whether it contains a specific message from pyresample
            # On python 2.7.9+ the resample_gauss method raises multiple deprecation warnings
            # that cause to fail, so we ignore the unrelated warnings.
            res, stddev, counts = kd_tree.resample_gauss(swath_def, data_multi,
                                                         self.area_def, 50000, [
                                                             25000, 15000, 10000],
                                                         segments=1, with_uncert=True)
            self.assertTrue(len(w) >= 1)
            self.assertTrue(
                any(['Possible more' in str(x.message) for x in w]))
        cross_sum = res.sum()
        cross_sum_counts = counts.sum()
        expected = 1461.8429990248171
        expected_stddev = [0.44621800779801657, 0.44363137712896705,
                           0.43861019464274459]
        expected_counts = 4934802.0
        self.assertTrue(res.shape == stddev.shape and stddev.shape ==
                        counts.shape and counts.shape == (800, 800, 3))
        self.assertAlmostEqual(cross_sum, expected)

        for i, e_stddev in enumerate(expected_stddev):
            cross_sum_stddev = stddev[:, :, i].sum()
            self.assertAlmostEqual(cross_sum_stddev, e_stddev)
        self.assertAlmostEqual(cross_sum_counts, expected_counts)
开发者ID:pytroll,项目名称:pyresample,代码行数:35,代码来源:test_kd_tree.py

示例9: test_self_map_multi

    def test_self_map_multi(self):
        data = np.column_stack((self.tb37v, self.tb37v, self.tb37v))
        swath_def = geometry.SwathDefinition(lons=self.lons, lats=self.lats)

        with catch_warnings() as w:
            res = kd_tree.resample_gauss(
                swath_def, data, swath_def, radius_of_influence=70000, sigmas=[56500, 56500, 56500]
            )
            self.assertFalse(len(w) != 1, "Failed to create neighbour radius warning")
            self.assertFalse(
                ("Possible more" not in str(w[0].message)), "Failed to create correct neighbour radius warning"
            )

        if sys.platform == "darwin":
            # OSX seems to get slightly different results for `_spatial_mp.Cartesian`
            truth_value = 668848.144817
        else:
            truth_value = 668848.082208
        self.assertAlmostEqual(
            res[:, 0].sum() / 100.0, truth_value, 1, msg="Failed self mapping swath multi for channel 1"
        )
        self.assertAlmostEqual(
            res[:, 1].sum() / 100.0, truth_value, 1, msg="Failed self mapping swath multi for channel 2"
        )
        self.assertAlmostEqual(
            res[:, 2].sum() / 100.0, truth_value, 1, msg="Failed self mapping swath multi for channel 3"
        )
开发者ID:pytroll,项目名称:pyresample,代码行数:27,代码来源:test_swath.py

示例10: test_masked_gauss

    def test_masked_gauss(self):
        data = numpy.ones((50, 10))
        data[:, 5:] = 2
        lons = numpy.fromfunction(lambda y, x: 3 + x, (50, 10))
        lats = numpy.fromfunction(lambda y, x: 75 - y, (50, 10))
        swath_def = geometry.SwathDefinition(lons=lons, lats=lats)
        mask = numpy.ones((50, 10))
        mask[:, :5] = 0
        masked_data = numpy.ma.array(data, mask=mask)
        res = kd_tree.resample_gauss(swath_def, masked_data.ravel(),
                                     self.area_def, 50000, 25000, segments=1)
        expected_mask = numpy.fromfile(os.path.join(os.path.dirname(__file__),
                                                    'test_files',
                                                    'mask_test_mask.dat'),
                                       sep=' ').reshape((800, 800))
        expected_data = numpy.fromfile(os.path.join(os.path.dirname(__file__),
                                                    'test_files',
                                                    'mask_test_data.dat'),
                                       sep=' ').reshape((800, 800))
        expected = expected_data.sum()
        cross_sum = res.data.sum()

        self.assertTrue(numpy.array_equal(expected_mask, res.mask),
                        msg='Gauss resampling of swath mask failed')
        self.assertAlmostEqual(cross_sum, expected, places=3,
                               msg='Gauss resampling of swath masked data failed')
开发者ID:nicolasfauchereau,项目名称:pyresample,代码行数:26,代码来源:test_kd_tree.py

示例11: test_gauss_base

 def test_gauss_base(self):
     with catch_warnings(UserWarning) as w:
         res = kd_tree.resample_gauss(self.tswath,
                                      self.tdata.ravel(), self.tgrid,
                                      50000, 25000, reduce_data=False, segments=1)
         self.assertFalse(len(w) != 1)
         self.assertFalse(('Searching' not in str(w[0].message)))
     self.assertAlmostEqual(res[0], 2.2020729, 5)
开发者ID:pytroll,项目名称:pyresample,代码行数:8,代码来源:test_kd_tree.py

示例12: test_gauss

 def test_gauss(self):
     data = numpy.fromfunction(lambda y, x: (y + x) * 10 ** -5, (5000, 100))
     lons = numpy.fromfunction(lambda y, x: 3 + (10.0 / 100) * x, (5000, 100))
     lats = numpy.fromfunction(lambda y, x: 75 - (50.0 / 5000) * y, (5000, 100))
     swath_def = geometry.SwathDefinition(lons=lons, lats=lats)
     if sys.version_info < (2, 6) or (sys.version_info >= (3, 0) and sys.version_info < (3, 4)):
         res = kd_tree.resample_gauss(swath_def, data.ravel(), self.area_def, 50000, 25000, segments=1)
     else:
         with warnings.catch_warnings(record=True) as w:
             res = kd_tree.resample_gauss(swath_def, data.ravel(), self.area_def, 50000, 25000, segments=1)
             self.assertFalse(len(w) != 1, "Failed to create neighbour radius warning")
             self.assertFalse(
                 ("Possible more" not in str(w[0].message)), "Failed to create correct neighbour radius warning"
             )
     cross_sum = res.sum()
     expected = 4872.81050892
     self.assertAlmostEqual(cross_sum, expected, msg="Swath resampling gauss failed")
开发者ID:johnlavelle,项目名称:pyresample,代码行数:17,代码来源:test_kd_tree.py

示例13: test_gauss_fwhm

 def test_gauss_fwhm(self):
     data = numpy.fromfunction(lambda y, x: (y + x)*10**-5, (5000, 100))        
     lons = numpy.fromfunction(lambda y, x: 3 + (10.0/100)*x, (5000, 100))
     lats = numpy.fromfunction(lambda y, x: 75 - (50.0/5000)*y, (5000, 100))
     swath_def = geometry.SwathDefinition(lons=lons, lats=lats)
     if sys.version_info < (2, 6):
         res = kd_tree.resample_gauss(swath_def, data.ravel(),\
                                      self.area_def, 50000, utils.fwhm2sigma(41627.730557884883), segments=1)
     else:
         with warnings.catch_warnings(record=True) as w:
             res = kd_tree.resample_gauss(swath_def, data.ravel(),\
                                          self.area_def, 50000, utils.fwhm2sigma(41627.730557884883), segments=1)
             self.failIf(len(w) != 1, 'Failed to create neighbour radius warning')
             self.failIf(('Possible more' not in str(w[0].message)), 'Failed to create correct neighbour radius warning')        
     cross_sum = res.sum()        
     expected = 4872.81050892
     self.assertAlmostEqual(cross_sum, expected,\
                                msg='Swath resampling gauss failed')
开发者ID:Alwnikrotikz,项目名称:pyresample,代码行数:18,代码来源:test_kd_tree.py

示例14: test_gauss_sparse

 def test_gauss_sparse(self):
     data = numpy.fromfunction(lambda y, x: y * x, (50, 10))
     lons = numpy.fromfunction(lambda y, x: 3 + x, (50, 10))
     lats = numpy.fromfunction(lambda y, x: 75 - y, (50, 10))
     swath_def = geometry.SwathDefinition(lons=lons, lats=lats)
     res = kd_tree.resample_gauss(swath_def, data.ravel(), self.area_def, 50000, 25000, fill_value=-1, segments=1)
     cross_sum = res.sum()
     expected = 15387753.9852
     self.assertAlmostEqual(cross_sum, expected, places=3, msg="Swath gauss sparse nearest failed")
开发者ID:johnlavelle,项目名称:pyresample,代码行数:9,代码来源:test_kd_tree.py

示例15: test_self_map_multi

 def test_self_map_multi(self):
     data = np.column_stack((self.tb37v, self.tb37v, self.tb37v))
     swath_def = geometry.SwathDefinition(lons=self.lons, lats=self.lats)
     if sys.version_info < (2, 6):
         res = kd_tree.resample_gauss(swath_def, data, swath_def, 
                                      radius_of_influence=70000, sigmas=[56500, 56500, 56500])
     else:
         with warnings.catch_warnings(record=True) as w:
             res = kd_tree.resample_gauss(swath_def, data, swath_def, 
                                          radius_of_influence=70000, sigmas=[56500, 56500, 56500])
             self.assertFalse(len(w) != 1, 'Failed to create neighbour radius warning')
             self.assertFalse(('Possible more' not in str(w[0].message)), 'Failed to create correct neighbour radius warning')
             
     self.assertAlmostEqual(res[:, 0].sum() / 100., 668848.082208, 1, 
                                msg='Failed self mapping swath multi for channel 1')
     self.assertAlmostEqual(res[:, 1].sum() / 100., 668848.082208, 1, 
                                msg='Failed self mapping swath multi for channel 2')
     self.assertAlmostEqual(res[:, 2].sum() / 100., 668848.082208, 1, 
                                msg='Failed self mapping swath multi for channel 3')            
开发者ID:valgur,项目名称:pyresample,代码行数:19,代码来源:test_swath.py


注:本文中的pyresample.kd_tree.resample_gauss函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。