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

ENH: get_query_payload to return useful info #2585

Merged
merged 2 commits into from
Nov 16, 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
11 changes: 8 additions & 3 deletions astroquery/alma/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def query_region_async(self, coordinate, radius, *, public=True,
payload=payload, **kwargs)

def query_async(self, payload, *, public=True, science=True,
legacy_columns=False, get_query_payload=None,
legacy_columns=False, get_query_payload=False,
maxrec=None, **kwargs):
"""
Perform a generic query with user-specified payload
Expand Down Expand Up @@ -380,11 +380,16 @@ def query_async(self, payload, *, public=True, science=True,
payload['science_observation'] = science
if public is not None:
payload['public_data'] = public
if get_query_payload:
return payload

query = _gen_sql(payload)

if get_query_payload:
# Return the TAP query payload that goes out to the server rather
# than the unprocessed payload dict from the python side
return query

result = self.query_tap(query, maxrec=maxrec)

if result is not None:
result = result.to_table()
else:
Expand Down
2 changes: 1 addition & 1 deletion astroquery/alma/tests/test_alma.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ def test_galactic_query():
result = alma.query_region(SkyCoord(0*u.deg, 0*u.deg, frame='galactic'),
radius=1*u.deg, get_query_payload=True)

assert result['ra_dec'] == SkyCoord(0*u.deg, 0*u.deg, frame='galactic').icrs.to_string() + ", 1.0"
assert "'ICRS',266.405,-28.9362,1.0" in result


def test_download_files():
Expand Down