Astropy: 具有速度和“单位”表示的框架无法转换为笛卡尔坐标系

创建于 2017-12-23  ·  3评论  ·  资料来源: astropy/astropy

#6944 中的一些极端情况测试揭示了具有实际表示为UnitSpherical速度的帧的一些有问题的行为。 事实证明这是真的。 下面的案例说明了这个问题:

还要注意,如果#6944 被合并,它有几个地方可以解决这个错误。 如果此错误已修复,则应删除这些变通方法(在coordinates子包中搜索#7028以找到它们)。

这有效:

>>> f = ICRS(1*u.deg, 2*u.deg)
>>> f.cartesian
<CartesianRepresentation (x, y, z) [dimensionless]
    ( 0.99923861,  0.01744177,  0.0348995)>

但这两种情况没有:

>>> f = ICRS(1*u.deg, 2*u.deg,
          pm_dec=1*u.mas/u.yr, pm_ra_cosdec=2*u.mas/u.yr, radial_velocity=10*u.km/u.s)
>>> f.represent_as('cartesian', in_frame_units=True)
UnitConversionError: 'mas / (rad yr)' (frequency) and 'km / s' (speed) are not convertible
>>> f = ICRS(1*u.deg, 2*u.deg, 
                pm_dec=1*u.mas/u.yr, pm_ra_cosdec=2*u.mas/u.yr)
>>> g = f.transform_to(GCRS)
>>> g.cartesian
UnitConversionError: '1 / s' (frequency) and 'km / s' (speed) are not convertible

这可能是一个有用的线索,在第二个失败的情况下, f.cartesian确实有效,但是在向 GCRS 的转换中的某些东西使它开始失败。 这些问题可能略有不同,但它们非常接近,可能必须一起解决。

@adrn@mhvk ,知道这里发生了什么吗? 有人可能会争辩说,至少上面的转换步骤有点不明确,但是即使单位有点奇怪,人们仍然应该能够得到笛卡尔表示......

Bug coordinates

所有3条评论

@eteq

我试图解决这个问题。 但在示例案例中,


>>> f = ICRS(1*u.deg, 2*u.deg,
          pm_dec=1*u.mas/u.yr, pm_ra_cosdec=2*u.mas/u.yr, radial_velocity=10*u.km/u.s)
>>> f.represent_as('cartesian', in_frame_units=True)

该示例中没有distance ,而是有radial_velocity 。 我不明白这到底是什么意思。 另外,如果我在框架中放置一些距离,它就完美无缺!

你能不能让我理解这个问题,我很困惑。

@shreyasbapat你能试试看https://github.com/astropy/astropy/pull/9064 是否解决了这个问题? (编辑:它没有)

9086让我想起了这个问题。 对于两种情况:

没有距离,但有房车

>>> f = ICRS(1*u.deg, 2*u.deg,
          pm_dec=1*u.mas/u.yr, pm_ra_cosdec=2*u.mas/u.yr, radial_velocity=10*u.km/u.s)
>>> f.represent_as('cartesian', in_frame_units=True)
UnitConversionError: 'mas / (rad yr)' (frequency) and 'km / s' (speed) are not convertible

我觉得这个是无解的:没有距离,就不能把自行转换成空间速度,也不能把空间速度转换成角速度。 因此,我认为对于这种情况,我们只需要确保错误消息更清晰(由 RV 但没有距离触发)。

坐标变换引入的RV

>>> f = ICRS(1*u.deg, 2*u.deg, 
                pm_dec=1*u.mas/u.yr, pm_ra_cosdec=2*u.mas/u.yr)
>>> g = f.transform_to(GCRS)
>>> repr(g)
# error
>>> g.data
<CartesianRepresentation (x, y, z) [dimensionless]
    (0.99923901, 0.01742676, 0.03489572)
 (has differentials w.r.t.: 's')>
g.data.differentials
<CartesianDifferential (d_x, d_y, d_z) in 1 / s
    (6.07736084e-13, -1.85772092e-11, -8.12625661e-12)>

