-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable calculation of barycentric velocities in get_body_barycentric #5231
Conversation
Just to give a sense of what would be needed to calculate barycentric velocity corrections:
Here, for the coordinate, a real routine would need to ensure the skycoord is in ICRS and that it has unit length (as in |
3a58df4
to
640c491
Compare
@adrn, @eteq, @StuartLittlefair - would you be able to review this? While it is only a small step towards having barycentric velocities, it is an essential one, and I think fairly independent. One question I wavered about was whether to given |
|
||
barycen_to_body_vector = u.Quantity( | ||
np.rollaxis(cartesian_position_body, -1, 0), u.au) | ||
body_posvel_bary = np.rollaxis(body_pv_bary, -1, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for using a different array here? Can't you just use body_pv_bary throughout?
@mhvk This looks good! I don't know what you want to do about the bug I just found. My instinct is just to fix it here, but I could also raise a separate issue for that. I don't have a strong opinion on functions return different numbers of items depending on arguments. It's pretty explicit that specifying |
@StuartLittlefair - indeed, multi-dimensional times broke with |
body_posvel_bary = np.zeros((2 if get_velocity else 1, 3) + | ||
getattr(jd1, 'shape', ())) | ||
getattr(jd1, 'shape', ())) | ||
for pair in kernel_spec: | ||
spk = kernel[pair] | ||
if spk.data_type == 3: | ||
# Type 3 kernels contain both position and velocity. | ||
posvel = kernel.compute(jd1, jd2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think this should be posvel = spk.compute(jd1, jd2)
, otherwise you're ignoring the pair
s in kernel_spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duh, that's the problem with untested code paths. But I don't really know any ephemeris with data_type=3
...
Hi @mhvk - Just one minor thing outstanding and then I'm perfectly happy with this. |
1410d86
to
f5b5402
Compare
OK, I rebased to get rid of the astropy-helpers version change that somehow snuck in there. Otherwise, I think this is done. @eteq - I think @StuartLittlefair did a thorough review, but the one question we have not quite answered is whether the present approach of adding a |
@@ -188,11 +187,16 @@ def get_body_barycentric(body, time, ephemeris=None): | |||
ephemeris : str, optional | |||
Ephemeris to use. By default, use the one set with | |||
``astropy.coordinates.solar_system_ephemeris.set`` | |||
get_velocity : bool, optional | |||
Whether or not to calculate the velocity as well as the position. | |||
Note that no velocity can be calculated with the built-in ephemeris for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This "note" part should perhaps go in the "Notes" section instead?
@mhvk - sorry for the delay on this. I'm very much against a function that returns substantially different things based on a keyword argument. It tends to make for less readable code because ideally you can look at the name of a function and have that tell you what it's doing. So I would change this to I reviewed the rest of it, though, and I'm happy aside from the small docstring suggestion. |
f5b5402
to
b5253e3
Compare
@eteq - OK, I made it two routines instead, which both use the function as I had it (which now is private). I agree it is cleaner, even though I'm not all that happy with a very long name like p.s. I also made the docstring change, though it is in the private routine now. |
@eteq - I think I addressed your comments. OK to merge? |
@mhvk - yep, I'm with you that One oddity, though: it appears that only appveyor ran... weird, but I think I can get the tests to run (immediately) by just pushing it to my own fork. Will report back when it finishes (and if it passes I'll go ahead and merge) |
@eteq - did the travis run work on your branch? Otherwise, I think reopening and closing this PR would do the trick, or I can just do a rebase and force-push. |
@mhvk - yes: https://travis-ci.org/eteq/astropy/builds/158024088 The coverage error is ignorable, but there's a sphinx warning. Since I'm already looking at it, I'll see if I can fix it. |
Ah, I think I figured it out, @mhvk - see mhvk#19 . The test for that is running in https://travis-ci.org/eteq/astropy/builds/158215451 so if that passes you can merge that and then we can merge this. |
add get_body_barycentric_posvel to __all__ in coordinates/solar_system
Cancelled the builds here, since this is already being tested at https://travis-ci.org/eteq/astropy/builds/158215451 |
Those travis builds now passed; since appveyor was already OK, I'm merging... |
This is a first step towards being able to compute barycentric corrections (#3544). It allows one to calculate barycentric velocities of solar system bodies, including the Earth, either based on builtin ephemerides or JPL ones.
Probably need some discussion on how exactly to implement getting a barycentric correction (in particular, should it be a method of
SkyCoord
or perhaps ofTime
, likelight_travel_time
).