question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

problem with applying space motion on coord

See original GitHub issue

This fails:

from astropy import coordinates as coord
import astropy.units as u
my_coord = coord.SkyCoord(0, 0, unit='deg', pm_ra_cosdec=1*u.mas/u.year, pm_dec=1*u.mas/u.year)
my_coord.apply_space_motion(dt=-50*u.Myr)

Tried cur_oc_coord.apply_space_motion(dt=-50*u.Myr) (astropy > 3)

and failed with

---------------------------------------------------------------------------
ErfaError                                 Traceback (most recent call last)
<ipython-input-7-7045e831345c> in <module>
----> 1 my_coord.apply_space_motion(dt=-50*u.Myr)

~/miniconda/envs/casa_siblings/lib/python3.6/site-packages/astropy/coordinates/sky_coordinate.py in apply_space_motion(self, new_obstime, dt)
    524                 t1 = Time('J2000')
    525                 new_obstime = None  # we don't actually know the inital obstime
--> 526                 t2 = t1 + dt
    527             else:
    528                 t2 = t1 + dt

~/miniconda/envs/casa_siblings/lib/python3.6/site-packages/astropy/time/core.py in __add__(self, other)
   1828
   1829         # Go back to left-side scale if needed
-> 1830         out._set_scale(self.scale)
   1831
   1832         return out

~/miniconda/envs/casa_siblings/lib/python3.6/site-packages/astropy/time/core.py in _set_scale(self, scale)
    720
    721             conv_func = getattr(erfa, sys1 + sys2)
--> 722             jd1, jd2 = conv_func(*args)
    723
    724         if self.masked:

~/miniconda/envs/casa_siblings/lib/python3.6/site-packages/astropy/_erfa/core.py in taiutc(tai1, tai2)
  15623     """
  15624     utc1, utc2, c_retval = ufunc.taiutc(tai1, tai2)
> 15625     check_errwarn(c_retval, 'taiutc')
  15626     return utc1, utc2
  15627

~/miniconda/envs/casa_siblings/lib/python3.6/site-packages/astropy/_erfa/core.py in check_errwarn(statcodes, func_name)
     95
     96         emsg = ', '.join(['{0} of "{1}"'.format(errcounts[e], errmsgs[e]) for e in errcodes])
---> 97         raise ErfaError('ERFA function "' + func_name + '" yielded ' + emsg)
     98
     99     elif numpy.any(statcodes>0):

ErfaError: ERFA function "taiutc" yielded 1 of "unacceptable date"

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
adrncommented, Apr 23, 2019

Ah! Well, the short answer is that we don’t support dates beyond what ERFA supports, so that won’t work. But there is also a major conceptual issue: apply_space_motion() assumes linear space motion, but over a timespan as long as 50 Myr, we would need to numerically integrate the solar position backwards in time along with all other stars in order to get the sky positions of the stars correct. For stars without full phase-space information (most stars), we can’t do that, and for stars with full 6D information, we don’t know the gravitational potential of the Galaxy precisely enough to do that.

For a visual example of why the linear space motion assumption would be bad over this timescale, I grabbed 8 random stars from Gaia DR2 with full 6D information within a few hundred pc (sky position, distance, proper motions, radial velocity), and numerically integrated their orbits along with the Sun’s with gala:

import astropy.units as u
import astropy.coordinates as coord
import numpy as np
import gala.dynamics as gd
import gala.potential as gp

# Sun's position in the Galactocentric coordinate system:
galcen_frame = coord.Galactocentric(galcen_distance=8.1*u.kpc, z_sun=-27*u.pc)
sun_w0 = gd.PhaseSpacePosition(pos=[-1,0,0]*galcen_frame.galcen_distance + [0,0,1]*galcen_frame.z_sun,
                               vel=galcen_frame.galcen_v_sun)

# Randomly picked stars from Gaia
my_coord = coord.SkyCoord(ra=[315.06572822, 334.34759232, 258.55167264, 315.53226497,
                              271.16818609,  96.47983521, 119.09427413, 220.15150749]*u.deg,
                          dec=[29.51923942, -32.93498261, -42.36461715,  39.12845438,
                               87.76716419, 8.66101605, -41.97996961, -49.57875398]*u.deg,
                          distance=[788.79771037,  311.54724819, 1044.40735734,  457.52502537,
                                    295.62380702,  151.82586427,  578.47206159,  116.90328162]*u.pc,
                          pm_ra_cosdec=[10.40951216,  27.84115464,  -3.89832249,  -4.3520146 ,
                                        -10.35189345,   5.17322539,  -6.63972354,   9.7376234 ]*u.mas/u.yr,
                          pm_dec=[-0.84158883, -27.80704026, -13.99847048,  -3.99020718,
                                  0.17050257, -36.02970855,   4.02437175,  -8.56420079]*u.mas/u.yr,
                          radial_velocity=[-8.58147296, 17.59388507, 11.14926892, -4.93905246, 10.51017945,
                                           -6.00870398, 17.55519365, -5.74785665]*u.km/u.s)

my_w0 = gd.PhaseSpacePosition(my_coord.transform_to(galcen_frame).data)
w0 = gd.combine((sun_w0, my_w0))

potential = gp.MilkyWayPotential()

orbits = potential.integrate_orbit(w0, dt=-0.1*u.Myr, t1=0, t2=-50*u.Myr)
orbits.plot()

image

If you wanted to ignore the uncertainty in the Milky Way force field, and the uncertainty in the stellar kinematics, you could take the example above with gala, define a new solar coordinate system at the location of the sun from 50 Myr ago, and look at where the stars are on the sky 😃

1reaction
pllimcommented, Apr 23, 2019

Although… why would sabertooth era be unacceptable by ERFA? 🤔

Read more comments on GitHub >

github_iconTop Results From Across the Web

3.4 Motion in Space - Calculus Volume 3 | OpenStax
This situation, with an object moving with an initial velocity but with no forces acting on it other than gravity, is known as...
Read more >
Robotic Motion Planning: Configuration Space
The space of all configurations is the configuration space or C- space. ... Inverse kinematics -- finding joint angles from Cartesian coordinates.
Read more >
Chapter 6. Inverse kinematics
The reason is that certain end effector motions can only be attained by a coordinated, simultaneous motion of two or more joints, and...
Read more >
Proper Time, Coordinate Systems, Lorentz Transformations
This is the classical Galilean principle of 'relativity of motion'. Roughly stated, this means that uniform motion through space has no effect on...
Read more >
Coordinate Systems - LearnOpenGL
To transform the coordinates from one space to the next coordinate space we'll ... your cube may end up at a different location...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found