Skip to content

HeliocentricEarthEcliptic frame does not copy obstime when transforming to HGS #4237

Closed

Description

@Cadair
>>> hee = HeliocentricEarthEcliptic(45*u.deg, 35*u.deg, 17*u.km, obstime="2020-01-01") 
>>> hee.transform_to(HeliographicStonyhurst) 
---------------------------------------------------------------------------
ConvertError                              Traceback (most recent call last)
<ipython-input-39-8ab95e21b2a5> in <module>
      1 hee = HeliocentricEarthEcliptic(45*u.deg, 35*u.deg, 17*u.km, obstime="2020-01-01")
----> 2 hee.transform_to(HeliographicStonyhurst)

~/.virtualenvs/ndcube-dev/lib/python3.8/site-packages/astropy/coordinates/baseframe.py in transform_to(self, new_frame)
   1196             msg = 'Cannot transform from {0} to {1}'
   1197             raise ConvertError(msg.format(self.__class__, new_frame.__class__))
-> 1198         return trans(self, new_frame)
   1199 
   1200     def is_transformable_to(self, new_frame):

~/.virtualenvs/ndcube-dev/lib/python3.8/site-packages/astropy/coordinates/transformations.py in __call__(self, fromcoord, toframe)
   1390 
   1391             curr_toframe = t.tosys(**frattrs)
-> 1392             curr_coord = t(curr_coord, curr_toframe)
   1393 
   1394         # this is safe even in the case where self.transforms is empty, because

~/.virtualenvs/ndcube-dev/lib/python3.8/site-packages/astropy/coordinates/transformations.py in __call__(self, fromcoord, toframe)
   1208     def __call__(self, fromcoord, toframe):
   1209 
-> 1210         M, vec = self.transform_func(fromcoord, toframe)
   1211         newrep = self._apply_transform(fromcoord, M, vec)
   1212 

~/.virtualenvs/ndcube-dev/lib/python3.8/site-packages/sunpy/coordinates/transformations.py in wrapped_func(*args, **kwargs)
    174                 _layer_level += 1
    175 
--> 176             result = func(*args, **kwargs)
    177 
    178             if debug_output:

~/.virtualenvs/ndcube-dev/lib/python3.8/site-packages/sunpy/coordinates/transformations.py in hcrs_to_hgs(hcrscoord, hgsframe)
    541     """
    542     if hgsframe.obstime is None:
--> 543         raise ConvertError("To perform this transformation, the coordinate"
    544                            " frame needs a specified `obstime`.")
    545 

ConvertError: To perform this transformation, the coordinate frame needs a specified `obstime`.

Activity

  1. Cadair commented on Jun 3, 2020

    @Cadair
    SponsorMemberAuthor
  2. ayshih commented on Jun 3, 2020

    @ayshih
    Member

    The workarounds are:

    • Explicitly specify the obstime for the destination frame: HeliographicStonyhurst(obstime=hee.obstime)
    • Use Skycoord: e.g., SkyCoord(hee)

    Of course, these workarounds may not be possible to implement in certain situations.

    The issue is that transformations between frames, when not using SkyCoord, do not propagate frame attributes such as obstime as aggressively. Everything works fine between SunPy frames as long as you stick to one of our two branches: the HGS/HGC/HCI/HCC/HPC branch or the HEE/GSE/GEI branch. However, when you cross between those two branches, as you are doing here, the transformations step through ICRS, which has no obstime attribute. That's why the obstime isn't carried through.

  3. ayshih commented on Jun 3, 2020

    @ayshih
    Member

    Hmm! I think I have an idea for an "easy" fix...

  4. ayshih commented on Jun 5, 2020

    @ayshih
    Member

    However, when you cross between those two branches, as you are doing here, the transformations step through ICRS, which has no obstime attribute. That's why the obstime isn't carried through.

    I actually was wrong here. obstime isn't carried through because only our transformations in SunPy internally preserve it (we copy it over when the destination frame has obstime=None). When you cross between the two subgraphs, we depend on Astropy transformations, and the obstime gets dropped because it isn't carried through at all, and depends only on how it is defined at the destination frame.

    I've just put up a PR to Astropy (astropy/astropy#10453) to fix the transform_to() behavior to be more like when using SkyCoord.

  5. added
    Effort LowRequires a small time investment.
    Package IntermediateRequires good technical knowledge of the package.
    Priority LowRapid action not required.
    and removed on Jul 11, 2020
  6. ayshih commented on Sep 2, 2020

    @ayshih
    Member

    I'm closing this issue. The bug is now avoided for the automatic transformation triggered by the observer frame attribute (#4266), and this style of transformation call is now deprecated (astropy/astropy#10475).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Effort LowRequires a small time investment.Package IntermediateRequires good technical knowledge of the package.Priority LowRapid action not required.coordinatesAffects the coordinates submodule

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions