I am trying to convert velocity from LSRK to ICRS (or any other frame), following the example in https://docs.astropy.org/en/stable/coordinates/velocities.html#. However, an exception is raised in SkyCoord.transform_to(). I would appreciate some help in understanding where I’m going wrong.
Astropy version: ‘5.2.2’
Minimum failing example:
from astropy.coordinates import SkyCoord, LSRK, ICRS
import astropy.units as u
mysource = SkyCoord(‘04h21m59.43s +19d32m06.4’, frame=LSRK, radial_velocity=25* u.km / u.s)
mysource.transform_to(ICRS())
The exception is:
TypeError: Position information stored on coordinate frame is insufficient to do a full-space position transformation (representation class: {data.class})
Full traceback:
TypeError Traceback (most recent call last)
Cell In[1], line 4
2 import astropy.units as u
3 mysource = SkyCoord(‘04h21m59.43s +19d32m06.4’, frame=LSRK, radial_velocity=25* u.km / u.s)
----> 4 mysource.transform_to(ICRS())
File ~/Anaconda3-2023.03/lib/python3.10/site-packages/astropy/coordinates/sky_coordinate.py:702, in SkyCoord.transform_to(self, frame, merge_attributes)
698 generic_frame = GenericFrame(frame_kwargs)
700 # Do the transformation, returning a coordinate frame of the desired
701 # final type (not generic).
→ 702 new_coord = trans(self.frame, generic_frame)
704 # Finally make the new SkyCoord object from the new_coord
and
705 # remaining frame_kwargs that are not frame_attributes in new_coord
.
706 for attr in set(new_coord.frame_attributes) & set(frame_kwargs.keys()):
File ~/Anaconda3-2023.03/lib/python3.10/site-packages/astropy/coordinates/transformations.py:1579, in CompositeTransform.call(self, fromcoord, toframe)
1576 frattrs[inter_frame_attr_nm] = attr
1578 curr_toframe = t.tosys(**frattrs)
→ 1579 curr_coord = t(curr_coord, curr_toframe)
1581 # this is safe even in the case where self.transforms is empty, because
1582 # coordinate objects are immutable, so copying is not needed
1583 return curr_coord
File ~/Anaconda3-2023.03/lib/python3.10/site-packages/astropy/coordinates/transformations.py:1341, in BaseAffineTransform.call(self, fromcoord, toframe)
1339 def call(self, fromcoord, toframe):
1340 params = self._affine_params(fromcoord, toframe)
→ 1341 newrep = self._apply_transform(fromcoord, *params)
1342 return toframe.realize_frame(newrep)
File ~/Anaconda3-2023.03/lib/python3.10/site-packages/astropy/coordinates/transformations.py:1194, in BaseAffineTransform._apply_transform(self, fromcoord, matrix, offset)
1191 # Some initial checking to short-circuit doing any re-representation if
1192 # we’re going to fail anyways:
1193 if isinstance(data, UnitSphericalRepresentation) and offset is not None:
→ 1194 raise TypeError(
1195 “Position information stored on coordinate frame "
1196 “is insufficient to do a full-space position "
1197 “transformation (representation class: {data.class})”
1198 )
1200 elif (
1201 has_velocity
1202 and (unit_vel_diff or rad_vel_diff)
(…)
1206 # Coordinate has a velocity, but it is not a full-space velocity
1207 # that we need to do a velocity offset
1208 raise TypeError(
1209 “Velocity information stored on coordinate frame is insufficient to do”
1210 " a full-space velocity transformation (differential class:”
1211 f” {data.differentials[‘s’].class})"
1212 )
TypeError: Position information stored on coordinate frame is insufficient to do a full-space position transformation (representation class: {data.class})