コード例 #1
0
    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')
コード例 #2
0
ファイル: test_kd_tree.py プロジェクト: cpaulik/pyresample
    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')
コード例 #3
0
ファイル: test_kd_tree.py プロジェクト: goodsonr/pyresample
    def test_gauss_uncert(self):
        sigma = utils.fwhm2sigma(41627.730557884883)
        with catch_warnings() as w:
            res, stddev, count = kd_tree.resample_gauss(self.tswath,
                                                        self.tdata,
                                                        self.tgrid,
                                                        100000,
                                                        sigma,
                                                        with_uncert=True)
            self.assertTrue(len(w) > 0, 'Failed to create neighbour warning')
            self.assertTrue((any('Searching' in str(_w.message) for _w in w)),
                            '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')
コード例 #4
0
 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')
コード例 #5
0
ファイル: test_kd_tree.py プロジェクト: cpaulik/pyresample
 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) 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, 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.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')
コード例 #6
0
ファイル: test_kd_tree.py プロジェクト: sebastic/pyresample
    def test_gauss_uncert(self):
        sigma = utils.fwhm2sigma(41627.730557884883)
        with catch_warnings() as w:
            res, stddev, count = kd_tree.resample_gauss(self.tswath, self.tdata,
                                                        self.tgrid, 100000, sigma,
                                                        with_uncert=True)
            self.assertTrue(len(w) > 0)
            self.assertTrue((any('Searching' in str(_w.message) for _w in w)))

        expected_res = 2.20206560694
        expected_stddev = 0.707115076173
        expected_count = 3
        self.assertAlmostEqual(res[0], expected_res, 5)
        self.assertAlmostEqual(stddev[0], expected_stddev, 5)
        self.assertEqual(count[0], expected_count)
コード例 #7
0
ファイル: test_kd_tree.py プロジェクト: sebastic/pyresample
 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)
     with catch_warnings() as w:
         res = kd_tree.resample_gauss(swath_def, data.ravel(),
                                      self.area_def, 50000, utils.fwhm2sigma(41627.730557884883), segments=1)
         self.assertFalse(len(w) != 1)
         self.assertFalse(('Possible more' not in str(w[0].message)))
     cross_sum = res.sum()
     expected = 4872.8100353517921
     self.assertAlmostEqual(cross_sum, expected)
コード例 #8
0
ファイル: test_kd_tree.py プロジェクト: pytroll/pyresample
    def test_gauss_uncert(self):
        sigma = utils.fwhm2sigma(41627.730557884883)
        with catch_warnings(UserWarning) as w:
            res, stddev, count = kd_tree.resample_gauss(self.tswath, self.tdata,
                                                        self.tgrid, 100000, sigma,
                                                        with_uncert=True)
            self.assertTrue(len(w) > 0)
            self.assertTrue((any('Searching' in str(_w.message) for _w in w)))

        expected_res = 2.20206560694
        expected_stddev = 0.707115076173
        expected_count = 3
        self.assertAlmostEqual(res[0], expected_res, 5)
        self.assertAlmostEqual(stddev[0], expected_stddev, 5)
        self.assertEqual(count[0], expected_count)
コード例 #9
0
ファイル: test_kd_tree.py プロジェクト: pytroll/pyresample
 def test_gauss_fwhm(self):
     data = np.fromfunction(lambda y, x: (y + x) * 10 ** -5, (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)
     with catch_warnings(UserWarning) as w:
         res = kd_tree.resample_gauss(swath_def, data.ravel(),
                                      self.area_def, 50000, utils.fwhm2sigma(41627.730557884883), segments=1)
         self.assertFalse(len(w) != 1)
         self.assertFalse(('Possible more' not in str(w[0].message)))
     cross_sum = res.sum()
     expected = 4872.8100353517921
     self.assertAlmostEqual(cross_sum, expected)
コード例 #10
0
    def test_gauss_uncert(self):
        sigma = utils.fwhm2sigma(41627.730557884883)
        with catch_warnings() as w:
            res, stddev, count = kd_tree.resample_gauss(self.tswath, self.tdata,
                                                        self.tgrid, 100000, sigma,
                                                        with_uncert=True)
            self.assertTrue(
                len(w) > 0, 'Failed to create neighbour warning')
            self.assertTrue((any('Searching' in str(_w.message) for _w in w)),
                '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')