New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support other default representations in SkyCoord #2550
Comments
@Cadair - that's correct. What were you thinking of? Part of the issue is that the user-interface is designed to be quite flexible, but in order to make that initially manageable we have focused on spherical coordinate inputs longitude, latitude, and distance. There is no fundamental limitation at this point so I don't imagine there being a problem supporting frames that are not spherical by default. It's just a question of making the syntax work. |
Here is some documentation that is currently in work. I think it should be manageable to support cartesian coordinates as being 3-tuples of length-type quantities:
|
Other than @taldcroft's option of using 3-tuples, we could build our own solar-coordinates specific wrapper, @Cadair. Something like |
Indeed it might make sense to subclass Note also that |
@vaticancameos @taldcroft I would much rather just use astropy's Is it possible to pass a representation object into |
Dumb question: how are we currently dealing with different origins for different representations? How would we distinguish between cartesian in heliocentric vs geocentric? |
@astrofrog I would say that a coordinate system with a different origin is a different frame. Is there any chance we can get a patch for this into 0.4? Just it will cause us issues if it is not upstreamed. |
@eteq - what do you think about patching |
@Cadair: Just saying, I'm up for patching it if need be. I have this
|
In terms of arbitrary representations, at first glance I think this is somewhat more of a In fact those bits currently are defined at the class level in the frame and don't get copied into instance attributes. I accidentally discovered this by modifying the So not to say it cannot be done, but I think it goes deeper than |
Just experimenting with changing the representation in a brute-force way. Kinda works, but not really...
|
So changing the
|
It's maybe not elegant, but what will work with the current plans for 0.4 release is to define frame classes like Note that if you do something like: |
@vaticancameos - I suspect it's deeper than that in the sense that the internal representation (i.e. the table of numbers that comprise the coordinate data) is really spherically-based. Not clear what sort of unexpected things happen when the representation is just abruptly changed. |
And who knows, maybe it's not that hard to add an |
Sorry, I missed that this discussion was happening. A few separate points:
So the idea is that If that worked, would it address your use cases, @Cadair and @vaticancameos ? |
@eteq - from what I can tell the code you suggested doesn't register I can certainly imagine things working more nicely, but I'm trying to think of things that would work with the coordinates we have now. We're starting to run into the type of suggestions that could noticeably delay release. We really must have astropy 0.4 out by SciPy, which I think realistically means focusing 100% on tidying the docs, finding bugs, getting all the packaging issues sorted, and the 500 other things that will come up. So my vote is not to accept new feature requests at this time. To be honest I think that SunPy are not the only ones that will have good ideas for features once the new coordinates is released. Is there a prohibition against having a mid-cycle 0.5 release for coordinates before the regularly scheduled 1.0? |
Just FYI, this works right now for initialization:
|
Hello, Let me try and work this out. This issue seems to have gone a little larger in scope than I intended. I am fully aware that we are on a deadline for 0.4, all I am really asking to get into 0.4 is the ability to support different prefered reprsentations. We are happy to contribute code, but it might be a good idea if you tell us a good plan of attack. To answer more specific points: @taldcroft We are planning on putting the SunPy frames onto the Astropy graph, because in theory we should be able to transform to the coordinate systems in Astropy, while it will be a neiche use case, it will be a cool feature. @eteq I think your example would service our needs perfectly. Another related question, why does doing this: x = SunPyFrame(...) #defaults to cartesian
x.represent_as(UnitSphericalRepresentation) return a representation object rather than a full frame in a new representation? The latter behaviour is going to be needed for us, in one way or another. (I realise you could stitch it together, but that is quite ugly). @taldcroft Your last example means we can at least make something work. We are going to be breaking this API this summer, we are going to be doing a lot of things that you might not have planned for. Part of the plan is to push this code back up and deal with these issues, a 0.5 release might not be a bad idea ;) |
@taldcroft - ah, you're right, I forgot to add a transform:
That will include it in the frame transform graph and allow you to go to/from SomeFrame to ICRS. Then it should work in |
@Cadair - But I don't quite understand what you mean when you say "rather than a full frame in a new representation". Representations do not have "intrinsic" representations - the preferred representation is just the most common one used by that frame. So if you have some frame that has a preferred cartesian representation, the way to actually get the spherical representation is exactly what you showed above. Internally, it's cached the first time you ask for the spherical representation, so it's not like it's wasting time re-computing it every time. |
Oh, and to address
That's exactly the way this is intended to be used: all transformations of spatial/celestial coordinates should live on the same transform graph. We'll only start needing multiple graphs when gWCS gets implemented. |
@eteq Ok so I think this might be a better idea: [Note I did this from memory]: >>> fr1 = MyFrame(...)
>>> type(fr1.data)
UnitSphericalRepresentation(...)
>>> fr1.get_represenation(CartesianRepresentation)
CartesianRepresentation(...)
>>> fr2 = fr1.represent_as(CartesianRepresentation)
>>> type(fr2)
MyFrame(...)
>>> type(MyFrame.data)
CartesianRepresentation(...) |
@eteq correct me if I am wrong but at the moment to get a new frame in a different representation you would have to do: >>> fr1 = MyFrame(...)
>>> fr2 = MyFrame(fr1.represent_as(CartesianRepresentation)) ???? |
@Cadair - I don't quite understand what you mean by "get a new frame in a different representation". I would say the way to do that is to just do:
That is, you only change representations when you actually want to do something with them. The internal representation used by a frame object should generally be regarded as an implementation detail... Can you be more specific about why you want it to be a particular representation? |
Oh, but that question aside, there's a slightly better way to acheive the same aim:
that will then preserver the frame attributes from |
@eteq Maybe I am missing something here, but there a a couple of solar coordinate frames which share the same origin and the same information (give or take) but are in cylindrical rather than spherical or spherical instead of cartesian. Rather than writing different frames for the same system but in a different representation, I thought it would be better to get a new Frame but where the internal data is in a different representation. (Which is the behaviour solar people will expect as they see them as different systems, even though they are not really). Basically I am suggesting a method that shortcuts this: >>> fr2 = fr1.realize_frame(fr1.represent_as(CartesianRepresentation)) |
@Cadair - this gets to the heart of the goal for the APE5 scheme. With this approach, there is no such thing as a "frame in cylindrical" or a "frame in spherical". A frame is a frame and there are lots of ways to represent points in that frame, but they're all essentially just different basis for the same point, rather than actually different points in different reference frames. So that's why I don't understand exactly what your goal is in changing representations for the same frame. If you have a frame that you initialized with a cylindrical representation, and want, say, the radius for the spherical version, you can just do Maybe a more complete example of what you might want to do with these two different objects would help? Maybe then I'd see that you actually want them to be more different than it seems to me? |
@eteq - maybe syntactic sugar, but I think what @Cadair wants (and what makes sense to me) is being able to do the solar equivalent of:
That at least is my understanding of a potential use case. (BTW, sorry, didn't have time to read the whole thread in detail, so hopefully I'm not off track or missing something that was said). |
@taldcroft yes that. |
@Cadair @taldcroft - so it looks to me like the only reason why If I'm understanding that correctly, what I'm trying to say is that this violates the separation-of-concerns APE5 is intended to implement. That is, frames should work regardless of what their representation - they may convert to the preferred representation some time, but that's not in any way intrinsic to the frame. That's way So is the problem that |
@eteq Ok I see your point, I forgot about the @eteq @taldcroft What would the best way be to patch |
@eteq, @taldcroft |
@eteq - I understand your point, but I think it addresses only part of the story here. While Second, if you do set a coordinate with a non-preferred representation, the default repr of that object still uses the preferred one, and there is no way to change that. In the context of interactive analysis and IPython notebooks, the repr of an object is important. The repr of the cartesian representation
So even though APE5 has the concept of a preferred representation, I don't think that we all appreciated that for a particular class like |
So here is a concrete idea: A frame class can define multiple representations:
And of course because I always like string aliases I would allow setting the The
I think this is the patch that SunPy have been wanting. :-) My first impression is that it's not that hard, but I don't know if there are any hidden complications. |
All - check out #2586, this is a proof of concept implementation of my suggestion above. |
When closing issues that are basically "won't fix" or "overcome by events" please also clear the milestone since the issue is no longer relevant to that milestone (or change it to the version the issue was actually addressed in). |
Unless myself and @vaticancameos are mistaken only frames that have
SphericalRepresentation
as their preferred frames are supported in SkyCoord at the moment?The text was updated successfully, but these errors were encountered: