Skip to content

Use pmsafe instead of starpm for applying space motion to SkyCoords - #10296

Merged
adrn merged 7 commits into
astropy:masterfrom
StuartLittlefair:use_pmsafe
May 20, 2020
Merged

adrn merged 7 commits into
astropy:masterfrom
StuartLittlefair:use_pmsafe

Conversation

@StuartLittlefair

Copy link
Copy Markdown
Contributor

Description

This pull request fixes SkyCoord.apply_space_motion for the case where no distance is present on the SkyCoord and the proper motion is relatively high.

Fixes #10092

@StuartLittlefair
StuartLittlefair requested a review from eteq May 4, 2020 16:47
@StuartLittlefair
StuartLittlefair requested a review from adrn May 4, 2020 16:47
@StuartLittlefair StuartLittlefair added this to the v4.0.2 milestone May 4, 2020

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super-nice! pmsafe was introduced in 2013, but maybe missed because the more logical starpm does not have a cross-reference to it. Only some nit-pick comments.

My sense is that this fixes a bug so should go in 4.0.2, but perhaps good to get @eteq's opinion.

Comment thread astropy/coordinates/sky_coordinate.py Outdated
if override_plx:
new_distance = None
else:
new_distance = Distance(parallax=starpm[4] * u.arcsec, copy=False)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny detail, but starpm[4] << u.arcsec avoids a copy. (or just do u.Quantity(starpm[4], u.arcsec, copy=False) in analogy to what follows). In either case, might as well drop the copy=False on Distance, since it has to make a copy in order to calculate from a parallax.

frame='galactic',
obstime=Time('1988-12-18 05:11:23.5'))

with catch_warnings(ErfaWarning):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd use `pytest.warns(ErfaWarning, match='some piece of text that matches the expected warning')

c1 = SkyCoord(frame, obstime=t1, pressure=101*u.kPa)
applied1 = c1.apply_space_motion(new_obstime=t2)
applied2 = c1.apply_space_motion(dt=12*u.year)
with catch_warnings(ErfaWarning):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, use pytest.warns (allows you to remove the import too...). And maybe add a comment that one gets a warning because the PM chosen is very high.

@StuartLittlefair

Copy link
Copy Markdown
Contributor Author

Thanks @mhvk. Really useful comments, as per usual!

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super! @eteq, @adrn - would be good if you had a look (if only to be aware of this change). Will merge in a few days otherwise.

@eteq eteq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @StuartLittlefair ! It looks basically good to me, except for one minor suggested variable-name-change (I tried to catch it in all spots so you can use the "add suggestion to batch" and do it all in github if you're happy with it...). But I'm fine with this with or without, so approving!

Comment thread astropy/coordinates/sky_coordinate.py Outdated
Comment thread astropy/coordinates/sky_coordinate.py Outdated
Comment thread astropy/coordinates/sky_coordinate.py Outdated
@pllim

pllim commented May 19, 2020

Copy link
Copy Markdown
Member

Note: A rebase will be needed to get rid of that merge commit. FYI.

@StuartLittlefair

Copy link
Copy Markdown
Contributor Author

@pllim I think the circleci failure is unrelated...

@adrn
adrn merged commit 847cb5d into astropy:master May 20, 2020
astrofrog pushed a commit that referenced this pull request May 22, 2020
Use pmsafe instead of starpm for applying space motion to SkyCoords
astrofrog pushed a commit that referenced this pull request May 22, 2020
Use pmsafe instead of starpm for applying space motion to SkyCoords
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Behaviour of apply_space_motion without distance without a distance

5 participants