Skip to content

Commit 55642bc

Browse files
committed
Revert "Remove get_raw_response optional parameters."
This reverts commit 0dbb4e5.
1 parent f0a9418 commit 55642bc

File tree

3 files changed

+66
-15
lines changed

3 files changed

+66
-15
lines changed

astroquery/jplhorizons/core.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def ephemerides_async(self, airmass_lessthan=99,
174174
closest_apparition=False, no_fragments=False,
175175
quantities=conf.eph_quantities,
176176
get_query_payload=False,
177-
cache=True,
177+
get_raw_response=False, cache=True,
178178
extra_precision=False):
179179
"""
180180
Query JPL Horizons for ephemerides.
@@ -478,6 +478,10 @@ def ephemerides_async(self, airmass_lessthan=99,
478478
When set to `True` the method returns the HTTP request parameters as
479479
a dict, default: False
480480
481+
get_raw_response : boolean, optional
482+
Return raw data as obtained by JPL Horizons without parsing the data
483+
into a table, default: False
484+
481485
extra_precision : boolean, optional
482486
Enables extra precision in RA and DEC values; default: False
483487
@@ -610,6 +614,10 @@ def ephemerides_async(self, airmass_lessthan=99,
610614
if get_query_payload:
611615
return request_payload
612616

617+
# set return_raw flag, if raw response desired
618+
if get_raw_response:
619+
self.return_raw = True
620+
613621
# query and parse
614622
response = self._request('GET', URL, params=request_payload,
615623
timeout=self.TIMEOUT, cache=cache)
@@ -629,7 +637,7 @@ def elements_async(self, get_query_payload=False,
629637
refplane='ecliptic',
630638
tp_type='absolute',
631639
closest_apparition=False, no_fragments=False,
632-
cache=True):
640+
get_raw_response=False, cache=True):
633641
"""
634642
Query JPL Horizons for osculating orbital elements.
635643
@@ -720,6 +728,10 @@ def elements_async(self, get_query_payload=False,
720728
When set to ``True`` the method returns the HTTP request parameters
721729
as a dict, default: False
722730
731+
get_raw_response: boolean, optional
732+
Return raw data as obtained by JPL Horizons without parsing the data
733+
into a table, default: False
734+
723735
724736
Returns
725737
-------
@@ -820,6 +832,10 @@ def elements_async(self, get_query_payload=False,
820832
if get_query_payload:
821833
return request_payload
822834

835+
# set return_raw flag, if raw response desired
836+
if get_raw_response:
837+
self.return_raw = True
838+
823839
# query and parse
824840
response = self._request('GET', URL, params=request_payload,
825841
timeout=self.TIMEOUT, cache=cache)
@@ -836,7 +852,7 @@ def elements_async(self, get_query_payload=False,
836852

837853
def vectors_async(self, get_query_payload=False,
838854
closest_apparition=False, no_fragments=False,
839-
cache=True,
855+
get_raw_response=False, cache=True,
840856
refplane='ecliptic', aberrations='geometric',
841857
delta_T=False,):
842858
"""
@@ -919,6 +935,10 @@ def vectors_async(self, get_query_payload=False,
919935
When set to `True` the method returns the HTTP request parameters as
920936
a dict, default: False
921937
938+
get_raw_response: boolean, optional
939+
Return raw data as obtained by JPL Horizons without parsing the data
940+
into a table, default: False
941+
922942
refplane : string
923943
Reference plane for all output quantities: ``'ecliptic'`` (ecliptic
924944
and mean equinox of reference epoch), ``'earth'`` (Earth mean
@@ -1058,6 +1078,10 @@ def vectors_async(self, get_query_payload=False,
10581078
if get_query_payload:
10591079
return request_payload
10601080

1081+
# set return_raw flag, if raw response desired
1082+
if get_raw_response:
1083+
self.return_raw = True
1084+
10611085
# query and parse
10621086
response = self._request('GET', URL, params=request_payload,
10631087
timeout=self.TIMEOUT, cache=cache)

astroquery/jplhorizons/tests/test_jplhorizons_remote.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@ def test_ephemerides_query_six(self):
174174

175175
assert len(res) == 32
176176

177+
def test_ephemerides_query_raw(self):
178+
res = (jplhorizons.Horizons(id='Ceres', location='500',
179+
id_type='smallbody', epochs=2451544.5).
180+
ephemerides(get_raw_response=True))
181+
182+
assert len(res) >= 15400
183+
177184
def test_elements_query(self):
178185
res = jplhorizons.Horizons(id='Ceres', location='500@10',
179186
id_type='smallbody',
@@ -219,6 +226,14 @@ def test_elements_query_two(self):
219226
[res['Omega'], res['w'], res['Tp_jd']],
220227
rtol=1e-3)
221228

229+
def test_elements_query_raw(self):
230+
res = jplhorizons.Horizons(id='Ceres', location='500@10',
231+
id_type='smallbody',
232+
epochs=2451544.5).elements(
233+
get_raw_response=True)
234+
235+
assert len(res) >= 6686
236+
222237
def test_vectors_query(self):
223238
# check values of Ceres for a given epoch
224239
# orbital uncertainty of Ceres is basically zero
@@ -245,6 +260,14 @@ def test_vectors_query(self):
245260
res['lighttime'], res['range'],
246261
res['range_rate']], rtol=1e-3)
247262

263+
def test_vectors_query_raw(self):
264+
res = jplhorizons.Horizons(id='Ceres', location='500@10',
265+
id_type='smallbody',
266+
epochs=2451544.5).vectors(
267+
get_raw_response=True)
268+
269+
assert len(res) >= 6412
270+
248271
def test_unknownobject(self):
249272
with pytest.raises(ValueError):
250273
jplhorizons.Horizons(id='spamspamspameggsspam', location='500',

docs/jplhorizons/jplhorizons.rst

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ limits fragment matching (73P-B would only match 73P-B), respectively. Note
189189
that these options should only be used for comets and will crash the query for
190190
other object types. Extra precision in the queried properties can be requested
191191
using the ``extra_precision`` option. Furthermore, ``get_query_payload=True``
192-
skips the query and only returns the query payload.
192+
skips the query and only returns the query payload, whereas
193+
``get_raw_response=True`` returns the raw query response instead of the astropy
194+
table.
193195

194196
:meth:`~astroquery.jplhorizons.HorizonsClass.ephemerides` queries by default all
195197
available quantities from the JPL Horizons servers. This might take a while. If
@@ -241,8 +243,9 @@ absolute representation of the time of perihelion passage. For comets, the
241243
options ``closest_apparition`` and ``no_fragments`` are available, which select
242244
the closest apparition in time and reject fragments, respectively. Note that
243245
these options should only be used for comets and will crash the query for other
244-
object types. Also available is ``get_query_payload=True``, which skips the
245-
query and only returns the query payload.
246+
object types. Also available are ``get_query_payload=True``, which skips the
247+
query and only returns the query payload, and ``get_raw_response=True``, which
248+
returns the raw query response instead of the astropy table.
246249

247250
Vectors
248251
-------
@@ -287,15 +290,16 @@ The following fields are queried:
287290
288291
289292
Similar to the other :class:`~astroquery.jplhorizons.HorizonsClass` functions,
290-
an optional parameter of :meth:`~astroquery.jplhorizons.HorizonsClass.vectors`
291-
is ``get_query_payload=True``, which skips the query and only returns the query
292-
payload for diagnostic purposes. For comets, the options ``closest_apparation``
293-
and ``no_fragments`` are available, which select the closest apparition in time
294-
and reject fragments, respectively. Note that these options should only be used
295-
for comets and will crash the query for other object types. Options
296-
``aberrations`` and ``delta_T`` provide different choices for aberration
297-
corrections as well as a measure for time-varying differences between TDB and UT
298-
time-scales, respectively.
293+
optional parameters of :meth:`~astroquery.jplhorizons.HorizonsClass.vectors` are
294+
``get_query_payload=True``, which skips the query and only returns the query
295+
payload, and ``get_raw_response=True``, which returns the raw query response
296+
instead of the astropy table. For comets, the options ``closest_apparation`` and
297+
``no_fragments`` are available, which select the closest apparition in time and
298+
reject fragments, respectively. Note that these options should only be used for
299+
comets and will crash the query for other object types. Options ``aberrations``
300+
and ``delta_T`` provide different choices for aberration corrections as well as
301+
a measure for time-varying differences between TDB and UT time-scales,
302+
respectively.
299303

300304

301305
How to Use the Query Tables

0 commit comments

Comments
 (0)