Skip to content

Add CartesianFrameAttribute to coordinates for GCRS and PrecessedGeocentric frames - #5196

Closed
StuartLittlefair wants to merge 4 commits into
astropy:masterfrom
StuartLittlefair:gcrs_ndims
Closed

StuartLittlefair wants to merge 4 commits into
astropy:masterfrom
StuartLittlefair:gcrs_ndims

Conversation

@StuartLittlefair

Copy link
Copy Markdown
Contributor

This PR fixes #4926.

It was impossible to create GCRS frames and PrecessedGeocentric frames with obsgeoloc and obsgeovel frame attributes of shape (3, N).

I have created a new frame attribute to allow this as it seemed the easiest way to allow frame attributes with this property, without an API change. It was suggested to make the obsgeoloc and obsgeovel frame attributes CartesianRepresentation instances but this would have broken existing examples and required extensive code changes.

This PR also contains changes to the ICRS <-> GCRS transformation code, since that did not work for obsgeoloc and obsgeovel attributes with shapes other than (3,)

@mhvk

mhvk commented Jul 27, 2016

Copy link
Copy Markdown
Contributor

@StuartLittlefair - I still think using a CartesianRepresentation would be much more logical; I'm less worried about code changes than the fact that you mention that examples would no longer be correct. Could you point me to one?

If we're sticking with using some sort of Quantity instead of a new frame attribute, my preference would be to adapt QuantityFrameAttribute's shape-checking. E.g., one could redefine the shape as follows (which is backwards compatible):

shape : tuple of tuple and slice, or None
    The first tuple gives the shape that the particular slice of the input's shape has to match.
    If no slice is given, the whole shape should match. E.g., ((3,), slice(0, 1)) would ensure
    that the first dimension of the input is 3, while `(3,)` would ensure that the input is
    one-dimensional with size 3.
...
if shape is not None and not isinstance(shape[0], tuple):
    shape = (shape, slice(None))
self.shape
...
if self.shape is not None and value.shape[self.shape[1]] != self.shape[0]:
   raise ...

@StuartLittlefair

Copy link
Copy Markdown
Contributor Author

@mhvk I suppose "broken examples" was a poor choice of words.

What I meant was that the representation of SkyCoords with obsgeoloc properties would change, which would change a lot of the documentation and doctests (e.g http://docs.astropy.org/en/stable/coordinates/solarsystem.html)

Beyond that, although I would consider it an API change to transition these attributes to CartesianRepresentations it might be reasonably low impact, since it would only affect users who have created frames using these attributes directly (for example someone who'd written code similar to that in https://mail.scipy.org/pipermail/astropy/2015-September/003912.html) or those who have accessed the obsgeoloc attributes expecting them to return Quantity instances.

If people agree this is acceptable I'm happy to change this to use CartesianRepresentations. I agree it's more logical.

@mhvk

mhvk commented Jul 27, 2016

Copy link
Copy Markdown
Contributor

Another advantage of using CartesianRepresentationFrameAttribute is that its shape would automatically exclude the leading 3, so that one can easily check whether it broadcasts correctly against, e.g., the coordinates proper (of course, in your approach you can also expose the shape without the leading 3, but it would mean extra hacking).

@StuartLittlefair

Copy link
Copy Markdown
Contributor Author

@mhvk I've just made a separate PR using CartesianRepresentations. I was surprised how smooth it was in the end. I shall keep this one open until the other is merged.

@StuartLittlefair

Copy link
Copy Markdown
Contributor Author

Closing in favour of #5207

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.

Cannot create GCRS frames with obsgeoloc shapes other than (3,)

3 participants