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


Python ICRS.take方法代码示例

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


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

示例1: TestManipulation

# 需要导入模块: from astropy.coordinates.builtin_frames import ICRS [as 别名]
# 或者: from astropy.coordinates.builtin_frames.ICRS import take [as 别名]

#.........这里部分代码省略.........
        assert np.all(s1_swapaxes.location == self.s1.location.swapaxes(0, 1))
        assert s1_swapaxes.location.shape == (7, 6)
        assert np.may_share_memory(s1_swapaxes.location, self.s1.location)
        assert np.all(s1_swapaxes.temperature ==
                      self.s1.temperature.swapaxes(0, 1))
        assert np.may_share_memory(s1_swapaxes.temperature,
                                   self.s1.temperature)
        assert s1_swapaxes.pressure == self.s1.pressure

    def test_reshape(self):
        s0_reshape = self.s0.reshape(2, 3, 7)
        assert s0_reshape.shape == (2, 3, 7)
        assert np.all(s0_reshape.data.lon == self.s0.data.lon.reshape(2, 3, 7))
        assert np.all(s0_reshape.data.lat == self.s0.data.lat.reshape(2, 3, 7))
        assert np.may_share_memory(s0_reshape.data.lon, self.s0.data.lon)
        assert np.may_share_memory(s0_reshape.data.lat, self.s0.data.lat)
        s1_reshape = self.s1.reshape(3, 2, 7)
        assert s1_reshape.shape == (3, 2, 7)
        assert np.all(s1_reshape.data.lat == self.s1.data.lat.reshape(3, 2, 7))
        assert np.may_share_memory(s1_reshape.data.lat, self.s1.data.lat)
        assert np.all(s1_reshape.obstime == self.s1.obstime.reshape(3, 2, 7))
        assert np.may_share_memory(s1_reshape.obstime.jd1,
                                   self.s1.obstime.jd1)
        assert np.all(s1_reshape.location == self.s1.location.reshape(3, 2, 7))
        assert np.may_share_memory(s1_reshape.location, self.s1.location)
        assert np.all(s1_reshape.temperature ==
                      self.s1.temperature.reshape(3, 2, 7))
        assert np.may_share_memory(s1_reshape.temperature,
                                   self.s1.temperature)
        assert s1_reshape.pressure == self.s1.pressure
        # For reshape(3, 14), copying is necessary for lon, lat, location, time
        s1_reshape2 = self.s1.reshape(3, 14)
        assert s1_reshape2.shape == (3, 14)
        assert np.all(s1_reshape2.data.lon == self.s1.data.lon.reshape(3, 14))
        assert not np.may_share_memory(s1_reshape2.data.lon, self.s1.data.lon)
        assert np.all(s1_reshape2.obstime == self.s1.obstime.reshape(3, 14))
        assert not np.may_share_memory(s1_reshape2.obstime.jd1,
                                       self.s1.obstime.jd1)
        assert np.all(s1_reshape2.location == self.s1.location.reshape(3, 14))
        assert not np.may_share_memory(s1_reshape2.location, self.s1.location)
        assert np.all(s1_reshape2.temperature ==
                      self.s1.temperature.reshape(3, 14))
        assert np.may_share_memory(s1_reshape2.temperature,
                                   self.s1.temperature)
        assert s1_reshape2.pressure == self.s1.pressure
        s2_reshape = self.s2.reshape(3, 2, 7)
        assert s2_reshape.shape == (3, 2, 7)
        assert np.all(s2_reshape.data.lon == self.s2.data.lon.reshape(3, 2, 7))
        assert np.may_share_memory(s2_reshape.data.lat, self.s2.data.lat)
        assert np.all(s2_reshape.obstime == self.s2.obstime.reshape(3, 2, 7))
        assert np.may_share_memory(s2_reshape.obstime.jd1, self.s2.obstime.jd1)
        assert np.all(s2_reshape.obsgeoloc.xyz ==
                      self.s2.obsgeoloc.reshape(3, 2, 7).xyz)
        assert np.may_share_memory(s2_reshape.obsgeoloc.x, self.s2.obsgeoloc.x)
        s3_reshape = self.s3.reshape(3, 2, 7)
        assert s3_reshape.shape == (3, 2, 7)
        assert np.all(s3_reshape.obstime == self.s3.obstime.reshape(3, 2, 7))
        assert np.may_share_memory(s3_reshape.obstime.jd1, self.s3.obstime.jd1)
        assert np.all(s3_reshape.obsgeoloc.xyz ==
                      self.s3.obsgeoloc.reshape(3, 2, 7).xyz)
        assert np.may_share_memory(s3_reshape.obsgeoloc.x, self.s3.obsgeoloc.x)
        sc_reshape = self.sc.reshape(3, 2, 7)
        assert sc_reshape.shape == (3, 2, 7)
        assert np.all(sc_reshape.data.lon == self.sc.data.lon.reshape(3, 2, 7))
        assert np.may_share_memory(sc_reshape.data.lat, self.sc.data.lat)
        assert np.all(sc_reshape.obstime == self.sc.obstime.reshape(3, 2, 7))
        assert np.may_share_memory(sc_reshape.obstime.jd1, self.sc.obstime.jd1)
        assert np.all(sc_reshape.obsgeoloc.xyz ==
                      self.sc.obsgeoloc.reshape(3, 2, 7).xyz)
        assert np.may_share_memory(sc_reshape.obsgeoloc.x, self.sc.obsgeoloc.x)
        # For reshape(3, 14), the arrays all need to be copied.
        sc_reshape2 = self.sc.reshape(3, 14)
        assert sc_reshape2.shape == (3, 14)
        assert np.all(sc_reshape2.data.lon == self.sc.data.lon.reshape(3, 14))
        assert not np.may_share_memory(sc_reshape2.data.lat,
                                       self.sc.data.lat)
        assert np.all(sc_reshape2.obstime == self.sc.obstime.reshape(3, 14))
        assert not np.may_share_memory(sc_reshape2.obstime.jd1,
                                       self.sc.obstime.jd1)
        assert np.all(sc_reshape2.obsgeoloc.xyz ==
                      self.sc.obsgeoloc.reshape(3, 14).xyz)
        assert not np.may_share_memory(sc_reshape2.obsgeoloc.x,
                                       self.sc.obsgeoloc.x)

    def test_squeeze(self):
        s0_squeeze = self.s0.reshape(3, 1, 2, 1, 7).squeeze()
        assert s0_squeeze.shape == (3, 2, 7)
        assert np.all(s0_squeeze.data.lat == self.s0.data.lat.reshape(3, 2, 7))
        assert np.may_share_memory(s0_squeeze.data.lat, self.s0.data.lat)

    def test_add_dimension(self):
        s0_adddim = self.s0[:, np.newaxis, :]
        assert s0_adddim.shape == (6, 1, 7)
        assert np.all(s0_adddim.data.lon == self.s0.data.lon[:, np.newaxis, :])
        assert np.may_share_memory(s0_adddim.data.lat, self.s0.data.lat)

    def test_take(self):
        s0_take = self.s0.take((5, 2))
        assert s0_take.shape == (2,)
        assert np.all(s0_take.data.lon == self.s0.data.lon.take((5, 2)))
开发者ID:Cadair,项目名称:astropy,代码行数:104,代码来源:test_shape_manipulation.py


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