BaseCoordinateFrame#

class astropy.coordinates.BaseCoordinateFrame(*args, copy=True, representation_type=None, differential_type=None, **kwargs)[源代码]#

基类:ShapedLikeNDArray

坐标系的基类。

这个类被设计成子类来创建特定系统的实例。子类可以实现以下属性:

除非通过 frame_specific_representation_info ,velocity名称默认为:

在哪里? {{lon}}{{lat}} 是角度组件的帧名称。

参数:
dataBaseRepresentation 子类实例BaseRepresentation子类实例

表示对象或 None 没有数据(或使用坐标分量参数,请参见下文)。

*args, ** 夸克

使用依赖于子类的名称协调组件。

representation_type : BaseRepresentation subclass, str ,可选BasePresation子类,python:str,可选

表示类或表示类的字符串名称。这将设置预期的输入表示类,从而更改传入数据的预期关键字参数。例如,传递 representation_type='cartesian' 将使类期望具有笛卡尔名称的位置数据,即 x, y, z 在大多数情况下,除非通过 frame_specific_representation_info 。要查看此框架的名称,请查看 <this frame>().representation_info

differential_type : BaseDifferential subclass, strdict ,可选BaseDifferential子类,PYTHON:字符串,PYTHON:DICT,可选

差分类别或差分类别词典(当前仅支持带有关键字‘s’的速度差异)。这将设置预期的输入差异类,从而更改传入数据的预期关键字参数。例如,传递 differential_type='cartesian' 将使类期待带有参数名称的速度数据 v_x, v_y, v_z 除非通过以下方式重写 frame_specific_representation_info 。要查看此框架的名称,请查看 <this frame>().representation_info

copy : bool ,可选可选的布尔

如果 True (默认),复制输入坐标阵列。只能作为关键字参数传入。

属性摘要

cache 

该帧的高速缓存,一个字典。

cartesian 

此对象中坐标的笛卡尔表示的简写。

cylindrical 

此对象中坐标的圆柱表示的缩写。

data 

此对象的坐标数据。

default_differential 

default_representation 

differential_type 

用于此帧数据的差分。

frame_attributes 

frame_specific_representation_info 

has_data 

如果此帧具有 data ,否则为False。

isscalar 

proper_motion 

二维固有运动的简写 Quantity 具有角速度单位的对象。

radial_velocity 

径向或视线速度的简写 Quantity 对象。

representation_component_names 

representation_component_units 

representation_info 

包含此帧的属性名应用于特定表示的信息的字典。

representation_type 

用于此帧数据的表示类。

shape 

基础数据的形状。

size 

根据形状计算的对象大小。

spherical 

此对象中坐标的球面表示的简写。

sphericalcoslat 

位置数据的球面表示的速记形式 SphericalCosLatDifferential 此对象中的速度数据。

velocity 

将笛卡尔空间运动作为 CartesianDifferential 对象。

方法总结

get_frame_attr_defaults \()

返回一个带有每个帧属性的默认值的DICT。

get_frame_attr_names \()

自 5.2 版本弃用.

get_representation_cls([which])

用于此帧的部分数据的类。

get_representation_component_names([which])

get_representation_component_units([which])

is_equivalent_frame (其他)

检查此对象是否与 other 对象。

is_frame_attr_default \(属性)

确定帧属性是否具有其值,因为它是默认值,还是因为此帧是用显式请求的值创建的。

is_transformable_to(new_frame)

确定是否可以将此坐标系转换为另一个给定坐标系。

realize_frame(data, **kwargs)

使用来自另一个帧的新数据生成新帧(可能有数据,也可能没有数据)。

replicate([copy])

返回帧的副本,可选地使用新的帧属性。

replicate_without_data([copy])

返回一个没有数据的副本,可以选择使用新的帧属性。

represent_as(base[, s, in_frame_units])

生成并返回此帧的新表示 data 作为表示对象。

separation (其他)

计算此坐标和另一个坐标之间的天空间隔。

separation_3d (其他)

这个坐标和另一个坐标之间的距离。

set_representation_cls([base, s])

设置此帧数据的表示和/或差分类。

transform_to(new_frame)

