Skip to content

Give option for coordinate preferred units #6184

Open

Description

@mhvk

Currently, coordinate.ra auto-converts to deg -- it should be possible to have the units remain those input by the user -- see #4903 -- the conclusion after discussion was that this will have to be an option, so that we do not break back-compatibility.

My current thought:

  • SkyCoord gains a formatter, with a format defined via strings, similar to Time (and possibly with similar format classes that do the parsing of the coordinates). repr uses this formatter.
  • The default format remains deg,deg (or whatever would indicate that), but this would be inferred from a configuration item, which could also be something to indicate "infer from input" (again, a bit like Time)

Activity

  1. taldcroft commented on Jun 12, 2017

    @taldcroft
    Member

    One minor problem with this is that the input for SkyCoord is so flexible and so actually retaining the units and format of the original data is not practical:

    In [16]: c = SkyCoord(['1d2m', 1*u.deg, 1*u.hourangle], ['1d', 1*u.radian, 1*u.deg])
    
    In [17]: c
    Out[17]: 
    <SkyCoord (ICRS): (ra, dec) in deg
        [(  1.03333333,   1.        ), (  1.        ,  57.29577951),
         ( 15.        ,   1.        )]>
    

    One could stipulate that it will use the unit of the first element for the rest.

    But in general adding a keyword to disable using preferred units would be fine.

  2. mhvk commented on Jun 12, 2017

    @mhvk
    ContributorAuthor

    @taldcroft - my preference would be to go towards a model like Time, perhaps even including format classes (though we wouldn't necessarily want to store data on those); I edited my top comment to reflect that.

  3. eteq commented on Jun 16, 2017

    @eteq
    Member

    I'm receptive to the idea of something like format classes - that would probably be a fairly minor perturbation on the "recommended units" machinery that already exists (and hopefully even make that easier to understand). To maintain backwards compatibility I think we have to stick with the default being what we've done thus far... But give users the power to override them.

    An important high-level question, though, is where these formatters would live. The recommended units currently live in the representations... and that's probably where the machinery should be for something more flexible. But the user-level selection (and state of which frame is the right one) should be at a higher level. I think probably the frame level is best because that's already where the choice of representation class is set statefully?

  4. added this to the v3.0.0 milestone on Jun 16, 2017
  5. eteq commented on Jun 16, 2017

    @eteq
    Member

    (Also, I tentatively milestoned this for 3.0, meaning either actually doing it, or agreeing not to do it)

  6. mhvk commented on Jun 16, 2017

    @mhvk
    ContributorAuthor

    OK, sounds good. Note that I'd like to remove recommended_unit from representations, since I think their functionality does not need (nor use) it at all -- your suggestion of having it on the frame seems the right one.
    Anyway, (well) after 2.0...

  7. removed this from the v3.0.0 milestone on Jan 23, 2018
  8. mhvk commented on Jan 23, 2018

    @mhvk
    ContributorAuthor

    Just as an update on the above: recommended_unit has been removed from the representations (#6858); that now all lives on the frames. Arguably, frames are the right place for any changes, as that is also where the current copying of data for representation in degrees gets done.

  9. maxnoe commented on May 12, 2021

    @maxnoe
    Member

    @mhvk wouldn't it also help performance if the default transformation was to rad? I imagine this would make many transformations later for trigonometric functions unnecessary.

  10. mhvk commented on May 12, 2021

    @mhvk
    ContributorAuthor

    @maxnoe - the issue is specifically about how sc.ra and sc.dec look, which are currently calculated from the representation. Nevertheless, you are right that if the representation itself was in radian, things would be a bit faster. In principle, even now you can do that by ensuring your inputs are in radian already. I'd guess, though, that the speed is likely limited by conversion to Cartesian, etc. (so, perhaps one should input cartesian representations for maximum speed?!).

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