-
-
Notifications
You must be signed in to change notification settings - Fork 412
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
Fixed failing PANSTARRS Catalog
queries
#2727
Changes from all commits
8af6d40
9718c79
b4ccc43
c42dd7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,7 +288,27 @@ def service_request_async(self, service, params, page_size=None, page=None, use_ | |
catalogs_request.extend(self._build_catalogs_params(params)) | ||
else: | ||
headers['Content-Type'] = 'application/json' | ||
catalogs_request = params | ||
|
||
# Parameter syntax needs to be updated only for PANSTARRS catalog queries | ||
if service.lower() == 'panstarrs': | ||
catalogs_request.extend(self._build_catalogs_params(params)) | ||
|
||
# After parameter syntax is updated, revert back to dictionary | ||
# so params can be passed as a JSON dictionary | ||
params_dict = {} | ||
for key, val in catalogs_request: | ||
params_dict.setdefault(key, []).append(val) | ||
catalogs_request = params_dict | ||
|
||
# Removing single-element lists. Single values will live on their own (except for `sort_by`) | ||
for key in catalogs_request.keys(): | ||
if (key != 'sort_by') & (len(catalogs_request[key]) == 1): | ||
catalogs_request[key] = catalogs_request[key][0] | ||
|
||
# Otherwise, catalogs_request can remain as the original params dict | ||
else: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This |
||
catalogs_request = params | ||
|
||
response = self._request('POST', request_url, data=catalogs_request, headers=headers, use_json=use_json) | ||
return response | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,6 +691,17 @@ def test_catalogs_query_criteria(self): | |
assert isinstance(result, Table) | ||
assert 'PSO J254.2861-04.1091' in result['objName'] | ||
|
||
result = mast.Catalogs.query_criteria(coordinates="158.47924 -7.30962", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the unit test, I'm using one of the queries that was reported to fail by one of our users. It includes the |
||
radius=0.01, | ||
catalog="PANSTARRS", | ||
table="mean", | ||
data_release="dr2", | ||
nStackDetections=[("gte", "1")], | ||
columns=["objName", "distance"], | ||
sort_by=[("asc", "distance")]) | ||
assert isinstance(result, Table) | ||
assert result['distance'][0] <= result['distance'][1] | ||
|
||
def test_catalogs_query_hsc_matchid_async(self): | ||
catalogData = mast.Catalogs.query_object("M10", | ||
radius=.001, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call updates the syntax of the parameters so it's readable in the backend. It needs to be made here so that users can add criteria decorators to their PANSTARRS queries, despite it being an API that requires params to be passed as JSON. It returns the params in list format, so I then have to convert it back to dictionary so that it can be dumped as a JSON dict later in the request.