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.

Velocities in spherical coordinates

See original GitHub issue

Hi, I’m converting some positions and velocities from ICRS to Galactocentric, and then turning that into a spherical representation. The velocities are given as angular velocities, which is a little strange since I would have expected them in km/s.

c = coord.SkyCoord(
        ra = ra * u.deg, 
        dec = dec * u.deg, 
        pm_ra_cosdec = pmracosdec * u.mas/u.yr, 
        pm_dec = pmdec * u.mas / u.yr, 
        radial_velocity = vrad * u.km / u.s, 
        distance = dist * u.kpc,
        frame = 'icrs',
    )
cg = c.transform_to(coord.Galactocentric())
cgs = cg.represent_as('spherical')
diffs = cgs.differentials['s']
diffs
<SphericalDifferential (d_lon, d_lat, d_distance) in (mas / yr, mas / yr, kpc mas / (rad yr))
    (-0.17801241, -0.06221044, -12.62912254)>

How can I get these in km/s? For d_distance I can do

cgs.differentials['s'].d_distance.to(u.km/u.s)

but for d_lon and d_lat I can’t do the conversion, even when I multiply by the distance:

(cgs.differentials['s'].d_lon * dist * u.kpc).to(u.km/u.s)

gives the following error:

UnitConversionError: 'kpc mas / yr' and 'km / s' (speed) are not convertible

Thanks.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

11reactions
adrncommented, Jul 9, 2021

Coming back to this because of velocity conversion headaches the students are facing at our Galactic Dynamics summer school — we should really just implement your proposed solution @mhvk (and same for PhysicsSpherical, Cylindrical, etc.)!

1reaction
mhvkcommented, Jul 9, 2021

Sounds good! Mostly just needs agreement on the name! Also for the attributes: v_ra, v_dec, radial_velocity, I guess?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spherical coordinates - Dynamics
The spherical coordinate system extends polar coordinates into 3D by using an ... the spherical basis vectors to rotate with the following angular...
Read more >
3.4: Velocity and Acceleration Components - Physics LibreTexts
In figure III.9, P is a point moving along a curve such that its spherical coordinates are changing ...
Read more >
How do you find velocity in spherical coordinates? - Quora
Vx, Vy, and Vz be the x,y, and z components of the velocity V in Cartesian co-ordinates i.e. V= iVx + jVy +...
Read more >
Spherical coordinate system - Wikipedia
Spherical coordinates (r, θ, φ) as commonly used in physics (ISO 80000-2:2019 convention): radial distance r (distance to origin), polar angle θ (theta)...
Read more >
Conversion of cartesian position and velocity to spherical ...
In spherical coordinates the velocity is: →v · However, the velocity vector is the same vector wether you write it using the spherical ......
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