Skip to content

Commit

Permalink
Merge pull request #2585 from bsipocz/alma_get_query_payload
Browse files Browse the repository at this point in the history
ENH: get_query_payload to return useful info
  • Loading branch information
bsipocz authored Nov 16, 2022
2 parents 8d63241 + 09bd956 commit 065ea83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit 065ea83

Please sign in to comment.