Skip to content

Commit 9c1f7db

Browse files
committed
BUG: Fix string radius/width case
1 parent 79075b1 commit 9c1f7db

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

astroquery/ipac/irsa/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"""
99

1010
import warnings
11-
from astropy.coordinates import SkyCoord
11+
from astropy.coordinates import SkyCoord, Angle
1212
from astropy import units as u
1313
from astropy.utils.decorators import deprecated_renamed_argument
1414
from pyvo.dal import TAPService
@@ -131,10 +131,15 @@ def query_region(self, coordinates=None, *, catalog=None, spatial='Cone',
131131
else:
132132
coords_icrs = parse_coordinates(coordinates).icrs
133133
ra, dec = coords_icrs.ra.deg, coords_icrs.dec.deg
134+
134135
if spatial == 'Cone':
136+
if isinstance(radius, str):
137+
radius = Angle(radius)
135138
where = (" WHERE CONTAINS(POINT('ICRS',ra,dec),"
136139
f"CIRCLE('ICRS',{ra},{dec},{radius.to(u.deg).value}))=1")
137140
elif spatial == 'Box':
141+
if isinstance(width, str):
142+
width = Angle(width)
138143
where = (" WHERE CONTAINS(POINT('ICRS',ra,dec),"
139144
f"BOX('ICRS',{ra},{dec},{width.to(u.deg).value},{width.to(u.deg).value}))=1")
140145
else:

astroquery/ipac/irsa/tests/test_irsa.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import pytest
44
from astropy.coordinates import SkyCoord
5-
from astropy.table import Table
65
import astropy.units as u
76

87
from astroquery.ipac.irsa import Irsa
@@ -11,10 +10,13 @@
1110
OBJ_LIST = ["00h42m44.330s +41d16m07.50s",
1211
SkyCoord(l=121.1743 * u.deg, b=-21.5733 * u.deg, frame="galactic")]
1312

13+
SIZE_LIST = [2 * u.arcmin, '0d2m0s']
1414

15-
@pytest.mark.parametrize(("coordinates"), OBJ_LIST)
16-
def test_query_region_cone(coordinates):
17-
query = Irsa.query_region(coordinates, catalog='fp_psc', spatial='Cone', radius=2 * u.arcmin,
15+
16+
@pytest.mark.parametrize("coordinates", OBJ_LIST)
17+
@pytest.mark.parametrize("radius", SIZE_LIST)
18+
def test_query_region_cone(coordinates, radius):
19+
query = Irsa.query_region(coordinates, catalog='fp_psc', spatial='Cone', radius=radius,
1820
get_query_payload=True)
1921

2022
# We don't fully float compare in this string, there are slight differences due to the name-coordinate
@@ -24,13 +26,15 @@ def test_query_region_cone(coordinates):
2426
assert ",0.0333" in query
2527

2628

27-
@pytest.mark.skip("Upstream TAP doesn't support Box geometry yet")
2829
@pytest.mark.parametrize("coordinates", OBJ_LIST)
29-
def test_query_region_box(coordinates):
30-
result = Irsa.query_region(
31-
coordinates, catalog='fp_psc', spatial='Box', width=2 * u.arcmin)
30+
@pytest.mark.parametrize("width", SIZE_LIST)
31+
def test_query_region_box(coordinates, width):
32+
query = Irsa.query_region(coordinates, catalog='fp_psc', spatial='Box', width=2 * u.arcmin,
33+
get_query_payload=True)
3234

33-
assert isinstance(result, Table)
35+
assert "SELECT * FROM fp_psc WHERE CONTAINS(POINT('ICRS',ra,dec),BOX('ICRS',10.68" in query
36+
assert ",41.26" in query
37+
assert ",0.0333" in query
3438

3539

3640
poly1 = [SkyCoord(ra=10.1 * u.deg, dec=10.1 * u.deg),

0 commit comments

Comments
 (0)