将此对象的坐标数据转换为新帧。

属性文档

cache#

该帧的高速缓存,一个字典。

它存储应根据坐标数据计算的所有内容( not 来自帧属性)。可以在函数中使用它来存储任何计算成本较高但可能会被其他函数重复使用的内容。例如::

if 'user_data' in myframe.cache:
    data = myframe.cache['user_data']
else:
    myframe.cache['user_data'] = data = expensive_func(myframe.lat)

如果对帧数据进行了就地修改,则应清除缓存:

myframe.cache.clear()
cartesian#

此对象中坐标的笛卡尔表示的简写。

cylindrical#

此对象中坐标的圆柱表示的缩写。

data#

此对象的坐标数据。如果此帧没有数据,则 ValueError 将被提高。使用 has_data 检查此帧对象上是否存在数据。

default_differential = None#
default_representation = None#
differential_type#

用于此帧数据的差分。

这将是来自 BaseDifferential 。有关同时设置表示法和差异的信息,请参阅 set_representation_cls 方法。

frame_attributes = {}#
frame_specific_representation_info = {<class 'astropy.coordinates.representation.cartesian.CartesianDifferential'>: [('d_x', 'v_x', Unit("km / s")), ('d_y', 'v_y', Unit("km / s")), ('d_z', 'v_z', Unit("km / s"))], <class 'astropy.coordinates.representation.spherical.SphericalCosLatDifferential'>: [('d_lon_coslat', 'pm_lon_coslat', Unit("mas / yr")), ('d_lat', 'pm_lat', Unit("mas / yr")), ('d_distance', 'radial_velocity', Unit("km / s"))], <class 'astropy.coordinates.representation.spherical.SphericalDifferential'>: [('d_lon', 'pm_lon', Unit("mas / yr")), ('d_lat', 'pm_lat', Unit("mas / yr")), ('d_distance', 'radial_velocity', Unit("km / s"))], <class 'astropy.coordinates.representation.spherical.SphericalRepresentation'>: [('lon', 'lon', 'recommended'), ('lat', 'lat', 'recommended')], <class 'astropy.coordinates.representation.spherical.UnitSphericalCosLatDifferential'>: [('d_lon_coslat', 'pm_lon_coslat', Unit("mas / yr")), ('d_lat', 'pm_lat', Unit("mas / yr")), ('d_distance', 'radial_velocity', Unit("km / s"))], <class 'astropy.coordinates.representation.spherical.UnitSphericalDifferential'>: [('d_lon', 'pm_lon', Unit("mas / yr")), ('d_lat', 'pm_lat', Unit("mas / yr")), ('d_distance', 'radial_velocity', Unit("km / s"))], <class 'astropy.coordinates.representation.spherical.UnitSphericalRepresentation'>: [('lon', 'lon', 'recommended'), ('lat', 'lat', 'recommended')]}#
has_data#

如果此帧具有 data ,否则为False。

isscalar#
proper_motion#

二维固有运动的简写 Quantity 具有角速度单位的对象。在返回的 Quantityaxis=0 是经度/纬度维度,因此 .proper_motion[0] 是纵向的固有运动 .proper_motion[1] 是纬向的。纵向固有运动已经包括cos(纬度)项。

radial_velocity#

径向或视线速度的简写 Quantity 对象。

representation_component_names#
representation_component_units#
representation_info#

包含此帧的属性名应用于特定表示的信息的字典。

representation_type#

用于此帧数据的表示类。

这将是来自 BaseRepresentation 。也可以 set 使用表示形式的字符串名称。如果希望设置显式差异类(而不是被推断),请使用 set_representation_cls 方法。

shape#
size#
spherical#

此对象中坐标的球面表示的简写。

sphericalcoslat#

位置数据的球面表示的速记形式 SphericalCosLatDifferential 此对象中的速度数据。

velocity#

将笛卡尔空间运动作为 CartesianDifferential 对象。

这相当于调用 self.cartesian.differentials['s']

方法文件

classmethod get_frame_attr_defaults()[源代码]#

返回一个带有每个帧属性的默认值的DICT。

classmethod get_frame_attr_names()[源代码]#

