Skip to content

Commit 15fab51

Browse files
authored
Merge pull request #2305 from bsipocz/large_crossid_queries
Large crossid queries
2 parents 843f9da + 2a4befe commit 15fab51

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ New Tools and Services
77

88
Service fixes and enhancements
99
------------------------------
10+
1011
casda
1112
^^^^^
1213

@@ -44,6 +45,8 @@ sdss
4445

4546
- Fix ``query_crossid`` for spectral data and DR17. [#2258, #2304]
4647

48+
- Fix ``query_crossid`` to be able to query larger list of coordinates. [#2305]
49+
4750

4851
Infrastructure, Utility and Other Changes and Additions
4952
-------------------------------------------------------

astroquery/sdss/core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ def query_crossid_async(self, coordinates, obj_names=None,
156156
for i in range(len(coordinates))])
157157

158158
# firstcol is hardwired, as obj_names is always passed
159-
request_payload = dict(uquery=sql_query, paste=data,
159+
files = {'upload': ('astroquery', data)}
160+
request_payload = dict(uquery=sql_query,
160161
firstcol=1,
161162
format='csv', photoScope='nearPrim',
162163
radius=radius,
@@ -166,9 +167,11 @@ def query_crossid_async(self, coordinates, obj_names=None,
166167
request_payload['searchtool'] = 'CrossID'
167168

168169
if get_query_payload:
169-
return request_payload
170+
return request_payload, files
171+
170172
url = self._get_crossid_url(data_release)
171173
response = self._request("POST", url, data=request_payload,
174+
files=files,
172175
timeout=timeout, cache=cache)
173176
return response
174177

astroquery/sdss/tests/test_sdss_remote.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from numpy.testing import assert_allclose
44
import pytest
55

6-
from astropy import coordinates
6+
from astropy.coordinates import SkyCoord
77
from astropy.table import Table
88

99
from urllib.error import URLError
@@ -18,9 +18,17 @@
1818
@pytest.mark.remote_data
1919
class TestSDSSRemote:
2020
# Test Case: A Seyfert 1 galaxy
21-
coords = coordinates.SkyCoord('0h8m05.63s +14d50m23.3s')
21+
coords = SkyCoord('0h8m05.63s +14d50m23.3s')
2222
mintimeout = 1e-2
2323

24+
@pytest.fixture()
25+
def large_results(self):
26+
# Large list of objects for regression tests
27+
query = "select top 1000 z, ra, dec, bestObjID from specObj where class = 'galaxy' and programname = 'eboss'"
28+
results = sdss.SDSS.query_sql(query)
29+
coords_large = SkyCoord(ra=results['ra'], dec=results['dec'], unit='deg')
30+
return coords_large
31+
2432
def test_images_timeout(self):
2533
"""
2634
This test *must* be run before `test_sdss_image` because that query
@@ -191,3 +199,9 @@ def test_spectro_query_crossid(self, dr):
191199

192200
assert isinstance(query2, Table)
193201
assert query2['specObjID'][0] == query2['specObjID'][1] == query1['specObjID'][0]
202+
203+
def test_large_crossid(self, large_results):
204+
# Regression test for #589
205+
206+
results = sdss.SDSS.query_crossid(large_results)
207+
assert len(results) == 894

0 commit comments

Comments
 (0)