Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cross-id for very old data releases #2318

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ sdss

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

- Fix ``query_crossid`` for very old data releases (< DR10). [#2318]


Infrastructure, Utility and Other Changes and Additions
Expand Down
9 changes: 6 additions & 3 deletions astroquery/sdss/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class SDSSClass(BaseQuery):
QUERY_URL_SUFFIX_DR_OLD = '/dr{dr}/en/tools/search/x_sql.asp'
QUERY_URL_SUFFIX_DR_10 = '/dr{dr}/en/tools/search/x_sql.aspx'
QUERY_URL_SUFFIX_DR_NEW = '/dr{dr}/en/tools/search/x_results.aspx'
XID_URL_SUFFIX_OLD = '/dr{dr}/en/tools/crossid/x_crossid.aspx'
XID_URL_SUFFIX_OLD = '/dr{dr}/en/tools/crossid/x_crossid.asp'
XID_URL_SUFFIX_DR_10 = '/dr{dr}/en/tools/crossid/x_crossid.aspx'
XID_URL_SUFFIX_NEW = '/dr{dr}/en/tools/search/X_Results.aspx'
IMAGING_URL_SUFFIX = ('{base}/dr{dr}/{instrument}/photoObj/frames/'
'{rerun}/{run}/{camcol}/'
Expand Down Expand Up @@ -123,7 +124,7 @@ def query_crossid_async(self, coordinates, obj_names=None,
raise TypeError("radius should be either Quantity or "
"convertible to float.")

sql_query = 'SELECT '
sql_query = 'SELECT\r\n' # Older versions expect the CRLF to be there.

if specobj_fields is None:
if photoobj_fields is None:
Expand Down Expand Up @@ -1078,8 +1079,10 @@ def _get_query_url(self, data_release):
return url

def _get_crossid_url(self, data_release):
if data_release < 11:
if data_release < 10:
suffix = self.XID_URL_SUFFIX_OLD
elif data_release == 10:
suffix = self.XID_URL_SUFFIX_DR_10
else:
suffix = self.XID_URL_SUFFIX_NEW

Expand Down
4 changes: 3 additions & 1 deletion astroquery/sdss/tests/test_sdss.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ def url_tester(data_release):


def url_tester_crossid(data_release):
if data_release < 11:
if data_release < 10:
baseurl = 'http://skyserver.sdss.org/dr{}/en/tools/crossid/x_crossid.asp'
if data_release == 10:
baseurl = 'http://skyserver.sdss.org/dr{}/en/tools/crossid/x_crossid.aspx'
if data_release == 11:
return
Expand Down
6 changes: 2 additions & 4 deletions astroquery/sdss/tests/test_sdss_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,7 @@ def test_query_non_default_field(self):
assert query1.colnames == ['r', 'psfMag_r']
assert query2.colnames == ['ra', 'dec', 'r']

# crossid doesn't work for DR<10, remove limitation once #2303 is fixed
@pytest.mark.parametrize("dr", dr_list[2:])
@pytest.mark.parametrize("dr", dr_list)
def test_query_crossid(self, dr):
query1 = sdss.SDSS.query_crossid(self.coords, data_release=dr)
query2 = sdss.SDSS.query_crossid([self.coords, self.coords])
Expand All @@ -185,8 +184,7 @@ def test_query_crossid(self, dr):
assert isinstance(query2, Table)
assert query2['objID'][0] == query1['objID'][0] == query2['objID'][1]

# crossid doesn't work for DR<10, remove limitation once #2303 is fixed
@pytest.mark.parametrize("dr", dr_list[2:])
@pytest.mark.parametrize("dr", dr_list)
def test_spectro_query_crossid(self, dr):
query1 = sdss.SDSS.query_crossid(self.coords,
specobj_fields=['specObjID', 'z'],
Expand Down