自 5.2 版本弃用: Get_Frame_Attr_Names()方法已弃用,可能会在将来的版本中删除。使用GET_FRAME_ATTR_DEFAULTS()获取帧属性名称和默认值的字典。获取名称的最快方法是Frame_Attributes.key()

返回一个带有每个帧属性的默认值的DICT。

get_representation_cls(which='base')[源代码]#

用于此帧的部分数据的类。

参数:
哪一个 :('base','s', None('base'、's',

返回哪个部分的类。”“基”是指用于表示坐标的类;“s”是时间的一阶导数,即表示固有运动和/或径向速度的类。如果 None ,同时返回dict。

返回:
代表BaseRepresentationBaseDifferential .基表示或基差分。
get_representation_component_names(which='base')[源代码]#
get_representation_component_units(which='base')[源代码]#
is_equivalent_frame(other)[源代码]#

检查此对象是否与 other 对象。

要成为同一帧,两个对象必须是相同的帧类,并且具有相同的帧属性。请注意,确实如此 not 不管对象有什么数据(如果有的话)。

参数:
其他 : BaseCoordinateFrameBaseCoordinateFrame

另一个要检查的帧

返回:
isequiv : bool布尔

如果帧相同,则为True;否则为False。

加薪:
TypeError

如果 other 不是一个 BaseCoordinateFrame 或者说子类。

is_frame_attr_default(attrnm)[源代码]#

确定帧属性是否具有其值,因为它是默认值,还是因为此帧是用显式请求的值创建的。

参数:
attrnm : strPython :字符串

要检查的属性的名称。

返回:
isdefault : bool布尔

如果属性 attrnm 默认值为,如果在创建此帧时指定了该值,则为False。

is_transformable_to(new_frame)[源代码]#

确定是否可以将此坐标系转换为另一个给定坐标系。

参数:
new_frameBaseCoordinateFrame 子类或实例BaselaborateFrame子类或实例

要转换为的建议框架。

返回:
transformable : boolstrBool或Python:Str

True 如果可以将其转换为 new_frameFalse 如果不是,或者字符串'same'if new_frame 是与此对象相同的系统,但未定义转换。

笔记

返回值'same'意味着转换可以工作,但它只会返回此对象的一个副本。预期用途是:

if coord.is_transformable_to(some_unknown_frame):
    coord2 = coord.transform_to(some_unknown_frame)

即使 some_unknown_frame 原来是同一帧类 coord . 这适用于无论帧属性如何(例如ICRS),帧都是相同的,但请注意 可以 还表明有人忘记定义同一帧类但属性不同的两个对象之间的转换。

realize_frame(data, **kwargs)[源代码]#

使用来自另一个帧的新数据生成新帧(可能有数据,也可能没有数据)。粗略地说,与 replicate_without_data .

参数:
dataBaseRepresentationBaseRepresentation

用作新帧的数据的表示。

**kwargs

任何其他关键字都被视为要在新的Frame对象上设置的Frame属性。特别是, representation_type 可以指定。

返回:
frameobjBaseCoordinateFrame 子类实例BaseCoordinateFrame子类实例

中的新对象 this 框架,具有与此框架相同的框架属性,但具有 data 作为坐标数据。

replicate(copy=False, **kwargs)[源代码]#

返回帧的副本,可选地使用新的帧属性。

副本是一个新的frame对象,它具有与此frame对象相同的数据,并且如果将frame属性作为额外的关键字参数提供给此方法,则会覆盖它们。如果 copy 设置为 True 然后将生成内部数组的副本。否则,复制副本将尽可能使用对原始阵列的引用来节省内存。内部数组通常不可由用户更改,因此在大多数情况下不必设置 copyTrue .

参数:
copy : bool ,可选可选的布尔

如果为True,则生成的对象是数据的副本。如果为False,则尽可能使用引用。此规则也适用于帧属性。

**kwargs

任何其他关键字都被视为要在新的Frame对象上设置的Frame属性。

返回:
frameobjBaseCoordinateFrame 子类实例BaseCoordinateFrame子类实例

此对象的副本,但可能具有新的帧属性。

replicate_without_data(copy=False, **kwargs)[源代码]#

返回一个没有数据的副本,可以选择使用新的帧属性。

副本是一个新的frame对象,没有数据,但具有与此对象相同的frame属性,除非被此方法的额外关键字参数覆盖。这个 copy 关键字确定帧属性是否被真正复制而不是被引用(这为帧属性较大的情况节省内存)。

这种方法本质上是相反的 realize_frame .

参数:
copy : bool ,可选可选的布尔

如果为True,则生成的对象具有帧属性的副本。如果为False,则尽可能使用引用。

**kwargs

任何其他关键字都被视为要在新的Frame对象上设置的Frame属性。

返回:
frameobjBaseCoordinateFrame 子类实例BaseCoordinateFrame子类实例

此对象的副本,但没有数据,可能具有新的帧属性。

represent_as(base, s='base', in_frame_units=False)[源代码]#

生成并返回此帧的新表示 data 作为表示对象。

注意:要对帧或SkyCoord对象的表示进行就地更改,请设置 representation 属性,或使用 set_representation_cls 方法来设置差分。

参数:
base : subclass of BaseRepresentationstr亚类

要生成的表示类型。一定是 (不是实例)或表示类的字符串名称。

s : subclass of BaseDifferential, str ,可选亚类

表示任何速度的类。一定是 (不是实例)或差异类的字符串名称。如果等于'base'(默认值),则从基类推断。如果 None ,所有速度信息都被丢弃。

in_frame_units : bool ,仅关键字布尔值,仅关键字

强制表示单位与特定于此帧的指定单位相匹配

返回:
newrep : BaseRepresentation-derived object基本表示法-派生

此框架的新表示对象 data .

加薪:
AttributeError

如果这个物体没有 data

实例

>>> from astropy import units as u
>>> from astropy.coordinates import SkyCoord, CartesianRepresentation
>>> coord = SkyCoord(0*u.deg, 0*u.deg)
>>> coord.represent_as(CartesianRepresentation)  
<CartesianRepresentation (x, y, z) [dimensionless]
        (1., 0., 0.)>
>>> coord.representation_type = CartesianRepresentation
>>> coord  
<SkyCoord (ICRS): (x, y, z) [dimensionless]
    (1., 0., 0.)>
separation(other)[源代码]#

计算此坐标和另一个坐标之间的天空间隔。

备注

如果 other 坐标对象在不同的帧中,它首先被转换到该对象的帧上。如果不加以解释,这可能导致不直观的行为。特别值得注意的是 self.separation(other)other.separation(self) 在这种情况下可能不会给出相同的答案。

参数:
otherBaseCoordinateFrameSkyCoordBaseCoordinateFrame或SkyCoord

得到分离的坐标。

返回:
sepAngle角度

在天空中这个和 other 协调。

笔记

分离是用Vincenty公式计算的,该公式在所有位置都是稳定的,包括极点和对极 [1].

separation_3d(other)[源代码]#

这个坐标和另一个坐标之间的距离。

参数:
otherBaseCoordinateFrameSkyCoordBaseCoordinateFrame或SkyCoord

要获取距离的坐标系。

返回:
sepDistance距离

这两个坐标之间的实际空间距离。

加薪:
ValueError

如果这个或另一个坐标没有距离。

set_representation_cls(base=None, s='base')[源代码]#

设置此帧数据的表示和/或差分类。

参数:
base : strBaseRepresentation 子类,可选Python:字符串,BasePresation子类,可选

用于表示坐标数据的名称或子类。

sBaseDifferential 子类,可选基差分子类,可选

用来表示任何速度的微分子类,如固有运动和径向速度。如果等于'base',这是默认值,它将从表示中推断出来。如果 None ,则表示将删除任何差分。

transform_to(new_frame)[源代码]#

将此对象的坐标数据转换为新帧。

参数:
new_frame : astropy:coordinate-like占星体:类似于坐标

要将此坐标框架转换为的框架。

返回:
transframe : astropy:coordinate-like占星体:类似于坐标

属性中表示的坐标数据的新对象 newframe 系统。

加薪:
ValueError

如果没有可能的转换路径。