Skip to content

Commit a1eb3b4

Browse files
committed
add test and documentation to query_region
1 parent 4058829 commit a1eb3b4

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

astroquery/esa/hsa/core.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,16 +398,7 @@ def query_observations(self, coordinate, radius, *, n_obs=10, **kwargs):
398398
-------
399399
A table object with the list of observations in the region
400400
"""
401-
r = radius
402-
if not isinstance(radius, u.Quantity):
403-
r = radius*u.deg
404-
coord = commons.parse_coordinates(coordinate).icrs
405-
406-
query = (f"select top {n_obs} observation_id from hsa.v_active_observation "
407-
f"where contains("
408-
f"point('ICRS', hsa.v_active_observation.ra, hsa.v_active_observation.dec), "
409-
f"circle('ICRS', {coord.ra.degree},{coord.dec.degree},{r.to(u.deg).value}))=1")
410-
return self.query_hsa_tap(query, **kwargs)
401+
return self.query_region(coordinate, radius, n_obs=n_obs, columns="observation_id", **kwargs)
411402

412403
def query_region(self, coordinate, radius, *, n_obs=10, columns='*', **kwargs):
413404
"""

astroquery/esa/hsa/tests/test_hsa.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,12 @@ def test_query_observations(self):
5757
hsa = HSAClass(self.get_dummy_tap_handler())
5858
hsa.query_observations(**parameters)
5959
dummyTapHandler.check_call("query_observations", parameters)
60+
61+
def test_query_region(self):
62+
c = SkyCoord(ra=100.2417*u.degree, dec=9.895*u.degree, frame='icrs')
63+
parameters = {'coordinate': c,
64+
'radius': 0.5}
65+
dummyTapHandler = DummyHSATapHandler("query_region", parameters)
66+
hsa = HSAClass(self.get_dummy_tap_handler())
67+
hsa.query_region(**parameters)
68+
dummyTapHandler.check_call("query_region", parameters)

docs/esa/hsa.rst

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,31 @@ This will show the available tables in HSA TAP service in the Herschel Science A
145145
This will show the column details of the table 'hsa.v_active_observation' in HSA TAP service in the Herschel Science Archive.
146146

147147

148-
7. Query Observations
148+
7. Query Region
149+
---------------
150+
151+
.. doctest-skip::
152+
153+
>>> from astroquery.esa.hsa import HSA
154+
>>> from astropy.coordinates import SkyCoord
155+
>>> from astropy import units as u
156+
>>>
157+
>>> c = SkyCoord(ra=100.2417*u.degree, dec=9.895*u.degree, frame='icrs')
158+
>>> result = HSA.query_region(c, 0.5)
159+
>>> result.pprint(max_width=100)
160+
aor bii ... target_name urn_version
161+
...
162+
------------------------------------------- ------------------ ... ---------------- -----------
163+
KPOT_wlanger_1-HPoint-0007 - CII_G202.6+2.0 10.062774289985356 ... CII_G202.6+2.0-1 921022
164+
n2264-o 9.45754288889945 ... NGC2264 919399
165+
n2264-n 9.45754288889945 ... NGC2264 919398
166+
n2264-n 9.450299102175919 ... NGC2264 898497
167+
n2264-o 9.450499719127244 ... NGC2264 898535
168+
169+
Retrieve a VOTable with the observations metadata of a given region
170+
171+
172+
8. Query Observations
149173
---------------------
150174

151175
.. doctest-skip::
@@ -169,7 +193,7 @@ This will show the column details of the table 'hsa.v_active_observation' in HSA
169193
Retrieve a VOTable with the observation IDs of a given region
170194

171195

172-
8. Procedure example
196+
9. Procedure example
173197
--------------------
174198

175199
First retrieve the observation IDs based on a position on the sky. To achive this, query the TAP service.

0 commit comments

Comments
 (0)