Repository navigation
Precise barycentric radial velocity corrections. - #6861
Conversation
|
Hi there @StuartLittlefair 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. Everything looks good from my point of view! 👍 If there are any issues with this message, please report them here. |
| obsgeovel = CartesianRepresentation(vel_x, vel_y, vel_z) | ||
|
|
||
| # CIRS velocity | ||
| rotation_vector = CartesianRepresentation(0/u.s, 0/u.s, OMEGA_EARTH) |
There was a problem hiding this comment.
Now that we have velocity support in frames at least, it should be possible to not do anything at all, except to add zero velocity to the ITRS position... PR soon...
|
This is great! But looking at the code, I realized that you are just reimplementing part of the frame transfer graph, and it seems to make even more sense to just use it completely. It turns out all that is needed is add a velocity of 0 to the I also couldn't resist some reorganizing of the redshift function, probably for no net benefit... |
|
With new methods, I don't know that we can backport this... |
Use frame transformations / simplify redshift
|
Thanks @mhvk! Lovely tidying in that PR. |
mhvk
left a comment
There was a problem hiding this comment.
Mostly small things, but it would seem that this might not be quite correct if the coordinates are not in ICRS.
| from ..utils.compat.numpycompat import NUMPY_LT_1_12 | ||
| from .angles import Longitude, Latitude | ||
| from .representation import CartesianRepresentation | ||
| from .matrix_utilities import matrix_transpose |
There was a problem hiding this comment.
Should have seen this when I made the PR to your PR, but we don't need this any more.
There was a problem hiding this comment.
yep, good point
| else: | ||
| # skycoord has distances so apply parallax | ||
| obs_icrs_cart = get_body_barycentric('earth', obstime) + gcrs_p | ||
| icrs_cart = self.cartesian |
There was a problem hiding this comment.
Don't we have to transform ourselves to ICRS for this to hold?
There was a problem hiding this comment.
damn - we do! This was a bug in the original version too. Also needs conversion in the if part of the if...else... clause.
| targcart = self.represent_as(UnitSphericalRepresentation).to_cartesian() | ||
| else: | ||
| # skycoord has distances so apply parallax | ||
| obs_icrs_cart = get_body_barycentric('earth', obstime) + gcrs_p |
There was a problem hiding this comment.
It seems a bit wasteful to re-calculate Earth here, when it was already done for the velocity above.
Probably best to just have pos_earth, vel_earth = get_body_barycentric('earth', obstime) early on.
| # skycoord has distances so apply parallax | ||
| obs_icrs_cart = get_body_barycentric('earth', obstime) + gcrs_p | ||
| icrs_cart = self.cartesian | ||
| targcart = (icrs_cart - obs_icrs_cart).represent_as(UnitSphericalRepresentation).to_cartesian() |
There was a problem hiding this comment.
This is a bit slow, since you have to do all the needless trig. I'd do:
targcart = icrs_cart - obs_icrs_cart
targcart /= targcart.norm()
There was a problem hiding this comment.
Much better.
|
Hi, This is our repo Shubham |
mhvk
left a comment
There was a problem hiding this comment.
One typo, but perhaps more importantly, could you update the docstring of radial_velocity_correction to note that (1) barycentric is more precise, and (2) that it should be applied multiplicatively for full precision (as you describe in the full documentation).
| gamma_obs = 1 / np.sqrt(1 - beta_obs.norm()**2) | ||
| gr = location.gravitational_redshift(obstime) | ||
| # barycentric redshift according to eq 28 in Wright & Eastmann (2014), | ||
| # neglectic Shapiro delay and effects of the star's own motion |
|
Approval was on the implementation (very nice!); doc-string would still be good to do (can be a |
|
OK, this all looks good from my perspective. The main question is about the milestone: @eteq, @astrofrog: this PR introduces two new methods, which are used in the radial-velocity correction. Is this OK for 2.0.3? It does correct a bug in the initial implementation. |
|
What is the status of issue discussed in #5783 for keeping Astropy updated with the latest leap seconds? Until that is fixed, we should add a warning in the documentation about this potential loss of precision. |
|
I would personally vote for 2.0.3 - @eteq? |
|
@shbhuk we won't let the leap seconds in astropy get out of date. At the moment this means releasing a bug fix to astropy, but that will get done when necessary |
|
@shbhuk Thanks for pointing this out. |
|
Agreed we really need to do this automatically, ideally from the IERS tables (which are already downloaded when needed anyway). Indeed, even to check those we do need to download the IERS tables - we cannot know when a leap second will occur when we release a new version of astropy. Help with this much appreciated! (see #5783 and links there) |
There was a problem hiding this comment.
@StuartLittlefair - thanks for all this - a huge improvement, and the core algorithms all LGTM. I also agree this is ok as 2.0.3 (with my caveat below).
The main concern I have is the introduction of two new (and useful) methods in a bugfix. As you'll see inline I have an idea for how to address that. If you're cool with what I suggest there, I'm happy to do the legwork on that myself so as not to delay this any further.
| for the location of this object at the | ||
| default ``obstime``.""") | ||
|
|
||
| def get_gcrs(self, obstime): |
There was a problem hiding this comment.
This is nominally a new feature and should be documented as such, but then we run into the awkwardness of "new feature" despite this being a bugfix. I wonder if the way to go is to have it be private (e.g. _get_gcrs) for this PR but then add a follow-on (trivial) PR for 3.0 that just de-privatizes it and has a changelog entry mentioning it?
| obsgeovel = gcrs_data.differentials['s'].to_cartesian() | ||
| return obsgeopos, obsgeovel | ||
|
|
||
| def gravitational_redshift(self, obstime): |
There was a problem hiding this comment.
similar here with the above re: privitizing this for this PR. One could definitely see people wanting to use this on its own, but we should then have it in the changelog.
| """ | ||
| # needs to be here to avoid circular imports | ||
| from .solar_system import get_body_barycentric | ||
| names = ('sun', 'jupiter', 'moon', 'earth') |
There was a problem hiding this comment.
Perhaps this should be a keyword argument with this as the default instead of hard-coded? That way if say, you thought you really cared about Saturn for whatever reason, you could include it.
(If we go with my private->public scheme this could be done in the follow-on PR. )
There was a problem hiding this comment.
I think this is a great idea but will leave it to a follow-on PR to avoid holding this up, since one wants to be careful about documenting which names are OK, and matching masses with names...
|
|
||
| sc = SkyCoord(1*u.deg, 2*u.deg) | ||
| vcorr = sc.rv_correction(kind='barycentric', obstime=t, location=loc) | ||
| rv = rv + vcorr + rv * vcorr / consts.c |
There was a problem hiding this comment.
Now that it's actually useful, we should add something to do this automatically. That's definitely a follow-on PR since it would be a new function/method, but now it's definitely justified.
There was a problem hiding this comment.
agreed! For 3.0 I'd like to do a PR that includes the effects of the proper motion and distance if they're present on the SkyCoord so I could add a function/method to that PR
|
@shbhuk @indiajoe - can you create a new issue about the idea of raising a warning re: leap seconds? I personally don't agree that there should be a warning, but it's open for discussion, and I would rather not block this PR while we hash that out. Bear in mind that this problem already existed, just was masked by the missing pieces that this PR fixes, so it's not a "new" problem that needs addressing now. And more generally we definitely do not want warnings to suddenly appear due to a bugfix release. (Or alternatively, put something about this into #5783 as stronger motivation for making #5783 happen... As detailed there we definitely want that to happen but it's non-trivial work) |
|
Great, looks good now once the tests pass. I'll make the PR to do the publicizing (already have it ready at https://github.com/eteq/astropy/tree/publicize_vcorrs_bits but will wait on this so that no extra rebase is needed). |
Precise barycentric radial velocity corrections.
This PR builds on the improvements to
EarthLocation.get_gcrs_posvelin #6699, to offer radial velocity corrections compatible with Wright & Eastman (2014) to 10 mm/s (for sources at infinite distance).Prior to this PR, radial velocity corrections between astropy and WE14 differed by several metres/second. This is due to ignoring the gravitational redshift at the observatory and a slight bug in

SkyCoord.radial_velocity_correction. This PR fixes both of these issues to give much more accurate radial velocity corrections. The plot before shows the situation before (top) and after (below). The yellow star marks the position of the Sun.As discussed in 5752 improvements to the precision of these corrections should probably be thought of as bug fixes.
The only remaining physics to include is that caused by the proper motion and parallax of the source, but I propose only including those terms once velocity support is added to
SkyCoord.This PR fixes #6697 and also fixes #6680, subject to the precision required by that user.