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


Python AuxCoord.collapsed方法代码示例

本文整理汇总了Python中iris.coords.AuxCoord.collapsed方法的典型用法代码示例。如果您正苦于以下问题:Python AuxCoord.collapsed方法的具体用法?Python AuxCoord.collapsed怎么用?Python AuxCoord.collapsed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iris.coords.AuxCoord的用法示例。


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

示例1: test_numeric_nd

# 需要导入模块: from iris.coords import AuxCoord [as 别名]
# 或者: from iris.coords.AuxCoord import collapsed [as 别名]
 def test_numeric_nd(self):
     # Contiguous only defined for 2d bounds.
     coord = AuxCoord(points=np.array([3, 6, 9]),
                      bounds=np.array([[1, 2, 4, 5],
                                       [4, 5, 7, 8],
                                       [7, 8, 10, 11]]))
     with self.assertRaises(ValueError):
         coord.collapsed()
开发者ID:carlocafaro89,项目名称:iris,代码行数:10,代码来源:test_Coord.py

示例2: test_serialize

# 需要导入模块: from iris.coords import AuxCoord [as 别名]
# 或者: from iris.coords.AuxCoord import collapsed [as 别名]
    def test_serialize(self):
        # Collapse a string AuxCoord, causing it to be serialised.
        string = Pair(np.array(['two', 'four', 'six', 'eight']),
                      np.array([['one', 'three'],
                                ['three', 'five'],
                                ['five', 'seven'],
                                ['seven', 'nine']]))
        string_nobounds = Pair(np.array(['ecks', 'why', 'zed']),
                               None)
        string_multi = Pair(np.array(['three', 'six', 'nine']),
                            np.array([['one', 'two', 'four', 'five'],
                                      ['four', 'five', 'seven', 'eight'],
                                      ['seven', 'eight', 'ten', 'eleven']]))

        def _serialize(data):
            return '|'.join(str(item) for item in data.flatten())

        for units in ['unknown', 'no_unit']:
            for points, bounds in [string, string_nobounds, string_multi]:
                coord = AuxCoord(points=points, bounds=bounds, units=units)
                collapsed_coord = coord.collapsed()
                self.assertArrayEqual(collapsed_coord.points,
                                      _serialize(points))
                if bounds is not None:
                    for index in np.ndindex(bounds.shape[1:]):
                        index_slice = (slice(None),) + tuple(index)
                        self.assertArrayEqual(
                            collapsed_coord.bounds[index_slice],
                            _serialize(bounds[index_slice]))
开发者ID:carlocafaro89,项目名称:iris,代码行数:31,代码来源:test_Coord.py

示例3: test_serialize

# 需要导入模块: from iris.coords import AuxCoord [as 别名]
# 或者: from iris.coords.AuxCoord import collapsed [as 别名]
 def test_serialize(self):
     for units in ['unknown', 'no_unit']:
         for points, bounds in self.pairs:
             coord = mock.MagicMock(spec_set=AuxCoord, name='AuxCoord',
                                    points=points, bounds=bounds,
                                    units=units)
             # Now perform the collase operation with the mock coordinate.
             AuxCoord.collapsed(coord)
             # Examine the operational footprint in the mock.
             self.assertEqual(coord.copy.call_count, 1)
             args, kwargs = coord.copy.call_args
             self.assertEqual(args, ())
             self.assertEqual(set(kwargs), set(['points', 'bounds']))
             self.assertArrayEqual(kwargs['points'],
                                   self._serialize(points))
             for index in np.ndindex(coord.bounds.shape[1:]):
                 index_slice = (slice(None),) + tuple(index)
                 self.assertArrayEqual(kwargs['bounds'][index_slice],
                                       self._serialize(bounds[index_slice]))
开发者ID:TheClimateCorporation,项目名称:iris,代码行数:21,代码来源:test_Coord.py

示例4: test_lazy_nd_points_and_bounds

# 需要导入模块: from iris.coords import AuxCoord [as 别名]
# 或者: from iris.coords.AuxCoord import collapsed [as 别名]
    def test_lazy_nd_points_and_bounds(self):
        import dask.array as da

        self.setupTestArrays((3, 4))
        coord = AuxCoord(self.pts_lazy, bounds=self.bds_lazy)

        collapsed_coord = coord.collapsed()

        self.assertTrue(collapsed_coord.has_lazy_points())
        self.assertTrue(collapsed_coord.has_lazy_bounds())

        self.assertArrayEqual(collapsed_coord.points, da.array([55]))
        self.assertArrayEqual(collapsed_coord.bounds, da.array([[-2, 112]]))
开发者ID:SciTools,项目名称:iris,代码行数:15,代码来源:test_Coord.py

示例5: test_numeric_nd

# 需要导入模块: from iris.coords import AuxCoord [as 别名]
# 或者: from iris.coords.AuxCoord import collapsed [as 别名]
    def test_numeric_nd(self):
        coord = AuxCoord(points=np.array([[1, 2, 4, 5],
                                          [4, 5, 7, 8],
                                          [7, 8, 10, 11]]))

        collapsed_coord = coord.collapsed()
        self.assertArrayEqual(collapsed_coord.points, np.array([6]))
        self.assertArrayEqual(collapsed_coord.bounds, np.array([[1, 11]]))

        # Test partially collapsing one dimension...
        collapsed_coord = coord.collapsed(1)
        self.assertArrayEqual(collapsed_coord.points, np.array([3.,  6.,  9.]))
        self.assertArrayEqual(collapsed_coord.bounds, np.array([[1,  5],
                                                                [4,  8],
                                                                [7, 11]]))

        # ... and the other
        collapsed_coord = coord.collapsed(0)
        self.assertArrayEqual(collapsed_coord.points, np.array([4,  5,  7, 8]))
        self.assertArrayEqual(collapsed_coord.bounds, np.array([[1,  7],
                                                                [2,  8],
                                                                [4, 10],
                                                                [5, 11]]))
开发者ID:SciTools,项目名称:iris,代码行数:25,代码来源:test_Coord.py

示例6: test_lazy_nd_bounds

# 需要导入模块: from iris.coords import AuxCoord [as 别名]
# 或者: from iris.coords.AuxCoord import collapsed [as 别名]
    def test_lazy_nd_bounds(self):
        import dask.array as da

        self.setupTestArrays((3, 4))
        coord = AuxCoord(self.pts_real, bounds=self.bds_lazy)

        collapsed_coord = coord.collapsed()

        # Note that the new points get recalculated from the lazy bounds
        #  and so end up as lazy
        self.assertTrue(collapsed_coord.has_lazy_points())
        self.assertTrue(collapsed_coord.has_lazy_bounds())

        self.assertArrayEqual(collapsed_coord.points, np.array([55]))
        self.assertArrayEqual(collapsed_coord.bounds, da.array([[-2, 112]]))
开发者ID:SciTools,项目名称:iris,代码行数:17,代码来源:test_Coord.py


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