Skip to content

Commit 5b8545d

Browse files
authored
Merge pull request #3292 from snbianco/ASB-28279-resolver
Pass in resolver name to MAST query functions
2 parents e849868 + 6ee7784 commit 5b8545d

File tree

13 files changed

+413
-71
lines changed

13 files changed

+413
-71
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ utils.tap
4343
- The method ``upload_table`` accepts file formats accepted by astropy's
4444
``Table.read()``. [#3295]
4545

46+
mast
47+
^^^^
48+
49+
- Added ``resolver`` parameter to query methods to specify the resolver to use when resolving object names to coordinates. [#3292]
50+
51+
- Added ``resolve_all`` parameter to ``MastClass.resolve_object`` to resolve object names and return
52+
coordinates for all available resolvers. [#3292]
53+
4654

4755
Infrastructure, Utility and Other Changes and Additions
4856
-------------------------------------------------------

astroquery/mast/collections.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def query_region_async(self, coordinates, *, radius=0.2*u.deg, catalog="Hsc",
294294

295295
@class_or_instance
296296
def query_object_async(self, objectname, *, radius=0.2*u.deg, catalog="Hsc",
297-
pagesize=None, page=None, version=None, **criteria):
297+
pagesize=None, page=None, version=None, resolver=None, **criteria):
298298
"""
299299
Given an object name, returns a list of catalog entries.
300300
See column documentation for specific catalogs `here <https://mast.stsci.edu/api/v0/pages.html>`__.
@@ -316,11 +316,16 @@ def query_object_async(self, objectname, *, radius=0.2*u.deg, catalog="Hsc",
316316
Can be used to override the default pagesize for (set in configs) this query only.
317317
E.g. when using a slow internet connection.
318318
page : int, optional
319-
Defaulte None.
319+
Default None.
320320
Can be used to override the default behavior of all results being returned
321321
to obtain a specific page of results.
322322
version : int, optional
323323
Version number for catalogs that have versions. Default is highest version.
324+
resolver : str, optional
325+
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
326+
If not specified, the default resolver order will be used. Please see the
327+
`STScI Archive Name Translation Application (SANTA) <https://mastresolver.stsci.edu/Santa-war/>`__
328+
for more information. Default is None.
324329
**criteria
325330
Catalog-specific keyword args.
326331
These can be found in the `service documentation <https://mast.stsci.edu/api/v0/_services.html>`__.
@@ -339,7 +344,7 @@ def query_object_async(self, objectname, *, radius=0.2*u.deg, catalog="Hsc",
339344
response : list of `~requests.Response`
340345
"""
341346

342-
coordinates = utils.resolve_object(objectname)
347+
coordinates = utils.resolve_object(objectname, resolver=resolver)
343348

344349
return self.query_region_async(coordinates,
345350
radius=radius,
@@ -350,7 +355,7 @@ def query_object_async(self, objectname, *, radius=0.2*u.deg, catalog="Hsc",
350355
**criteria)
351356

352357
@class_or_instance
353-
def query_criteria_async(self, catalog, *, pagesize=None, page=None, **criteria):
358+
def query_criteria_async(self, catalog, *, pagesize=None, page=None, resolver=None, **criteria):
354359
"""
355360
Given an set of filters, returns a list of catalog entries.
356361
See column documentation for specific catalogs `here <https://mast.stsci.edu/api/v0/pages.html>`__.
@@ -365,6 +370,11 @@ def query_criteria_async(self, catalog, *, pagesize=None, page=None, **criteria)
365370
page : int, optional
366371
Can be used to override the default behavior of all results being returned to obtain
367372
one specific page of results.
373+
resolver : str, optional
374+
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
375+
If not specified, the default resolver order will be used. Please see the
376+
`STScI Archive Name Translation Application (SANTA) <https://mastresolver.stsci.edu/Santa-war/>`__
377+
for more information. Default is None.
368378
**criteria
369379
Criteria to apply. At least one non-positional criteria must be supplied.
370380
Valid criteria are coordinates, objectname, radius (as in `query_region` and `query_object`),
@@ -395,7 +405,9 @@ def query_criteria_async(self, catalog, *, pagesize=None, page=None, **criteria)
395405
radius = criteria.pop('radius', 0.2*u.deg)
396406

397407
if objectname or coordinates:
398-
coordinates = utils.parse_input_location(coordinates, objectname)
408+
coordinates = utils.parse_input_location(coordinates=coordinates,
409+
objectname=objectname,
410+
resolver=resolver)
399411

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

astroquery/mast/core.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,31 @@ def disable_cloud_dataset(self):
110110
"""
111111
pass
112112

113-
def resolve_object(self, objectname):
113+
def resolve_object(self, objectname, *, resolver=None, resolve_all=False):
114114
"""
115115
Resolves an object name to a position on the sky.
116116
117117
Parameters
118118
----------
119119
objectname : str
120120
Name of astronomical object to resolve.
121+
resolver : str, optional
122+
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
123+
If not specified, the default resolver order will be used. Please see the
124+
`STScI Archive Name Translation Application (SANTA) <https://mastresolver.stsci.edu/Santa-war/>`__
125+
for more information. If ``resolve_all`` is True, this parameter will be ignored. Default is None.
126+
resolve_all : bool, optional
127+
If True, will try to resolve the object name using all available resolvers ("NED", "SIMBAD").
128+
Function will return a dictionary where the keys are the resolver names and the values are the
129+
resolved coordinates. Default is False.
121130
122131
Returns
123132
-------
124-
response : `~astropy.coordinates.SkyCoord`
125-
The sky position of the given object.
133+
response : `~astropy.coordinates.SkyCoord`, dict
134+
If ``resolve_all`` is False, returns a `~astropy.coordinates.SkyCoord` object with the resolved coordinates.
135+
If ``resolve_all`` is True, returns a dictionary where the keys are the resolver names and the values are
136+
`~astropy.coordinates.SkyCoord` objects with the resolved coordinates.
126137
"""
127-
return utils.resolve_object(objectname)
138+
return utils.resolve_object(objectname,
139+
resolver=resolver,
140+
resolve_all=resolve_all)

astroquery/mast/cutouts.py

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __init__(self):
107107
self._service_api_connection.set_service_params(services, "tesscut")
108108

109109
def get_sectors(self, *, coordinates=None, radius=0*u.deg, product='SPOC', objectname=None,
110-
moving_target=False, mt_type=None):
110+
moving_target=False, mt_type=None, resolver=None):
111111
"""
112112
Get a list of the TESS data sectors whose footprints intersect
113113
with the given search area.
@@ -152,6 +152,11 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, product='SPOC', objec
152152
first majorbody is tried and then smallbody if a matching majorbody is not found.
153153
154154
NOTE: If moving_target is supplied, this argument is ignored.
155+
resolver : str, optional
156+
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
157+
If not specified, the default resolver order will be used. Please see the
158+
`STScI Archive Name Translation Application (SANTA) <https://mastresolver.stsci.edu/Santa-war/>`__
159+
for more information. Default is None.
155160
156161
Returns
157162
-------
@@ -187,7 +192,9 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, product='SPOC', objec
187192
else:
188193

189194
# Get Skycoord object for coordinates/object
190-
coordinates = parse_input_location(coordinates, objectname)
195+
coordinates = parse_input_location(coordinates=coordinates,
196+
objectname=objectname,
197+
resolver=resolver)
191198

192199
# If radius is just a number we assume degrees
193200
radius = Angle(radius, u.deg)
@@ -223,7 +230,8 @@ def get_sectors(self, *, coordinates=None, radius=0*u.deg, product='SPOC', objec
223230
return Table(sector_dict)
224231

225232
def download_cutouts(self, *, coordinates=None, size=5, sector=None, product='SPOC', path=".",
226-
inflate=True, objectname=None, moving_target=False, mt_type=None, verbose=False):
233+
inflate=True, objectname=None, moving_target=False, mt_type=None, resolver=None,
234+
verbose=False):
227235
"""
228236
Download cutout target pixel file(s) around the given coordinates with indicated size.
229237
@@ -280,6 +288,11 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, product='SP
280288
first majorbody is tried and then smallbody if a matching majorbody is not found.
281289
282290
NOTE: If moving_target is supplied, this argument is ignored.
291+
resolver : str, optional
292+
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
293+
If not specified, the default resolver order will be used. Please see the
294+
`STScI Archive Name Translation Application (SANTA) <https://mastresolver.stsci.edu/Santa-war/>`__
295+
for more information. Default is None.
283296
284297
Returns
285298
-------
@@ -310,7 +323,9 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, product='SP
310323
else:
311324

312325
# Get Skycoord object for coordinates/object
313-
coordinates = parse_input_location(coordinates, objectname)
326+
coordinates = parse_input_location(coordinates=coordinates,
327+
objectname=objectname,
328+
resolver=resolver)
314329

315330
astrocut_request = f"astrocut?ra={coordinates.ra.deg}&dec={coordinates.dec.deg}"
316331

@@ -359,7 +374,7 @@ def download_cutouts(self, *, coordinates=None, size=5, sector=None, product='SP
359374
return localpath_table
360375

361376
def get_cutouts(self, *, coordinates=None, size=5, product='SPOC', sector=None,
362-
objectname=None, moving_target=False, mt_type=None):
377+
objectname=None, moving_target=False, mt_type=None, resolver=None):
363378
"""
364379
Get cutout target pixel file(s) around the given coordinates with indicated size,
365380
and return them as a list of `~astropy.io.fits.HDUList` objects.
@@ -408,6 +423,11 @@ def get_cutouts(self, *, coordinates=None, size=5, product='SPOC', sector=None,
408423
first majorbody is tried and then smallbody if a matching majorbody is not found.
409424
410425
NOTE: If moving_target is supplied, this argument is ignored.
426+
resolver : str, optional
427+
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
428+
If not specified, the default resolver order will be used. Please see the
429+
`STScI Archive Name Translation Application (SANTA) <https://mastresolver.stsci.edu/Santa-war/>`__
430+
for more information. Default is None.
411431
412432
Returns
413433
-------
@@ -457,7 +477,9 @@ def get_cutouts(self, *, coordinates=None, size=5, product='SPOC', sector=None,
457477
param_dict['product'] = product.upper()
458478

459479
# Get Skycoord object for coordinates/object
460-
coordinates = parse_input_location(coordinates, objectname)
480+
coordinates = parse_input_location(coordinates=coordinates,
481+
objectname=objectname,
482+
resolver=resolver)
461483

462484
param_dict["ra"] = coordinates.ra.deg
463485
param_dict["dec"] = coordinates.dec.deg
@@ -531,7 +553,7 @@ def get_surveys(self, coordinates, *, radius="0d"):
531553
"""
532554

533555
# Get Skycoord object for coordinates/object
534-
coordinates = parse_input_location(coordinates)
556+
coordinates = parse_input_location(coordinates=coordinates)
535557
radius = Angle(radius, u.deg)
536558

537559
params = {"ra": coordinates.ra.deg,
@@ -596,7 +618,7 @@ def download_cutouts(self, coordinates, *, size=5, survey=None, cutout_format="f
596618
Cutout file(s) for given coordinates
597619
"""
598620
# Get Skycoord object for coordinates/object
599-
coordinates = parse_input_location(coordinates)
621+
coordinates = parse_input_location(coordinates=coordinates)
600622
size_dict = _parse_cutout_size(size)
601623

602624
path = os.path.join(path, '')
@@ -675,7 +697,7 @@ def get_cutouts(self, coordinates, *, size=5, survey=None):
675697
"""
676698

677699
# Get Skycoord object for coordinates/object
678-
coordinates = parse_input_location(coordinates)
700+
coordinates = parse_input_location(coordinates=coordinates)
679701

680702
param_dict = _parse_cutout_size(size)
681703
param_dict["ra"] = coordinates.ra.deg
@@ -760,7 +782,7 @@ def download_cutouts(self, coordinates, *, size=5, path=".", inflate=True, verbo
760782
"""
761783

762784
# Get Skycoord object for coordinates/object
763-
coordinates = parse_input_location(coordinates)
785+
coordinates = parse_input_location(coordinates=coordinates)
764786

765787
# Build initial astrocut request
766788
astrocut_request = f"astrocut?ra={coordinates.ra.deg}&dec={coordinates.dec.deg}"
@@ -829,7 +851,7 @@ def get_cutouts(self, coordinates, *, size=5):
829851
"""
830852

831853
# Get Skycoord object for coordinates/object
832-
coordinates = parse_input_location(coordinates)
854+
coordinates = parse_input_location(coordinates=coordinates)
833855

834856
param_dict = _parse_cutout_size(size)
835857

astroquery/mast/missions.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def query_region_async(self, coordinates, *, radius=3*u.arcmin, limit=5000, offs
222222

223223
@class_or_instance
224224
def query_criteria_async(self, *, coordinates=None, objectname=None, radius=3*u.arcmin,
225-
limit=5000, offset=0, select_cols=None, **criteria):
225+
limit=5000, offset=0, select_cols=None, resolver=None, **criteria):
226226
"""
227227
Given a set of search criteria, returns a list of mission metadata.
228228
@@ -246,6 +246,11 @@ def query_criteria_async(self, *, coordinates=None, objectname=None, radius=3*u.
246246
the number of records you wish to skip before selecting records.
247247
select_cols: list, None
248248
Default None. Names of columns that will be included in the astropy table
249+
resolver : str, optional
250+
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
251+
If not specified, the default resolver order will be used. Please see the
252+
`STScI Archive Name Translation Application (SANTA) <https://mastresolver.stsci.edu/Santa-war/>`__
253+
for more information. Default is None.
249254
**criteria
250255
Criteria to apply. At least one non-positional criterion must be supplied.
251256
Valid criteria are coordinates, objectname, radius (as in
@@ -268,7 +273,9 @@ def query_criteria_async(self, *, coordinates=None, objectname=None, radius=3*u.
268273

269274
# Parse user input location
270275
if objectname or coordinates:
271-
coordinates = utils.parse_input_location(coordinates, objectname)
276+
coordinates = utils.parse_input_location(coordinates=coordinates,
277+
objectname=objectname,
278+
resolver=resolver)
272279

273280
# if radius is just a number we assume degrees
274281
radius = coord.Angle(radius, u.arcmin)
@@ -300,7 +307,7 @@ def query_criteria_async(self, *, coordinates=None, objectname=None, radius=3*u.
300307

301308
@class_or_instance
302309
def query_object_async(self, objectname, *, radius=3*u.arcmin, limit=5000, offset=0,
303-
select_cols=None, **criteria):
310+
select_cols=None, resolver=None, **criteria):
304311
"""
305312
Given an object name, returns a list of matching rows.
306313
@@ -321,6 +328,11 @@ def query_object_async(self, objectname, *, radius=3*u.arcmin, limit=5000, offse
321328
the number of records you wish to skip before selecting records.
322329
select_cols: list, None
323330
Default None. Names of columns that will be included in the astropy table
331+
resolver : str, optional
332+
The resolver to use when resolving a named target into coordinates. Valid options are "SIMBAD" and "NED".
333+
If not specified, the default resolver order will be used. Please see the
334+
`STScI Archive Name Translation Application (SANTA) <https://mastresolver.stsci.edu/Santa-war/>`__
335+
for more information. Default is None.
324336
**criteria
325337
Other mission-specific criteria arguments.
326338
All valid filters can be found using `~astroquery.mast.missions.MastMissionsClass.get_column_list`
@@ -332,7 +344,7 @@ def query_object_async(self, objectname, *, radius=3*u.arcmin, limit=5000, offse
332344
response : list of `~requests.Response`
333345
"""
334346

335-
coordinates = utils.resolve_object(objectname)
347+
coordinates = utils.resolve_object(objectname, resolver=resolver)
336348

337349
return self.query_region_async(coordinates, radius=radius, limit=limit, offset=offset,
338350
select_cols=select_cols, **criteria)

0 commit comments

Comments
 (0)