From 678b9f59a09f8da839ad29e26503b18d55e73eb5 Mon Sep 17 00:00:00 2001 From: Michael Mommert Date: Wed, 29 May 2019 12:19:17 -0700 Subject: [PATCH] added extra_precision option for ephemerides --- astroquery/jplhorizons/core.py | 11 +++++++---- astroquery/jplhorizons/tests/test_jplhorizons.py | 4 +++- .../jplhorizons/tests/test_jplhorizons_remote.py | 8 ++++++++ docs/jplhorizons/jplhorizons.rst | 8 +++++--- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/astroquery/jplhorizons/core.py b/astroquery/jplhorizons/core.py index 251837bae0..a3c45371f3 100644 --- a/astroquery/jplhorizons/core.py +++ b/astroquery/jplhorizons/core.py @@ -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): """ @@ -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 `_; 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 @@ -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 @@ -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)): diff --git a/astroquery/jplhorizons/tests/test_jplhorizons.py b/astroquery/jplhorizons/tests/test_jplhorizons.py index bb6dde7964..3935167da4 100644 --- a/astroquery/jplhorizons/tests/test_jplhorizons.py +++ b/astroquery/jplhorizons/tests/test_jplhorizons.py @@ -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', @@ -197,6 +198,7 @@ def test_elements_query_payload(): ('REF_SYSTEM', 'J2000'), ('REF_PLANE', 'ECLIPTIC'), ('TP_TYPE', 'ABSOLUTE'), + ('EXTRA_PREC', 'NO') ('TLIST', '2451544.5')]) diff --git a/astroquery/jplhorizons/tests/test_jplhorizons_remote.py b/astroquery/jplhorizons/tests/test_jplhorizons_remote.py index e63cd69446..ecdd3a94eb 100644 --- a/astroquery/jplhorizons/tests/test_jplhorizons_remote.py +++ b/astroquery/jplhorizons/tests/test_jplhorizons_remote.py @@ -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 diff --git a/docs/jplhorizons/jplhorizons.rst b/docs/jplhorizons/jplhorizons.rst index 51e9b9c102..da5d530aea 100644 --- a/docs/jplhorizons/jplhorizons.rst +++ b/docs/jplhorizons/jplhorizons.rst @@ -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