Repository navigation
Add geodetic representations - #11086
Conversation
mhvk
left a comment
There was a problem hiding this comment.
@astrojuanlu - this looks good! I'm actually pleasantly surprised to see how relatively simple it is to add - the work is mostly in the tests!
Beyond the small in-line comments: I think these representations belong in earth.py as they are not useful as general representations. Similarly, I'd put the tests in test_earth. (Or perhaps a new earth_representations or even an earth/ module. Though seems a bit overkill right now.)
I agree that for now we can ignore velocities - we can add the ability to mimic observations from airplanes when the need arises!
How were you thinking of proceeding? A first step might simply be to remove the transformation machinery in EarthLocation and instead go through these representations inside from_geodetic and lon, lat, heigh - to_geodetic() may need some kind of deprecation warning as right now it returns a namedtuple and people may count on it. (I think that is OK, we should move to .represent_as anyway, making it more frame-like.)
p.s. I'll change this to draft right now just to be sure we don't accidentally merge.
|
Thanks for the prompt review @mhvk ! I agree with moving this to |
Don't forget balloons! https://askdrphilastro.wordpress.com/2019/12/15/blast-antarctica-2019-2020/ |
How can I forget my own colleague! So, we will have to get there... |
6b09266 to
b227ed9
Compare
b227ed9 to
e831960
Compare
|
Addressed the first batch of comments, going to look into |
|
What I did in the end was to deprecate This is ready for a second pass! |
|
Many test failures due to the |
|
I would just note that many locations on Earth have heights that are below that of the ellipsoid. I seems a bit unreasonable to force a different method for creating an |
|
Darn, we'd need |
mhvk
left a comment
There was a problem hiding this comment.
@astrojuanlu - this is starting to look very nice. Bit of a mix of larger and probably overly detailed comments.
More general one is where we stop. One option is actually a bit before where you are now, i.e., not add deprecation messages yet, but just introduce the new representations and use them internally only for the transformations. This has the advantage that no tests will fail yet. Arguably, in that case, we would also not yet add the represent_as method (which is not tested yet, so that is fine, I think).
The other is perhaps a bit further than you are now, whether EarthLocation stops becoming a Quantity and instead stores the representation in .data like a frame (or perhaps as an intermediate suggestion still shares the data with a CartesianRepresentation).
But my sense would be to take the smaller step suggested above, so we can get this in and follow-up on it.
| For the conversion to geodetic coordinates, the ERFA routine | ||
| ``gc2gd`` is used. See https://github.com/liberfa/erfa | ||
| """ | ||
| warn("Method .to_geodetic(ellipsoid) is deprecated, " |
There was a problem hiding this comment.
Agree with the deprecation message, but in analogy with a frame or sky coord, I think there is little against still having the properties for particular representations, i.e., I think we should allow (and also refer to in the warning message),
el.{wgs84,...}geodetic
el.cartesian
There was a problem hiding this comment.
Removed the deprecation message for now, but saving this for the future.
| llh.lat, | ||
| u.Quantity(llh.height, self.unit, copy=False)) | ||
|
|
||
| def represent_as(self, other_class): |
There was a problem hiding this comment.
Again seeing EarthLocation as more like a frame/skycoord rather than a representation, I think we can allow strings. I'd suggest following the nomenclature in their represent_as method and calling it base.
There was a problem hiding this comment.
Removed represent_as for now, but saving this for the future.
| return new_array.view(self.dtype).reshape(self.shape) | ||
|
|
||
|
|
||
| class BaseGeodeticRepresentation(BaseRepresentation): |
There was a problem hiding this comment.
I think this will get registered in REPRESENTATION_CLASSES, which is not ideal... Pinging @adrn for ideas; should we allow a name = False explicit way to avoid registration? (Note: this should not have to hold up this PR!)
| assert str(greenwich.info).startswith('name = Royal Observatory Greenwich') | ||
|
|
||
|
|
||
| class TestWGS84GeodeticRepresentationRepresentation: |
There was a problem hiding this comment.
I would shrink this class substantially - many of the tests are done on Spherical to just have them done once, no need to do them again. Also, do re-align for the longer name...
There was a problem hiding this comment.
Thinking more, since all new tests are (very nicely) just focussed on the representations, how about a new test_geodetic_representations?
There was a problem hiding this comment.
I moved these tests to test_geodetic_representations.py, but I'm not sure which ones to remove.
I agree - I will remove the deprecation warnings and remove |
0a95f85 to
988b8fe
Compare
|
While supporting alternate ellipsoids is fine, you should realize that there is more work involved in doing so. As currently written, |
|
I should note that this relates to task 1) in issue #11072 |
221d454 to
900fbfa
Compare
|
Warnings are legitimate: fixing |
783303e to
8226e48
Compare
Also ensure longitude wraps at 180.
Turning it from a tuple into a dict.
8226e48 to
4612ca1
Compare
|
@astrojuanlu - OK, I also changed the tests now. Plus one thing that you should sign off on: to make |
mhvk
left a comment
There was a problem hiding this comment.
Approving, but, as noted, @astrojuanlu, would be best if you approve the changes I made!
| 'lat': Latitude, | ||
| 'height': u.Quantity} | ||
|
|
||
| def __init_subclass__(cls, **kwargs): |
astrojuanlu
left a comment
There was a problem hiding this comment.
Can't approve my own pull request. This looks good to me, thanks @mhvk for the final tweaks!
Description
In line with discussions at #4261, this pull request aims to add geodetic representations.
I started with
WGS84GeodeticRepresentationto touch base and get a few eyes on my approach. In particular, I don't think we can cleanly have a genericGeodeticRepresentationwhere the ellipsoid is an extra parameter, retained in roundtrip transformations, but I would be glad to be proven wrong.The tests are almost a copy-paste of
TestSphericalRepresentation, with a few changes:heightinstead ofdistanceheightcan only be aQuantity, not aDistanceBesides, I also adapted
test_gc2gdandtest_gd2gcfromtest_earth.pyto make sure we get the same results.