Repository navigation
Closed
Labels
Effort LowRequires a small time investment.Requires a small time investment.Package IntermediateRequires good technical knowledge of the package.Requires good technical knowledge of the package.Priority LowRapid action not required.Rapid action not required.coordinatesAffects the coordinates submoduleAffects the coordinates submodule
Description
>>> 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`.
Metadata
Metadata
Assignees
Labels
Effort LowRequires a small time investment.Requires a small time investment.Package IntermediateRequires good technical knowledge of the package.Requires good technical knowledge of the package.Priority LowRapid action not required.Rapid action not required.coordinatesAffects the coordinates submoduleAffects the coordinates submodule
Activity
Cadair commentedon Jun 3, 2020
ping @ayshih @samaloney
ayshih commentedon Jun 3, 2020
The workarounds are:
obstimefor the destination frame:HeliographicStonyhurst(obstime=hee.obstime)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 asobstimeas 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 noobstimeattribute. That's why theobstimeisn't carried through.ayshih commentedon Jun 3, 2020
Hmm! I think I have an idea for an "easy" fix...
ayshih commentedon Jun 5, 2020
I actually was wrong here.
obstimeisn't carried through because only our transformations in SunPy internally preserve it (we copy it over when the destination frame hasobstime=None). When you cross between the two subgraphs, we depend on Astropy transformations, and theobstimegets 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 usingSkyCoord.ayshih commentedon Sep 2, 2020
I'm closing this issue. The bug is now avoided for the automatic transformation triggered by the
observerframe attribute (#4266), and this style of transformation call is now deprecated (astropy/astropy#10475).