Skip to content

Commit eebda9f

Browse files
committed
Utils method to parse coordinates
1 parent b43c5bb commit eebda9f

File tree

5 files changed

+9
-41
lines changed

5 files changed

+9
-41
lines changed

astroquery/mast/collections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from astropy.table import Table, Row
2121

22-
from ..utils import commons, async_to_sync
22+
from ..utils import async_to_sync
2323
from ..utils.class_or_instance import class_or_instance
2424
from ..exceptions import InvalidQueryError, MaxResultsWarning, InputWarning
2525

@@ -204,7 +204,7 @@ def query_region_async(self, coordinates, *, radius=0.2*u.deg, catalog="Hsc",
204204
"""
205205

206206
# Put coordinates and radius into consistent format
207-
coordinates = commons.parse_coordinates(coordinates)
207+
coordinates = utils.parse_coordinates(coordinates)
208208

209209
# if radius is just a number we assume degrees
210210
radius = coord.Angle(radius, u.deg)

astroquery/mast/missions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def query_region_async(self, coordinates, *, radius=3*u.arcmin, limit=5000, offs
219219
self._validate_criteria(**criteria)
220220

221221
# Put coordinates and radius into consistent format
222-
coordinates = commons.parse_coordinates(coordinates)
222+
coordinates = utils.parse_coordinates(coordinates)
223223

224224
# If radius is just a number, assume arcminutes
225225
radius = coord.Angle(radius, u.arcmin)

astroquery/mast/observations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from astroquery import log
2424
from astroquery.mast.cloud import CloudAccess
2525

26-
from ..utils import commons, async_to_sync
26+
from ..utils import async_to_sync
2727
from ..utils.class_or_instance import class_or_instance
2828
from ..exceptions import (InvalidQueryError, RemoteServiceError,
2929
NoResultsWarning, InputWarning)
@@ -234,7 +234,7 @@ def query_region_async(self, coordinates, *, radius=0.2*u.deg, pagesize=None, pa
234234
"""
235235

236236
# Put coordinates and radius into consistent format
237-
coordinates = commons.parse_coordinates(coordinates)
237+
coordinates = utils.parse_coordinates(coordinates)
238238

239239
# if radius is just a number we assume degrees
240240
radius = coord.Angle(radius, u.deg)
@@ -363,7 +363,7 @@ def query_region_count(self, coordinates, *, radius=0.2*u.deg, pagesize=None, pa
363363
"""
364364

365365
# build the coordinates string needed by ObservationsClass._caom_filtered_position
366-
coordinates = commons.parse_coordinates(coordinates)
366+
coordinates = utils.parse_coordinates(coordinates)
367367

368368
# if radius is just a number we assume degrees
369369
radius = coord.Angle(radius, u.deg)

astroquery/mast/tests/test_mast.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,37 +1197,3 @@ def test_zcut_get_cutouts(patch_post, tmpdir):
11971197
assert isinstance(cutout_list, list)
11981198
assert len(cutout_list) == 1
11991199
assert isinstance(cutout_list[0], fits.HDUList)
1200-
1201-
1202-
################
1203-
# Utils tests #
1204-
################
1205-
1206-
1207-
def test_parse_input_location(patch_post):
1208-
# Test with coordinates
1209-
coord = SkyCoord(23.34086, 60.658, unit="deg")
1210-
loc = mast.utils.parse_input_location(coordinates=coord)
1211-
assert isinstance(loc, SkyCoord)
1212-
assert loc.ra == coord.ra
1213-
assert loc.dec == coord.dec
1214-
1215-
# Test with object name
1216-
obj_coord = SkyCoord(124.531756290083, -68.3129998725044, unit="deg")
1217-
loc = mast.utils.parse_input_location(objectname="TIC 307210830")
1218-
assert isinstance(loc, SkyCoord)
1219-
assert loc.ra == obj_coord.ra
1220-
assert loc.dec == obj_coord.dec
1221-
1222-
# Error if both coordinates and object name are provided
1223-
with pytest.raises(InvalidQueryError, match="Only one of objectname and coordinates may be specified"):
1224-
mast.utils.parse_input_location(coordinates=coord, objectname="M101")
1225-
1226-
# Error if neither coordinates nor object name is provided
1227-
with pytest.raises(InvalidQueryError, match="One of objectname and coordinates must be specified"):
1228-
mast.utils.parse_input_location()
1229-
1230-
# Warn if resolver is specified without an object name
1231-
with pytest.warns(InputWarning, match="Resolver is only used when resolving object names"):
1232-
loc = mast.utils.parse_input_location(coordinates=coord, resolver="SIMBAD")
1233-
assert isinstance(loc, SkyCoord)

astroquery/mast/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ def parse_input_location(*, coordinates=None, objectname=None, resolver=None):
216216
Returns
217217
-------
218218
response : `~astropy.coordinates.SkyCoord`
219-
The given coordinates, or object's location as an `~astropy.coordinates.SkyCoord` object.
219+
The given coordinates, or object's location as an `~astropy.coordinates.SkyCoord` object
220+
in the ICRS frame.
220221
"""
221222

222223
# Checking for valid input
@@ -232,6 +233,7 @@ def parse_input_location(*, coordinates=None, objectname=None, resolver=None):
232233
if objectname:
233234
obj_coord = resolve_object(objectname, resolver=resolver)
234235

236+
# Parse coordinates, if given
235237
if coordinates:
236238
obj_coord = commons.parse_coordinates(coordinates)
237239

0 commit comments

Comments
 (0)