Skip to content

Implement a DistanceOffsetFrame that's like SkyOffsetFrame but includes distance effects #7770

Open

Description

@astrojuanlu

From the documentation of SkyOffsetFrame objects:

A frame which is relative to some specific position and oriented to match its frame.

So I hoped I would be able to do things like this:

GCRS2 = SkyOffsetFrame(origin=ICRS(get_body_barycentric("earth", Time.now())))

However, it seems that SkyOffsetFrame objects are not using the distance information, and transformations with or without it produce the same result:

In [3]: skyoffset_nodist = SkyOffsetFrame(origin=ICRS(ra=31 * u.deg, dec=10 * u.deg))

In [4]: skyoffset_dist = SkyOffsetFrame(origin=ICRS(ra=31 * u.deg, dec=10 * u.deg, distance=1 * u.kpc))

In [5]: coords = ICRS([0.4, 0.3, 0.2] * u.km, representation_type=CartesianRepresentation)

In [6]: coords.transform_to(skyoffset_nodist).cartesian
Out[6]: 
<CartesianRepresentation (x, y, z) in km
    (0.52455168, 0.05113496, 0.11059271)>

In [7]: coords.transform_to(skyoffset_dist).cartesian
Out[7]: 
<CartesianRepresentation (x, y, z) in km
    (0.52455168, 0.05113496, 0.11059271)>

Activity

  1. astrojuanlu commented on Aug 25, 2018

    @astrojuanlu
    MemberAuthor

    And I guess the reason is here:

    @frame_transform_graph.transform(DynamicMatrixTransform, framecls, _SkyOffsetFramecls)
    def reference_to_skyoffset(reference_frame, skyoffset_frame):
    """Convert a reference coordinate to an sky offset frame."""
    # Define rotation matrices along the position angle vector, and
    # relative to the origin.
    origin = skyoffset_frame.origin.spherical
    mat1 = rotation_matrix(-skyoffset_frame.rotation, 'x')
    mat2 = rotation_matrix(-origin.lat, 'y')
    mat3 = rotation_matrix(origin.lon, 'z')
    return matrix_product(mat1, mat2, mat3)

    Even if origin has the distance attribute, it's not used. If this is not by design and it's a bug, I guess it shouldn't be very difficult to fix and I can do it myself.

  2. astrojuanlu commented on Aug 25, 2018

    @astrojuanlu
    MemberAuthor

    I guess it shouldn't be very difficult to fix and I can do it myself.

    ...or maybe it is, because it changes the nature of the transformation to a FunctionTransform or FunctionTransformWithFiniteDifference.

  3. adrn commented on Oct 8, 2018

    @adrn
    Member

    onceptually, transforming to a SkyOffsetFrame is meant to remain at the same origin and just rotate to a coordinate system with the origin at the specified location. But I see how the docstring of SkyOffsetFrame is vague enough that it sounds like it does what you need! Personally, I think the type of transformation you want should belong in a separate Frame class, and would still be useful. It sounds a bit more like Galactocentric, which uses an AffineTransform instead of a MatrixTransform.

    So, I would vote for turning this issue into 2:

    • Fix docstring of SkyOffsetFrame to indicate that distance information in the origin is ignored, and not intended to be used.
    • Create a new frame class that is like a hybrid between SkyOffset and Galactocentric.

    Thoughts @eteq?

  4. eteq commented on Oct 24, 2018

    @eteq
    Member

    I'm 👍 to @adrn's suggestion here. The SkyOffsetFrame is oriented towards the "that's the way my telescope is pointed" use case, which implicitly means that the "distance" part of the origin shouldn't change. That's implicit in the "sky" part of the name but definitely needs to be cleared up in the docs!

    I'm going to rename this issue to be the second of these (since it's more useful to have @Juanlu001's sleuthing above in that issue), and make a separate one for the first/docstring suggestion.

  5. changed the title [-]SkyOffsetFrame objects do not use distance information[/-] [+]Implement a DistanceOffsetFrame that's like SkyOffsetFrame but includes distance effects[/+] on Oct 24, 2018
  6. eteq commented on Oct 24, 2018

    @eteq
    Member

    (Note that I'm not necessarily advocating DistanceOffsetFrame as the name... not sure what the best name is. Just a "working title")

  7. added this to the v3.2 milestone on Oct 24, 2018
  8. eteq commented on Oct 24, 2018

    @eteq
    Member

    @Juanlu001 - I've not milestoned this v3.1 because I don't think @adrn or I have the time to work on this for feature freeze... but if you think you can do it in the next couple days I'd be happy to have it in! (But I realize that might be a big ask depending on how complex it turns out to be.)

  9. removed this from the v3.2 milestone on Oct 24, 2018
  10. astrojuanlu commented on Oct 24, 2018

    @astrojuanlu
    MemberAuthor

    It's a bit short notice, so I prefer to leave it for the next release. Thanks @eteq!

  11. added this to the v3.2 milestone on Dec 5, 2018
  12. bsipocz commented on Apr 17, 2019

    @bsipocz
    Member

    @Juanlu001 - I suppose you're not against removing the milestone here? (technically there are still 3 days until feature freeze, but I suspect you have enough on your plate already).

  13. astrojuanlu commented on Apr 17, 2019

    @astrojuanlu
    MemberAuthor

    Sure, let's postpone it! Thanks @bsipocz

  14. removed this from the v3.2 milestone on Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions