{"action":"created","issue":{"url":"https://api.github.com/repos/astropy/astropy/issues/6425","repository_url":"https://api.github.com/repos/astropy/astropy","labels_url":"https://api.github.com/repos/astropy/astropy/issues/6425/labels{/name}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/6425/comments","events_url":"https://api.github.com/repos/astropy/astropy/issues/6425/events","html_url":"https://github.com/astropy/astropy/issues/6425","id":248112407,"number":6425,"title":"Velocities in cylindrical coordinates","user":{"login":"jobovy","id":1044876,"avatar_url":"https://avatars2.githubusercontent.com/u/1044876?v=4","gravatar_id":"","url":"https://api.github.com/users/jobovy","html_url":"https://github.com/jobovy","followers_url":"https://api.github.com/users/jobovy/followers","following_url":"https://api.github.com/users/jobovy/following{/other_user}","gists_url":"https://api.github.com/users/jobovy/gists{/gist_id}","starred_url":"https://api.github.com/users/jobovy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jobovy/subscriptions","organizations_url":"https://api.github.com/users/jobovy/orgs","repos_url":"https://api.github.com/users/jobovy/repos","events_url":"https://api.github.com/users/jobovy/events{/privacy}","received_events_url":"https://api.github.com/users/jobovy/received_events","type":"User","site_admin":false},"labels":[{"id":21499868,"url":"https://api.github.com/repos/astropy/astropy/labels/coordinates","name":"coordinates","color":"c7def8","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-04T20:42:47Z","updated_at":"2017-08-08T19:16:04Z","closed_at":null,"body":"I'm trying to compute velocities in the Galactocentric cylindrical coordinate frame with astropy v2, but as far as I can tell this isn't documented anywhere. The following seems to work\r\n```\r\nra= 120.*u.deg\r\ndec= 30.*u.deg\r\ndistance= 1.2*u.kpc\r\npmra= 5.*u.mas/u.yr\r\npmdec= -3.*u.mas/u.yr\r\nvlos= 55.*u.km/u.s\r\nc= apycoords.ICRS(ra=ra,dec=dec,\r\n                  distance=distance,\r\n                  pm_ra_cosdec=pmra,\r\n                  pm_dec=pmdec,\r\n                  radial_velocity=vlos)\r\n# Define GC frame\r\nv_sun = apycoords.CartesianDifferential([11.1,245.,7.25]*u.km/u.s)\r\ngc_frame= apycoords.Galactocentric(galcen_distance=8.1*u.kpc,\r\n                                   z_sun=25.*u.pc,\r\n                                   galcen_v_sun=v_sun)\r\ncg= c.transform_to(gc_frame)\r\ncg.representation= 'cylindrical'\r\nprint(\"Cylindrical: v_r/(km/s)=\",cg.d_rho.to(u.km/u.s),\r\n      \", v_phi/(km/s)=\",cg.d_phi.to(u.mas/u.yr).value*4.74047*cg.rho.to(u.kpc).value,\r\n      \" v_z/(km/s)=\",cg.d_z.to(u.km/u.s))\r\nCylindrical: v_r/(km/s)= 17.213193237684614 km / s , v_phi/(km/s)= -213.59390592255582  v_z/(km/s)= 52.07396464035026 km / s\r\n```\r\nThis gives the right answer, but maybe this isn't how these ``d_`` attributes are supposed to be used? Also, having to manually convert ``d_phi`` from mas/yr to km/s must be wrong. Is there a way to get the velocity in the cylindrical representation out more directly that I am missing or if not, is it correct to use the ``d_`` attributes in this way?"},"comment":{"url":"https://api.github.com/repos/astropy/astropy/issues/comments/321054343","html_url":"https://github.com/astropy/astropy/issues/6425#issuecomment-321054343","issue_url":"https://api.github.com/repos/astropy/astropy/issues/6425","id":321054343,"user":{"login":"mhvk","id":2789820,"avatar_url":"https://avatars0.githubusercontent.com/u/2789820?v=4","gravatar_id":"","url":"https://api.github.com/users/mhvk","html_url":"https://github.com/mhvk","followers_url":"https://api.github.com/users/mhvk/followers","following_url":"https://api.github.com/users/mhvk/following{/other_user}","gists_url":"https://api.github.com/users/mhvk/gists{/gist_id}","starred_url":"https://api.github.com/users/mhvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhvk/subscriptions","organizations_url":"https://api.github.com/users/mhvk/orgs","repos_url":"https://api.github.com/users/mhvk/repos","events_url":"https://api.github.com/users/mhvk/events{/privacy}","received_events_url":"https://api.github.com/users/mhvk/received_events","type":"User","site_admin":false},"created_at":"2017-08-08T19:16:04Z","updated_at":"2017-08-08T19:16:04Z","body":"@jobovy - thanks! This is all new and shiny, so things may not be as clear yet as they should be. I'm happy to see though that the values come out right -- I don't think we have many tests for cylindrical representations...\r\n\r\nHere, I think the code works as planned: you ask it to represent the coordinates in cylindrical, i.e., a radius, angle, and height, and then the time derivatives will use the same units, so for the angle you get `angle/time` - it effectively is a proper motion, just as you would get if you went back to a spherical coordinate system (I wonder if it would be clearer if we called it `pm_phi`, though on the other hand I'm a bit wary of too many name overrides...)\r\n\r\nAs for the manual conversion, after multiplication with distance, the unit system needs to know how to get rid of the angle. Since the small angle approximation is a good one, we can treat angles in radians as dimensionless:\r\n```\r\n(cg.d_phi * cg.rho).to(u.km/u.s, equivalencies=u.dimensionless_angles())\r\n# <Quantity -213.5939268065537 km / s>\r\n```\r\n(This is equivalent to `cg.d_phi/u.rad*cg.rho`)\r\n"}}
{"actor":{"display_login":"mhvk"}}