Repository navigation
Closed
Labels
Description
In V1.3.1 the SkyCoord class will refuse to perform transformations that I think ought to be possible, e.g.
from astropy.coordinates import EarthLocation, SkyCoord, get_moon
import astropy.units as u
from astropy.time import Time
import numpy as np
greenwich = EarthLocation.of_site('greenwich')
times = Time("2017-03-20T12:00:00") + np.linspace(-2,2,3)*u.hour
moon = get_moon(times, location=greenwich)
targets = SkyCoord([350.7*u.deg, 260.7*u.deg], [18.4*u.deg, 22.4*u.deg])
targets.transform_to(moon[:,np.newaxis])produces
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-10-327087abec51> in <module>()
----> 1 targets.transform_to(moon[:,np.newaxis])
/Users/sl/anaconda3/lib/python3.6/site-packages/astropy/coordinates/sky_coordinate.py in transform_to(self, frame, merge_attributes)
452 # We could remove overlaps here, but the init code is set up to accept
453 # overlaps as long as the values are identical (which they must be).
--> 454 return self.__class__(new_coord, **frame_kwargs)
455
456 def __getattr__(self, attr):
/Users/sl/anaconda3/lib/python3.6/site-packages/astropy/coordinates/sky_coordinate.py in __init__(self, *args, **kwargs)
210 args = list(args) # Make it mutable
211 copy = kwargs.pop('copy', True)
--> 212 kwargs = self._parse_inputs(args, kwargs)
213
214 # Set internal versions of object state attributes
/Users/sl/anaconda3/lib/python3.6/site-packages/astropy/coordinates/sky_coordinate.py in _parse_inputs(self, args, kwargs)
358 raise ValueError("Coordinate attribute '{0}'={1!r} conflicts with "
359 "keyword argument '{0}'={2!r}"
--> 360 .format(attr, coord_value, valid_kwargs[attr]))
361 valid_kwargs[attr] = coord_value
362
ValueError: Coordinate attribute 'obsgeoloc'=<CartesianRepresentation (x, y, z) in m
[[( 3380626.24081659, -2114946.52919111, 4961181.87025111),
( 3380626.24081659, -2114946.52919111, 4961181.87025111)],
[( 3986386.39265932, -139720.62235739, 4960258.04040856),
( 3986386.39265932, -139720.62235739, 4960258.04040856)],
[( 3520492.65007889, 1873089.76476866, 4961111.20464583),
( 3520492.65007889, 1873089.76476866, 4961111.20464583)]]> conflicts with keyword argument 'obsgeoloc'=<CartesianRepresentation (x, y, z) in m
[( 3380626.24081659, -2114946.52919111, 4961181.87025111),
( 3986386.39265932, -139720.62235739, 4960258.04040856),
( 3520492.65007889, 1873089.76476866, 4961111.20464583)]>the transform fails since the check for attribute conflicts looks for strict equality. However, in this case one is a broadcastable to the other, so I believe this transformation ought to be possible.
Activity
bsipocz commentedon Mar 21, 2017
I see this on master, too.
mhvk commentedon Mar 21, 2017
See #5897 for a simpler fix.
mhvk commentedon Mar 24, 2017
Fixed by #5897