本文整理汇总了Python中astropy.coordinates.builtin_frames.ICRS.representation_type方法的典型用法代码示例。如果您正苦于以下问题:Python ICRS.representation_type方法的具体用法?Python ICRS.representation_type怎么用?Python ICRS.representation_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类astropy.coordinates.builtin_frames.ICRS
的用法示例。
在下文中一共展示了ICRS.representation_type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getitem_representation
# 需要导入模块: from astropy.coordinates.builtin_frames import ICRS [as 别名]
# 或者: from astropy.coordinates.builtin_frames.ICRS import representation_type [as 别名]
def test_getitem_representation():
"""
Make sure current representation survives __getitem__ even if different
from data representation.
"""
from astropy.coordinates.builtin_frames import ICRS
c = ICRS([1, 1] * u.deg, [2, 2] * u.deg)
c.representation_type = 'cartesian'
assert c[0].representation_type is r.CartesianRepresentation
示例2: test_representation
# 需要导入模块: from astropy.coordinates.builtin_frames import ICRS [as 别名]
# 或者: from astropy.coordinates.builtin_frames.ICRS import representation_type [as 别名]
def test_representation():
"""
Test the getter and setter properties for `representation`
"""
from astropy.coordinates.builtin_frames import ICRS
# Create the frame object.
icrs = ICRS(ra=1*u.deg, dec=1*u.deg)
data = icrs.data
# Create some representation objects.
icrs_cart = icrs.cartesian
icrs_spher = icrs.spherical
# Testing when `_representation` set to `CartesianRepresentation`.
icrs.representation_type = r.CartesianRepresentation
assert icrs.representation_type == r.CartesianRepresentation
assert icrs_cart.x == icrs.x
assert icrs_cart.y == icrs.y
assert icrs_cart.z == icrs.z
assert icrs.data == data
# Testing that an ICRS object in CartesianRepresentation must not have spherical attributes.
for attr in ('ra', 'dec', 'distance'):
with pytest.raises(AttributeError) as err:
getattr(icrs, attr)
assert 'object has no attribute' in str(err)
# Testing when `_representation` set to `CylindricalRepresentation`.
icrs.representation_type = r.CylindricalRepresentation
assert icrs.representation_type == r.CylindricalRepresentation
assert icrs.data == data
# Testing setter input using text argument for spherical.
icrs.representation_type = 'spherical'
assert icrs.representation_type is r.SphericalRepresentation
assert icrs_spher.lat == icrs.dec
assert icrs_spher.lon == icrs.ra
assert icrs_spher.distance == icrs.distance
assert icrs.data == data
# Testing that an ICRS object in SphericalRepresentation must not have cartesian attributes.
for attr in ('x', 'y', 'z'):
with pytest.raises(AttributeError) as err:
getattr(icrs, attr)
assert 'object has no attribute' in str(err)
# Testing setter input using text argument for cylindrical.
icrs.representation_type = 'cylindrical'
assert icrs.representation_type is r.CylindricalRepresentation
assert icrs.data == data
with pytest.raises(ValueError) as err:
icrs.representation_type = 'WRONG'
assert 'but must be a BaseRepresentation class' in str(err)
with pytest.raises(ValueError) as err:
icrs.representation_type = ICRS
assert 'but must be a BaseRepresentation class' in str(err)