Skip to content

Commit 31f3072

Browse files
committed
Slight tweak to how we resolve objects
1 parent 5d02df3 commit 31f3072

2 files changed

Lines changed: 41 additions & 24 deletions

File tree

astroquery/mast/tests/test_mast_remote.py

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22

3+
import json
34
import logging
5+
import os
46
from pathlib import Path
7+
8+
import astropy.units as u
59
import numpy as np
6-
import os
710
import pytest
8-
import json
9-
10-
from requests.models import Response
11-
12-
from astropy.table import Table, unique
1311
from astropy.coordinates import SkyCoord
1412
from astropy.io import fits
15-
import astropy.units as u
16-
17-
from astroquery.mast import Observations, utils, Mast, Catalogs, Hapcut, Tesscut, Zcut, MastMissions
13+
from astropy.table import Table, unique
14+
from requests.models import Response
1815

16+
from astroquery.mast import (
17+
Catalogs,
18+
Hapcut,
19+
Mast,
20+
MastMissions,
21+
Observations,
22+
Tesscut,
23+
Zcut,
24+
utils,
25+
)
26+
27+
from ...exceptions import (
28+
InputWarning,
29+
InvalidQueryError,
30+
MaxResultsWarning,
31+
NoResultsWarning,
32+
)
1933
from ..utils import ResolverError
20-
from ...exceptions import (InputWarning, InvalidQueryError, MaxResultsWarning,
21-
NoResultsWarning)
2234

2335

2436
@pytest.fixture(scope="module")
@@ -66,8 +78,10 @@ def test_resolve_object(self):
6678

6779
# Try the same object with different resolvers
6880
# The position of objects can change with different resolvers
69-
ned_loc = utils.resolve_object("jw100", resolver="NED")
70-
assert round(ned_loc.separation(SkyCoord("354.10436 21.15083", unit='deg')).value, 4) == 0
81+
# TODO: Commenting out NED resolver test for now since we've been having issues with NED service availability.
82+
# Re-enable this test once the service is stable.
83+
# ned_loc = utils.resolve_object("jw100", resolver="NED")
84+
# assert round(ned_loc.separation(SkyCoord("354.10436 21.15083", unit='deg')).value, 4) == 0
7185

7286
simbad_loc = utils.resolve_object("jw100", resolver="simbad")
7387
assert round(simbad_loc.separation(SkyCoord("83.70341477 -5.55918309", unit="deg")).value, 4) == 0
@@ -79,16 +93,16 @@ def test_resolve_object(self):
7993
# Use resolve_all to get all resolvers
8094
loc_dict = utils.resolve_object("jw100", resolve_all=True)
8195
assert isinstance(loc_dict, dict)
82-
assert loc_dict['NED'] == ned_loc
96+
# assert loc_dict['NED'] == ned_loc
8397
assert loc_dict['SIMBAD'] == simbad_loc
8498

8599
# Error if coordinates cannot be resolved
86100
with pytest.raises(ResolverError, match='Could not resolve "invalid" to a sky position.'):
87101
utils.resolve_object("invalid")
88102

89103
# Error if coordinates cannot be resolved with a specific resolver
90-
with pytest.raises(ResolverError, match='Could not resolve "invalid" to a sky position using resolver "NED"'):
91-
utils.resolve_object("invalid", resolver="NED")
104+
with pytest.raises(ResolverError, match='not resolve "invalid" to a sky position using resolver "SIMBAD"'):
105+
utils.resolve_object("invalid", resolver="SIMBAD")
92106

93107
###########################
94108
# MissionSearchClass Test #

astroquery/mast/utils.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,28 @@
66
Miscellaneous functions used throughout the MAST module.
77
"""
88

9+
import platform
910
import re
1011
import warnings
1112

1213
import numpy as np
1314
import requests
14-
import platform
15+
from astropy import units as u
1516
from astropy.coordinates import SkyCoord
1617
from astropy.table import Table
1718
from astropy.utils import deprecated
1819
from astropy.utils.console import ProgressBarOrSpinner
1920
from astropy.utils.decorators import deprecated_renamed_argument
20-
from astropy import units as u
2121

2222
from .. import log
23-
from ..version import version
24-
from ..exceptions import InputWarning, NoResultsWarning, ResolverError, InvalidQueryError
23+
from ..exceptions import (
24+
InputWarning,
25+
InvalidQueryError,
26+
NoResultsWarning,
27+
ResolverError,
28+
)
2529
from ..utils import commons
26-
30+
from ..version import version
2731

2832
__all__ = []
2933

@@ -227,10 +231,9 @@ def resolve_object(object_name, *, resolver=None, resolve_all=False, batch_size=
227231
break
228232

229233
# Send request to STScI Archive Name Translation Application (SANTA)
230-
params = {'outputFormat': 'json',
231-
'resolveAll': resolve_all or is_catalog} # Always set resolveAll to True for MAST catalogs
234+
params = {'outputFormat': 'json', 'resolveAll': resolve_all} # Always set resolveAll to True for MAST catalogs
232235
if resolver and not params['resolveAll']:
233-
params['resolver'] = resolver
236+
params['resolver'] = [resolver, catalog] if is_catalog else [resolver]
234237

235238
# Fetch results (batching if necessary)
236239
results = _batched_request(

0 commit comments

Comments
 (0)