Skip to content

Fix two bugs in get_sun and related bug in GCRS->ICRS transformation - #3750

Merged
eteq merged 5 commits into
astropy:masterfrom
eteq:fix-get_sun
May 15, 2015
Merged

eteq merged 5 commits into
astropy:masterfrom
eteq:fix-get_sun

Conversation

@eteq

@eteq eteq commented May 3, 2015

Copy link
Copy Markdown
Member

This fixes two bugs I found in astropy.coordinates.funcs.get_sun:

  1. The GCRS frame that was being returned was not getting an obstime corresponding to the input times. That's not strictly speaking wrong, but it probably is confusing.
  2. The ERFA function that's used to get the sun/earth vector says it's in BCRS. That means it has not included the effects of aberration of light, which is included in the GCRS frame. So this PR adds in the effect of abberation.

These effects are quite small for what actually ends up observable (i.e. the AltAz frame), so things like the observing example are unaffected, but this is slightly more correct.

Also included is a fix to a definite bug I uncovered while testing get_sun for this fix: the GCRS->ICRS transformation was computing the distance wrong, yielding strange incorrect results like a coordinate near the ICRS origin comes back via the ICRS->GCRS->ICRS transformation as though it were 2 AU away from the barycenter. The actual fix is just the removal of a minus sign.

@eteq

eteq commented May 3, 2015

Copy link
Copy Markdown
Member Author

cc @adrn
also cc @cdeil and @ejeschke (you may or may not recall, but I uncovered this during one of our hangouts about the observing planning GSoC project)

@cdeil

cdeil commented May 4, 2015

Copy link
Copy Markdown
Member

I think the travis-ci fail is a fluke?
Can someone restart this build?
https://travis-ci.org/astropy/astropy/jobs/61056885#L2165

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.

Would it make sense to extract these aberration formulae into a helper function?
Might not be worth exposing in __all__, but could come in handy in other places in astropy.coordinates or other packages that use astropy.coordinates?
Just a thought ... I'm not sure.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, that make senses - there's a builtin_frames/utils.py that has helper functions used in some of the other frames.

I'll give it some time to see if there are other comments on this, but it's easy enough to pull this out and put it there.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually, @cdeil, after trying to do this I realized I couldn't really figure out a way to make it any simpler to actually invoke than the already existing usage, because in all other cases you would want to specify the earth->something else axis. Here it's only simpler because the "something else" is the sun itself. So I don't really see a way to generalize it more than what's in the existing ERFA ab function. (except for the invlorentz bit... not sure why ERFA decided that should be stored separately... But that's a one-liner and it doesn't seem to me like it justifies a helper at this point)

@eteq

eteq commented May 6, 2015

Copy link
Copy Markdown
Member Author

@taldcroft @adrn or @astrofrog - do you or anyone you can think of want to review this? I feel like another brain separate from mine should try to wrap their brain around this, most because I got it wrong once already and am now afraid I might be doing it again, just in a different way...

@adrn

adrn commented May 7, 2015

Copy link
Copy Markdown
Member

@eteq I'm happy to review, but am definitely not an expert. If someone else wants to step up, please do! Otherwise, I'll take a look this afternoon.

@eteq

eteq commented May 7, 2015

Copy link
Copy Markdown
Member Author

@adrn - I think the experts at this don't generally hang out on github, so I think your perspective is valuable even just to make sure it makes internal sense...

@taldcroft

Copy link
Copy Markdown
Member

@eteq - this is well beyond my coordinates-fu...

@eteq

eteq commented May 8, 2015

Copy link
Copy Markdown
Member Author

@adrn - were you still planning to review this? I see it needs a rebase, but it's a trivial one-liner, so you can review it first so we don't waste testing cycles

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.

This is getting super picky, but I liked to put in axis=-1 -- did a double take on this because I thought it was missing the axis specification.

Also, curious as to why you transpose and use the last axis? Won't this be a tiny tiny tiny bit faster if you just do

distance = np.sum((astrom['eb']*u.au + gcrs_coo.cartesian.xyz)**2, axis=0)**0.5

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

will add the axis part - I completely agree with you but was just being lazy here.

Re: the transpose: it's needed because astrom['eb'] is sometimes a vector of length equal to the non-3 dimension of xyz, so the transpose there was the easiest way to get the broadcasting to work. I think it would also work to reshape the astrom['ab'] to (1,n), but this seems simpler...

@adrn

adrn commented May 9, 2015

Copy link
Copy Markdown
Member

I'm no expert on the details of the transformation, but I'm happy with the code itself!

@eteq

eteq commented May 14, 2015

Copy link
Copy Markdown
Member Author

Alright, rebased and I addressed @adrn's comment, as well as adding a changelog entry. Will merge once the tests pass if there are no objections.

eteq added a commit that referenced this pull request May 15, 2015
Fix two bugs in get_sun and related bug in GCRS->ICRS transformation
@eteq
eteq merged commit 7b595e4 into astropy:master May 15, 2015
@eteq
eteq deleted the fix-get_sun branch May 15, 2015 18:42
eteq added a commit that referenced this pull request May 28, 2015
Fix two bugs in get_sun and related bug in GCRS->ICRS transformation
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.

5 participants