Skip to content

Commit

Permalink
added extra_precision option for ephemerides
Browse files Browse the repository at this point in the history
  • Loading branch information
mommermi committed May 29, 2019
1 parent 38ceae8 commit 678b9f5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
11 changes: 7 additions & 4 deletions astroquery/jplhorizons/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def ephemerides_async(self, airmass_lessthan=99,
refsystem='J2000',
closest_apparition=False, no_fragments=False,
quantities=conf.eph_quantities,
extra_precision=False,
get_query_payload=False,
get_raw_response=False, cache=True):
"""
Expand Down Expand Up @@ -434,13 +435,15 @@ def ephemerides_async(self, airmass_lessthan=99,
selection; default: False. Do not use this option for
non-cometary objects.
quantities : integer or string, optional
single integer or comma-separated list in the form of a string
Single integer or comma-separated list in the form of a string
corresponding to all the
quantities to be queried from JPL Horizons using the coding
according to the `JPL Horizons User Manual Definition of
Observer Table Quantities
<https://ssd.jpl.nasa.gov/?horizons_doc#table_quantities>`_;
default: all quantities
extra_precision : boolean, optional
Enables extra precision in RA and DEC values; default: False
get_query_payload : boolean, optional
When set to `True` the method returns the HTTP request
parameters as a dict, default: False
Expand Down Expand Up @@ -528,7 +531,8 @@ def ephemerides_async(self, airmass_lessthan=99,
('ANG_FORMAT', ('DEG')),
('APPARENT', ({False: 'AIRLESS',
True: 'REFRACTED'}[refraction])),
('REF_SYSTEM', (refsystem))])
('REF_SYSTEM', (refsystem)),
('EXTRA_PREC', {True: 'YES', False: 'NO'}[extra_precision])])

if isinstance(self.location, dict):
if ('lon' not in self.location or 'lat' not in self.location or
Expand Down Expand Up @@ -763,8 +767,7 @@ def elements_async(self, get_query_payload=False,
('REF_PLANE', {'ecliptic': 'ECLIPTIC', 'earth': 'FRAME',
'body': "'BODY EQUATOR'"}[refplane]),
('TP_TYPE', {'absolute': 'ABSOLUTE',
'relative': 'RELATIVE'}[tp_type])]
)
'relative': 'RELATIVE'}[tp_type])])

# parse self.epochs
if isinstance(self.epochs, (list, tuple, ndarray)):
Expand Down
4 changes: 3 additions & 1 deletion astroquery/jplhorizons/tests/test_jplhorizons.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ def test_ephemerides_query_payload(self):
('STOP_TIME', '"2080-02-01"'),
('STEP_SIZE', '"3h"'),
('AIRMASS', '1.2'),
('SKIP_DAYLT', 'YES')])
('SKIP_DAYLT', 'YES'),
('EXTRA_PREC', 'NO')])

def test_elements_query_payload():
res = (jplhorizons.Horizons(id='Ceres', location='500@10',
Expand All @@ -197,6 +198,7 @@ def test_elements_query_payload():
('REF_SYSTEM', 'J2000'),
('REF_PLANE', 'ECLIPTIC'),
('TP_TYPE', 'ABSOLUTE'),
('EXTRA_PREC', 'NO')
('TLIST', '2451544.5')])


Expand Down
8 changes: 8 additions & 0 deletions astroquery/jplhorizons/tests/test_jplhorizons_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,11 @@ def test_vectors_delta_T(self):

vec = obj.vectors(delta_T=True)
assert_quantity_allclose(vec['delta_T'][0], 69.184373)

def test_ephemerides_extraprecision(self):
obj = jplhorizons.Horizons(id='1', epochs=2458500, location='G37')

vec_simple = obj.ephemerides(extra_precision=False)
vec_highprec = obj.ephemerides(extra_precision=True)

assert (vec_simple['RA'][0]-vec_highprec['RA'][0]) > 1e-7
8 changes: 5 additions & 3 deletions docs/jplhorizons/jplhorizons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,11 @@ default).. For comets, the options ``closest_apparation`` and
``no_fragments`` are available, which select the closest apparition in
time and reject fragments, respectively. Note that these options
should only be used for comets and will crash the query for other
object types. Furthermore, ``get_query_payload=True`` skips the query
and only returns the query payload, whereas ``get_raw_response=True``
the raw query response instead of the astropy table returns.
object types. Extra precision in the queried properties can be
requested using the ``extra_precision`` option. Furthermore,
``get_query_payload=True`` skips the query and only returns the query
payload, whereas ``get_raw_response=True`` the raw query response
instead of the astropy table returns.

:meth:`~astroquery.jplhorizons.HorizonsClass.ephemerides` queries by
default all available quantities from the JPL Horizons servers. This
Expand Down

0 comments on commit 678b9f5

Please sign in to comment.