Skip to content

Commit d1dbd5f

Browse files
committed
- EmptyResponseError changed to NoResultsWarning when empty ephemeris table is retrieved
- Added remote test for ephemeris with moon phase and uncertainty - Changes listed in CHANGES.rst
1 parent 0286b8b commit d1dbd5f

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ mpc
1212
^^^
1313

1414
- Parse star catalog information when querying observations database [#2957]
15+
- Parse ephemeris with sky motion with three digit precision [#3019]
16+
- Raise NoResultWarining when empty ephemeris reponse is returned [#3019]
1517

1618
linelists.cdms
1719
^^^^^^^^^^^^^^

astroquery/mpc/core.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
from ..query import BaseQuery
1717
from . import conf
1818
from ..utils import async_to_sync, class_or_instance
19-
from ..exceptions import InvalidQueryError, EmptyResponseError
20-
19+
from ..exceptions import InvalidQueryError, EmptyResponseError, NoResultsWarning
2120

2221
__all__ = ['MPCClass']
2322

@@ -1064,7 +1063,7 @@ def _parse_result(self, result, **kwargs):
10641063
try:
10651064
i = text_table.index('\n', text_table.index('h m s')) + 1
10661065
except ValueError as e:
1067-
raise EmptyResponseError(content)
1066+
raise NoResultsWarning(content)
10681067
columns = text_table[:i]
10691068
data_start = columns.count('\n') - 1
10701069
else:
@@ -1073,7 +1072,7 @@ def _parse_result(self, result, **kwargs):
10731072
try:
10741073
i = text_table.index('\n', text_table.index('JD_TT')) + 1
10751074
except ValueError as e:
1076-
raise EmptyResponseError(content)
1075+
raise NoResultsWarning(content)
10771076
columns = text_table[:i]
10781077
data_start = columns.count('\n') - 1
10791078

@@ -1181,7 +1180,6 @@ def _parse_result(self, result, **kwargs):
11811180
else:
11821181
# convert from MPES string to Time
11831182
tab['JD'] = Time(tab['JD'], format='jd', scale='tt')
1184-
print(tab)
11851183
return tab
11861184

11871185
elif self.query_type == 'observations':

astroquery/mpc/tests/test_mpc_remote.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
import requests
33
import pytest
4-
4+
import astropy.units as u
55
from astroquery.exceptions import InvalidQueryError
66
from astroquery import mpc
77

@@ -78,6 +78,21 @@ def test_get_ephemeris_by_target(self, target):
7878
response = mpc.MPC.get_ephemeris(target)
7979
assert len(response) > 0
8080

81+
def test_get_ephemeris_Moon_phase(self):
82+
result = mpc.core.MPC.get_ephemeris('2P', location='G37')
83+
assert result['Moon phase'][0] >= 0
84+
85+
def test_get_ephemeris_Uncertainty(self):
86+
# this test requires an object with uncertainties != N/A
87+
result = mpc.core.MPC.get_ephemeris('2024 AA', start='2024-06-15')
88+
assert result['Uncertainty 3sig'].quantity[0] > 0 * u.arcsec
89+
90+
def test_get_ephemeris_Moon_phase_and_Uncertainty(self):
91+
# this test requires an object with uncertainties != N/A
92+
result = mpc.core.MPC.get_ephemeris('2024 AA', location='G37', start='2024-06-15')
93+
assert result['Moon phase'][0] >= 0
94+
assert result['Uncertainty 3sig'].quantity[0] > 0 * u.arcsec
95+
8196
def test_get_ephemeris_target_fail(self):
8297
# test that query failed
8398
with pytest.raises(InvalidQueryError):

0 commit comments

Comments
 (0)