Skip to content

Finish up Astrometric frame and spherical_offsets_to - #4909

Merged
astrofrog merged 37 commits into
astropy:masterfrom
eteq:astrometric-frame
May 16, 2016
Merged

astrofrog merged 37 commits into
astropy:masterfrom
eteq:astrometric-frame

Conversation

@eteq

@eteq eteq commented May 14, 2016

Copy link
Copy Markdown
Member

This PR is an amalgamation of related work, particularly from #4338 and #4524 (it replaces both). Thanks to @alexrudy and @Kevtron for their contributions in the latter!

I won't dwell on the ideas too much because they been covered in all the other issues I reference here and have been reviewed piece-meal in the various PRs. So if the tests pass my feeling is that this is all set!

One significant change from #4524 that's worth mentioning though: this now uses some metaclass magic to convince the class generator (which creates astrometric classes) to both give correct class names (previously they were all called Astrometric which causes various issues - now they get names like AstrometricICRS), and change the spherical components to e.g. dra and ddec / dlon and dlat (instead of ra and dec or lon and lat). I think this is safer because that makes it immediately clear when reading the code that it's an astrometric ("offset") frame instead of just an ordinary frame.

So if merged, this closes #4209, closes #4338, closes #4339, and closes #4524 (whew!)

Kevin Sooley and others added 29 commits May 13, 2016 18:39
This function didn't really do anything that can't be done by just
creating a new frame from the same thing.  I.e,

frame.__class__(orgin=neworigin)
is the same as
frame.at_origin(neworigin)
@eteq

eteq commented May 14, 2016 •

Copy link
Copy Markdown
Member Author

(Oh, and it assuages @r-owen and @mhvk's concerns from #4338 by no longer using the small-angle approximation: spherical_offsets_to is now basically just a shell to simplify the use of astrometric frames for the one-to-one use case)

i00.spherical_offsets_to(fk5)


#large offset (>1 deg) should give a warning

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.

No longer true, so remove this comment!

@mhvk

mhvk commented May 14, 2016

Copy link
Copy Markdown
Contributor

@eteq - this looks great, although the actual machinery is still beyond me (it would be good to have a "coordinates for developpers" section in the documentation, just like @astrofrog has been thinking about a similar one for modelling).

@mhvk

mhvk commented May 14, 2016

Copy link
Copy Markdown
Contributor

The two remaining failures in travis seem to real (it is a doctest).

@eteq

eteq commented May 14, 2016

Copy link
Copy Markdown
Member Author

Alright, I think I've addressed all of @mhvk's comments.

Re:

the actual machinery is still beyond me (it would be good to have a "coordinates for developpers" section in the documentation, just like @astrofrog has been thinking about a similar one for modelling).

Good idea! I created #4913 to try to help us remember to do this. I admit there's some real black magic going on in the metaclasses here. Although I confess I enjoyed it: there's some really tricky stuff going on there that is really only possible due to Python's inherent flexibility.

@eteq

eteq commented May 14, 2016

Copy link
Copy Markdown
Member Author

weird... the remaining failure is due to doctests that come out as either 0 or -0 at machine precision. I would have thought FLOAT_CMP would fix that but apparently not... at any rate, I can just change the examples to do something that's not quite so close to 0.

@mhvk

mhvk commented May 14, 2016

Copy link
Copy Markdown
Contributor

Sounds good to just change the example. I think this reflects a display issue in older versions of numpy -- I'd guess FLOAT_CMP would pick it up if there were a dot after the number (which there should be).

@eteq

eteq commented May 14, 2016

Copy link
Copy Markdown
Member Author

in the end I concluded that it was good to keep one example with 0s (to demonstrate the idea) and just skip that in the doctests. The rest are all non-0 now (and otherwise essentially identical), so it's still sufficiently tested.

@taldcroft

Copy link
Copy Markdown
Member

@eteq - rather late to this conversation, but I had always assumed that astrometric frames would include a roll (or parallactic) angle. This has practical application as a poor-mans WCS to make a quick sky image (perhaps a finding chart) based on a catalog and telescope parallactic angle.

@eteq

eteq commented May 16, 2016

Copy link
Copy Markdown
Member Author

@taldcroft -Ah, good point. Was pretty easy to include, so the commit I just pushed up includes a rotation attribute (which defaults to 0).

One catch with this: it's now somewhat less right to call it "dra" or "ddec" if the rotation is non-0. But I think it's ok to just accept that - it's still reasonably clear, and one can always do coord.spherical.lat or similar.

@taldcroft

Copy link
Copy Markdown
Member

@eteq - awesome on getting in the rotation! I had expected to have to wait until 1.3. 😄

@eteq

eteq commented May 16, 2016 •

Copy link
Copy Markdown
Member Author

Oh, one thing about the rotation: I just picked the sign in the way that I thought was the most likely use case ("rotate to match a thing at position angle x"), but I'm really not sure if that's the most intuitive direction. Probably best to just merge this once the tests are passing, and then have an issue about that, as we can gather user opinions during beta.

@eteq

eteq commented May 16, 2016

Copy link
Copy Markdown
Member Author

Turns out there's a really obscure bug in py 3.3: the namedtuple._asdict method does not work correctly if a namedtuple is a subclass of another namedtuple. My only question is: who was it that found this and fixed it in 3.4?? This is a pretty deep obscure hole in the python world...

Anyway, after the last commit (which just adds a compatibility layer to fix up the py 3.3 asdict), we should be good to go.

@astrofrog
astrofrog merged commit 3c47c10 into astropy:master May 16, 2016
@astrofrog

Copy link
Copy Markdown
Member

Looks good!

@mhvk

mhvk commented May 16, 2016

Copy link
Copy Markdown
Contributor

@eteq - on the names: from what I've seen from, e.g., POSS and UCAC calibration, if one goes for relative positions, sometimes xi and eta are used as local longitude and latitude relative to a plate centre (e.g., the UCAC paper by Zacharias et al. http://adsabs.harvard.edu/abs/2000AJ....120.2131Z). But those of course still have unknown position, so arguably that would be a bit different astrometric frame. Still, it may not be bad to use those for the names, since for large values, dra and ddec are not offsets in ra, dec any more (dra=12h, ddec=0 would get one to ra_ref+12h, -dec_ref). And it doesn't have problems at the poles...

As for the rotation, I think one always it to be such that with rot=0, a star to the North from the ref star would have a positive offset in latitude, with rot=90, that would hold for a star in the East, etc., i.e., the rotation defines where a positive offset in latitude goes, from N going through E.

@eteq
eteq deleted the astrometric-frame branch May 16, 2016 14:44
@eteq

eteq commented May 16, 2016

Copy link
Copy Markdown
Member Author

(I've created #4931 to continue the conversation since this is now merged as-is)

@mhvk mhvk mentioned this pull request May 17, 2016
@mhvk

mhvk commented May 18, 2016

Copy link
Copy Markdown
Contributor

@eteq - the doctest problem with -0. and 0. was because FLOAT_CMP did not use the sign of numbers; see 41293bf

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.

Create AstrometricFrame Function or method to compute the RA and Dec offsets between two coordinates?

5 participants