Repository navigation
Closed
Labels
BugClose?Tell stale bot that this issue/PR is staleTell stale bot that this issue/PR is stalecoordinates
Milestone
Description
I have followed the example at:
my example/test is:
import astropy
print('astropy.__version__:', astropy.__version__)
from astropy.table import Table
from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.coordinates import match_coordinates_sky
from astroquery.irsa import Irsa
from astroquery.sdss import SDSS
c = SkyCoord(ra=ra1*u.degree, dec=dec1*u.degree, distance=distance1*u.kpc)
catalog = SkyCoord(ra=ra2*u.degree, dec=dec2*u.degree, distance=distance2*u.kpc)
idx, d2d, d3d = c.match_to_catalog_3d(catalog)
matches = catalog[idx]
dra, ddec = c.spherical_offsets_to(matches)
no specfic catalogue is used. In my example I use astroquery as shown below:
region_center = SkyCoord(9.81625*u.deg, 0.88806*u.deg, frame='icrs')
allwise_irsa = Irsa.query_region(coordinates=region_center, radius=4*u.arcmin,
catalog='wise_allwise_p3as_psd')
print('Number of ALLWISE sources:', len(allwise_irsa))
sdss = SDSS.query_region(coordinates=region_center, radius=4*u.arcmin,
spectro=False,
photoobj_fields=['ra','dec','u','g','r','i','z'])
ra = allwise_irsa['ra']
dec = allwise_irsa['dec']
radec_allwise = SkyCoord(ra, dec,unit=(u.degree, u.degree), frame='icrs')
ra = sdss['ra']
dec = sdss['dec']
radec_sdss = SkyCoord(ra, dec,unit=(u.degree, u.degree), frame='icrs')
idx, d2d, d3d = match_coordinates_sky(radec_allwise, radec_sdss)
idx, d2d, d3d = radec_allwise.match_to_catalog_sky(radec_sdss)
print('Number of xmatch sources:', len(idx))
matches = radec_sdss[idx]
print('Test single source')
print(matches[0])
print(radec_allwise[0])
dra, ddec = radec_allwise[0].spherical_offsets_to(matches[0])
print('dra, ddec:', dra.arcsec, ddec.arcsec)
print('Test array')
dra, ddec = radec_allwise.spherical_offsets_to(matches)
I am using astropy 1.2.1
Traceback (most recent call last):
File "spherical_offsets_to_test.py", line 55, in <module>
dra, ddec = radec_allwise.spherical_offsets_to(matches)
File "/home/rgm/anaconda/lib/python2.7/site-packages/astropy/coordinates/sky_coordinate.py", line 747, in spherical_offsets_to
acoord = tocoord.transform_to(aframe)
File "/home/rgm/anaconda/lib/python2.7/site-packages/astropy/coordinates/sky_coordinate.py", line 403, in transform_to
new_coord = trans(self.frame, generic_frame)
File "/home/rgm/anaconda/lib/python2.7/site-packages/astropy/coordinates/transformations.py", line 915, in __call__
curr_coord = t(curr_coord, curr_toframe)
File "/home/rgm/anaconda/lib/python2.7/site-packages/astropy/coordinates/transformations.py", line 833, in __call__
newrep = newrep.represent_as(fromcoord.data.__class__)
File "/home/rgm/anaconda/lib/python2.7/site-packages/astropy/coordinates/representation.py", line 90, in represent_as
return other_class.from_cartesian(self.to_cartesian())
File "/home/rgm/anaconda/lib/python2.7/site-packages/astropy/coordinates/representation.py", line 421, in from_cartesian
s = np.hypot(cart.x, cart.y)
File "/home/rgm/anaconda/lib/python2.7/site-packages/astropy/units/quantity.py", line 753, in __getattr__
attr))
AttributeError: 'Quantity' object has no 'hypot' member`
Metadata
Metadata
Assignees
Labels
BugClose?Tell stale bot that this issue/PR is staleTell stale bot that this issue/PR is stalecoordinates
Activity
mhvk commentedon Jul 8, 2016
This is most bizarre. Is it possible to make a simple example without astroquery? Also, what numpy version are you using?
richardgmcmahon commentedon Jul 8, 2016
OK, I have used raw numpy and get the same error: see below; i have added a test using the arrays for separation and position_angle and theu seem to work; so the problem is specific to spherical_offsets_to.
I have poked around in the traceback but it is not obviuos to me what is causing the error: AttributeError: 'Quantity' object has no 'hypot' member
mhvk commentedon Aug 11, 2016
@richardgmcmahon - I've been slow here, but trying to simplify your example further, I see that
spherical_offsets_tofails for any non-scalarSkyCoord:The problem is that a wrong transformation matrix is created, full of
Quantityobjects. It definitely is higher up than a problem withQuantity...Still investigating further...
mhvk commentedon Aug 11, 2016
OK, this actually happens to be solved already in current master (perhaps somewhat inadvertently...), due to my removal of the use of numpy matrices (#5104). This will be in astropy 1.3, but I don't know whether we now should consider back-porting it to 1.2 (or even 1.0?). @eteq, @astrofrog?
mhvk commentedon Aug 11, 2016
p.s. At the very least we should include some array-shaped test cases, so that we don't regress on this...
eteq commentedon Nov 29, 2016
Given how close 1.3 is, I think we can probably call this closed if it's fixed for 1.3?
spherical_offsets_tois not in 1.0.x, so no need to port it there...eteq commentedon Nov 29, 2016
That is, the actual underlying issue. I created #5163 to implement the regression test @mhvk suggested above.
add regression test for issue from astropy#5163
Merge pull request #5519 from eteq/test-for-5163
eteq commentedon Nov 29, 2016
With #5519 in and passing, I think this is OK to close, so I will do so. But @richardgmcmahon, if you're still seeing the error in the lastest master, feel free to re-open this!