如何连接两个令人讨厌的SkyCoord向量?

时间:2019-04-23 15:27:31

标签: python python-3.x astropy

我从两个不同的恒星目录(现实中是Tycho2和Hipparcos)中加载了坐标数据,并且我试图创建一个恒星位置表。一个在J2000.0时代给出位置和适当的运动,另一个在J1991.25时代给出。从astropy documentation,我应该能够将一个转换为另一个,然后将它们连接为一个位置向量。如果运行以下MWE,则会收到一条错误消息,指出两个输入没有相同的帧。

Parameter 'resource_group_name' must conform to the following pattern: '^[-\\w\\._\\(\\)]+$'.
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 326, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 384, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 375, in _run_job
    cmd_copy.exception_handler(ex)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/commands.py", line 54, in _polish_bad_errors
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 354, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 145, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 451, in default_command_handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/custom.py", line 2313, in webapp_up
    _create_new_rg = should_create_new_rg(cmd, default_rg, rg_name, is_linux)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/_create_util.py", line 282, in should_create_new_rg
    elif (_check_resource_group_exists(cmd, rg_name) and
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/appservice/_create_util.py", line 86, in _check_resource_group_exists
    return rcf.resource_groups.check_existence(rg_name)
  File "/opt/az/lib/python3.6/site-packages/azure/mgmt/resource/resources/v2018_05_01/operations/resource_groups_operations.py", line 61, in check_existence
    'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'),
  File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 592, in url
    data = self.validate(data, name, required=True, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/msrest/serialization.py", line 672, in validate
    raise ValidationError(key, name, value)
msrest.exceptions.ValidationError: Parameter 'resource_group_name' must conform to the following pattern: '^[-\\w\\._\\(\\)]+$'.

To open an issue, please run: 'az feedback'

我得到的错误是:

from astropy.coordinates import SkyCoord, concatenate
from astropy.time import Time
import astropy.units as u

tpos = SkyCoord(
    ra=[1, 2, 3, 4] * u.deg,
    dec=[1, 2, 3, 4] * u.deg,
    pm_ra_cosdec=[1e-3, 2e-3, 3e-3, 4e-3] * u.milliarcsecond / u.year,
    pm_dec=[1e-3, 2e-3, 3e-3, 4e-3] * u.milliarcsecond / u.year,
    obstime=Time(2000.0, format='jyear'),
    frame='icrs'
)

spos = SkyCoord(
    ra=[1, 2, 3, 4] * u.deg,
    dec=[1, 2, 3, 4] * u.deg,
    pm_ra_cosdec=[1e-3, 2e-3, 3e-3, 4e-3] * u.milliarcsecond / u.year,
    pm_dec=[1e-3, 2e-3, 3e-3, 4e-3] * u.milliarcsecond / u.year,
    obstime=Time(1991.25, format='jyear'),
    frame='icrs'
).transform_to(tpos)

pos = concatenate([tpos, spos])

如果我尝试--------------------------------------------------------------------------- ValueError Traceback (most recent call last) <ipython-input-6-3eecaa4d104b> in <module> 21 ).transform_to(tpos) 22 ---> 23 pos = concatenate([tpos, spos]) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\astropy\coordinates\funcs.py in concatenate(coords) 373 if not sc.is_equivalent_frame(scs[0]): 374 raise ValueError("All inputs must have equivalent frames: " --> 375 "{0} != {1}".format(sc, scs[0])) 376 377 # TODO: this can be changed to SkyCoord.from_representation() for a speed ValueError: All inputs must have equivalent frames: <SkyCoord (ICRS): (ra, dec) in deg [(1., 1.), (2., 2.), (3., 3.), (4., 4.)] (pm_ra_cosdec, pm_dec) in mas / yr [(0.001, 0.001), (0.002, 0.002), (0.003, 0.003), (0.004, 0.004)]> != <SkyCoord (ICRS): (ra, dec) in deg [(1., 1.), (2., 2.), (3., 3.), (4., 4.)] (pm_ra_cosdec, pm_dec) in mas / yr [(0.001, 0.001), (0.002, 0.002), (0.003, 0.003), (0.004, 0.004)]> ,时间将保持不变spos.transform_to(tpos).obstime

<Time object: scale='utc' format='jyear' value=1991.25>方法实际上在做什么?我实际上需要调用什么方法/函数才能将两者放入同一帧?

1 个答案:

答案 0 :(得分:1)

聚会晚了一点,但可能会帮助别人。

我认为问题是:您如何解释1991年到2000年之间由于适当运动引起的坐标变化。

transform_to()方法主要用于从一个坐标系更改为另一个坐标系。在这种情况下,两个目录均基于ICRS框架。 同样,在此期间也无需考虑地球轴的进动,因为该帧是参照遥远的天体固定的。

您可以使用apply_space_motion方法说明正确的运动:

spos = SkyCoord(
    ra =45 * u.deg,
    dec = 30 * u.deg,
    distance =100*u.pc,
    pm_ra_cosdec =5 * u.arcsec / u.yr,
    pm_dec = 5* u.arcsec / u.yr,
    obstime = 'J1991.25',
    frame='icrs' )

print('co_ords in 1991   ' , spos.ra, spos.dec)

spos = spos.apply_space_motion(new_obstime = Time(2000.0, format='jyear'))

print( 'co_ords in 2000   ', spos.ra, spos.dec)



>>>  co_ords in 1991    45d00m00s 30d00m00s
     co_ords in 2000    45d00m50.5211s 30d00m43.7445s

我在对象属性中添加了一个distance参数,否则它将在输出中导致警告。距离值是多少并不重要,因为我们只对2D解决方案感兴趣,但是,如果您考虑使用3D运动,那么这显然很重要。

我不确定您需要的位置有多准确,但我将适当的运动增加到 每年每轴5弧秒,以在此期间进行重大更改。只有像巴纳德的恒星这样的恒星才能在这种范围内正常运动。