这是相当微妙的。 没有适当的运动, gUnitSpherical ,这是有道理的,这里也应该如此,所以转换有问题。 为了完整起见,在单位球体上表示它确实有效:

g.represent_as('unitspherical')                                                               
Out[24]: 
<UnitSphericalRepresentation (lon, lat) in rad
    (0.01743826, 0.0349028)
 (has differentials w.r.t.: 's')>

In [25]: g.represent_as('unitspherical').differentials['s']                                            
Out[25]: 
<UnitSphericalDifferential (d_lon, d_lat) in rad / s
    (-1.85963079e-11, -8.13120751e-12)>

但即便如此, g.cartesian应该工作 - 在这里,问题是框架为用户决定什么单位是合理的,坚持笛卡尔速度在km/s (当然,这可以追溯到我长期以来一直抱怨表示中的坐标单位是为我决定的......): https :

单位本身来自:

g.representation_info
{astropy.coordinates.representation.CartesianRepresentation: {'names': ['x',
   'y',
   'z'],
  'units': [None, None, None]},
 astropy.coordinates.representation.UnitSphericalRepresentation: {'names': ('ra',
   'dec'),
  'units': (Unit("deg"), Unit("deg"))},
 astropy.coordinates.representation.RadialRepresentation: {'names': ['distance'],
  'units': [None]},
 astropy.coordinates.representation.SphericalRepresentation: {'names': ('ra',
   'dec',
   'distance'),
  'units': (Unit("deg"), Unit("deg"), None)},
 astropy.coordinates.representation.PhysicsSphericalRepresentation: {'names': ['phi',
   'theta',
   'r'],
  'units': [Unit("deg"), Unit("deg"), None]},
 astropy.coordinates.representation.CylindricalRepresentation: {'names': ['rho',
   'phi',
   'z'],
  'units': [None, Unit("deg"), None]},
 astropy.coordinates.representation.CartesianDifferential: {'names': ('v_x',
   'v_y',
   'v_z'),
  'units': (Unit("km / s"), Unit("km / s"), Unit("km / s"))},
 astropy.coordinates.representation.UnitSphericalDifferential: {'names': ('pm_ra',
   'pm_dec'),
  'units': (Unit("mas / yr"), Unit("mas / yr"))},
 astropy.coordinates.representation.SphericalDifferential: {'names': ('pm_ra',
   'pm_dec',
   'radial_velocity'),
  'units': (Unit("mas / yr"), Unit("mas / yr"), Unit("km / s"))},
 astropy.coordinates.representation.UnitSphericalCosLatDifferential: {'names': ('pm_ra_cosdec',
   'pm_dec'),
  'units': (Unit("mas / yr"), Unit("mas / yr"))},
 astropy.coordinates.representation.SphericalCosLatDifferential: {'names': ('pm_ra_cosdec',
   'pm_dec',
   'radial_velocity'),
  'units': (Unit("mas / yr"), Unit("mas / yr"), Unit("km / s"))},
 astropy.coordinates.representation.RadialDifferential: {'names': ['d_distance'],
  'units': [None]},
 astropy.coordinates.representation.PhysicsSphericalDifferential: {'names': ['d_phi',
   'd_theta',
   'd_r'],
  'units': [None, None, None]},
 astropy.coordinates.representation.CylindricalDifferential: {'names': ['d_rho',
   'd_phi',
   'd_z'],
  'units': [None, None, None]}}

有人在这里看到CartesianDifferential是唯一错误的,这是因为它完全设置了首选单位。

这可能意味着 #9086 中的修复可以通过一个小的修改:一个人应该尝试去请求的单位,但不关心是否失败。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

Warren-Porter picture Warren-Porter  ·  38评论

jehturner picture jehturner  ·  36评论

astrofrog picture astrofrog  ·  36评论

eteq picture eteq  ·  50评论

dhomeier picture dhomeier  ·  36评论