Skip to content

Commit 091b987

Browse files
author
C. E. Brasseur
authored
Merge pull request #2258 from nmcardoso/fix-query_crossid_async
Fix SDSS CrossID method not working for spec data and for DR17 (photo and spec)
2 parents 5644067 + 0eaa824 commit 091b987

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

astroquery/sdss/core.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def query_crossid_async(self, coordinates, obj_names=None,
8181
radius : str or `~astropy.units.Quantity` object, optional The
8282
string must be parsable by `~astropy.coordinates.Angle`. The
8383
appropriate `~astropy.units.Quantity` object from
84-
`astropy.units` may also be used. Defaults to 2 arcsec.
84+
`astropy.units` may also be used. Defaults to 5 arcsec.
8585
timeout : float, optional
8686
Time limit (in seconds) for establishing successful connection with
8787
remote server. Defaults to `SDSSClass.TIMEOUT`.
@@ -144,7 +144,10 @@ def query_crossid_async(self, coordinates, obj_names=None,
144144

145145
sql_query += ',dbo.fPhotoTypeN(p.type) as type \
146146
FROM #upload u JOIN #x x ON x.up_id = u.up_id \
147-
JOIN PhotoObjAll p ON p.objID = x.objID ORDER BY x.up_id'
147+
JOIN PhotoObjAll p ON p.objID = x.objID '
148+
if specobj_fields:
149+
sql_query += 'JOIN SpecObjAll s ON p.objID = s.bestObjID '
150+
sql_query += 'ORDER BY x.up_id'
148151

149152
data = "obj_id ra dec \n"
150153
data += " \n ".join(['{0} {1} {2}'.format(obj_names[i],
@@ -165,7 +168,7 @@ def query_crossid_async(self, coordinates, obj_names=None,
165168
if get_query_payload:
166169
return request_payload
167170
url = self._get_crossid_url(data_release)
168-
response = self._request("POST", url, params=request_payload,
171+
response = self._request("POST", url, data=request_payload,
169172
timeout=timeout, cache=cache)
170173
return response
171174

astroquery/sdss/tests/test_sdss_remote.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,16 @@ def test_query_crossid(self):
174174

175175
assert isinstance(query2, Table)
176176
assert query2['objID'][0] == query1['objID'][0] == query2['objID'][1]
177+
178+
def test_spectro_query_crossid(self):
179+
query1 = sdss.SDSS.query_crossid_async(
180+
self.coords, specobj_fields=['specObjID', 'z'], cache=False)
181+
query2 = sdss.SDSS.query_crossid_async(
182+
[self.coords, self.coords],
183+
specobj_fields=['specObjID', 'z'],
184+
cache=False)
185+
assert isinstance(query1, Table)
186+
assert query1['specObjID'][0] == 845594848269461504
187+
188+
assert isinstance(query2, Table)
189+
assert query2['specObjID'][0] == query2['specObjID'][1] == query1['specObjID'][0]

0 commit comments

Comments
 (0)