From 6762dcda6ed625b1cc5f28fa56e4577b65fdf235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Sat, 21 Dec 2024 20:39:13 -0800 Subject: [PATCH 1/3] MAINT: remove DACE after coordinating with them --- astroquery/dace/__init__.py | 28 +------ astroquery/dace/core.py | 78 ------------------- astroquery/dace/tests/__init__.py | 0 .../dace/tests/data/parameter_list.json | 62 --------------- astroquery/dace/tests/setup_package.py | 9 --- astroquery/dace/tests/test_dace.py | 25 ------ astroquery/dace/tests/test_dace_remote.py | 19 ----- docs/dace/dace.rst | 52 ------------- setup.cfg | 2 +- 9 files changed, 5 insertions(+), 270 deletions(-) delete mode 100644 astroquery/dace/core.py delete mode 100644 astroquery/dace/tests/__init__.py delete mode 100644 astroquery/dace/tests/data/parameter_list.json delete mode 100644 astroquery/dace/tests/setup_package.py delete mode 100644 astroquery/dace/tests/test_dace.py delete mode 100644 astroquery/dace/tests/test_dace_remote.py delete mode 100644 docs/dace/dace.rst diff --git a/astroquery/dace/__init__.py b/astroquery/dace/__init__.py index b920f4a652..9346d30e80 100644 --- a/astroquery/dace/__init__.py +++ b/astroquery/dace/__init__.py @@ -4,29 +4,9 @@ Dace API -------- -:author: Julien Burnier (julien.burnier@unige.ch) +This module has beeen removed due to upstream changes and in favour of the +standalone dace-query package. """ -from astropy import config as _config - - -class Conf(_config.ConfigNamespace): - """ - Configuration parameters for `astroquery.dace`. - """ - server = _config.ConfigItem( - ['https://dace-api.unige.ch/'], - 'Dace') - - timeout = _config.ConfigItem( - 30, - 'Time limit for connecting to DACE server.') - - -conf = Conf() - -from .core import Dace, DaceClass - -__all__ = ['Dace', 'DaceClass', - 'Conf', 'conf', - ] +raise ImportError("The DACE module has been removed from astroquery due to server-side " + "changes. Use the standalone dace-query package to access DACE data.") diff --git a/astroquery/dace/core.py b/astroquery/dace/core.py deleted file mode 100644 index 44b5f3c8f7..0000000000 --- a/astroquery/dace/core.py +++ /dev/null @@ -1,78 +0,0 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst - -from collections import defaultdict -from json import JSONDecodeError -from astropy.table import Table -from ..query import BaseQuery -from ..utils import async_to_sync -from . import conf - -__all__ = ['Dace', 'DaceClass'] - - -class ParseException(Exception): - """Raised when parsing Dace data fails""" - - -@async_to_sync -class DaceClass(BaseQuery): - """ - DACE class to access DACE (Data Analysis Center for Exoplanets) data based in Geneva Observatory - """ - - __DACE_URL = conf.server - __DACE_TIMEOUT = conf.timeout - __OBSERVATION_ENDPOINT = 'ObsAPI/observation/' - __RADIAL_VELOCITIES_ENDPOINT = __OBSERVATION_ENDPOINT + 'radialVelocities/' - __HEADERS = {'Accept': 'application/json'} - - def query_radial_velocities_async(self, object_name): - """ - Get radial velocities data for an object_name. For example : HD40307 - - Parameters - ---------- - object_name : str - The target you want radial velocities data - - Returns - ------- - response : a ``requests.Response`` from DACE - """ - return self._request("GET", ''.join([self.__DACE_URL, self.__RADIAL_VELOCITIES_ENDPOINT, object_name]), - timeout=self.__DACE_TIMEOUT, headers=self.__HEADERS) - - def _parse_result(self, response, *, verbose=False): - try: - json_data = response.json() - dace_dict = self.transform_data_as_dict(json_data) - return Table(dace_dict) - except JSONDecodeError as error: - raise ParseException("Failed to parse DACE result. Request response : {}".format(response.text)) from error - - @staticmethod - def transform_data_as_dict(json_data): - """ - Internally DACE data are provided using protobuff. The format is a list of parameters. Here we parse - these data to give to the user something more readable and ignore the internal stuff - """ - data = defaultdict(list) - parameters = json_data.get('parameters') - for parameter in parameters: - variable_name = parameter.get('variableName') - double_values = parameter.get('doubleValues') - int_values = parameter.get('intValues') - string_values = parameter.get('stringValues') - bool_values = parameter.get('boolValues') - # Only one type of values can be present. So we look for the next occurence not None - values = next(values_list for values_list in [double_values, int_values, string_values, bool_values] if - values_list is not None) - data[variable_name].extend(values) - - error_values = parameter.get('minErrorValues') # min or max is symmetric - if error_values is not None: - data[variable_name + '_err'].extend(error_values) - return data - - -Dace = DaceClass() diff --git a/astroquery/dace/tests/__init__.py b/astroquery/dace/tests/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/astroquery/dace/tests/data/parameter_list.json b/astroquery/dace/tests/data/parameter_list.json deleted file mode 100644 index 7385bc1452..0000000000 --- a/astroquery/dace/tests/data/parameter_list.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "parameters": [ - { - "variableName": "ccf_noise", - "label": "CCF Noise", - "unit": "", - "doubleValues": [ - 0.005320016177906, - 0.00393390440796704, - 0.0032324617496158 - ] - }, - { - "variableName": "ins_name", - "label": "Instrument Name", - "unit": "", - "stringValues": [ - "CORALIE98", - "CORALIE98", - "HARPS" - ] - }, - { - "variableName": "drs_qc", - "label": "DRS Quality check", - "unit": "", - "boolValues": [ - true, - true, - false - ] - }, - { - "variableName": "rjd", - "label": "Barycentric Reduced Julian Day", - "unit": "RJD", - "intValues": [ - 51031, - 51039, - 51088 - ] - }, - { - "variableName": "rv", - "label": "Radial Velocity", - "unit": "MPS", - "doubleValues": [ - 31300.4226771379, - 31295.5671320506, - 31294.3391634734 - ], - "minErrorValues": [ - 5.420218247708816, - 4.0697289792344185, - 3.4386352834851026 - ] - } - ] -} - - - diff --git a/astroquery/dace/tests/setup_package.py b/astroquery/dace/tests/setup_package.py deleted file mode 100644 index 0c5d082964..0000000000 --- a/astroquery/dace/tests/setup_package.py +++ /dev/null @@ -1,9 +0,0 @@ -# Licensed under a 3-clause BSD style license - see LICENSE.rst - - -import os - - -def get_package_data(): - paths = [os.path.join('data', '*.json')] - return {'astroquery.dace.tests': paths} diff --git a/astroquery/dace/tests/test_dace.py b/astroquery/dace/tests/test_dace.py deleted file mode 100644 index b8be0bb9f5..0000000000 --- a/astroquery/dace/tests/test_dace.py +++ /dev/null @@ -1,25 +0,0 @@ -import os -import json -from astroquery.dace import Dace - -DATA_FILES = { - 'parameter_list': 'parameter_list.json', -} - - -def test_transform_data_as_dict(): - expected_parameter_dict = {'ccf_noise': [0.005320016177906, 0.00393390440796704, 0.0032324617496158], - 'ins_name': ['CORALIE98', 'CORALIE98', 'HARPS'], - 'drs_qc': [True, True, False], - 'rjd': [51031, 51039, 51088], - 'rv': [31300.4226771379, 31295.5671320506, 31294.3391634734], - 'rv_err': [5.420218247708816, 4.0697289792344185, 3.4386352834851026]} - with open(_data_path('parameter_list.json'), 'r') as file: - parameter_list = json.load(file) - parameter_dict = Dace.transform_data_as_dict(parameter_list) - assert parameter_dict == expected_parameter_dict - - -def _data_path(filename): - data_dir = os.path.join(os.path.dirname(__file__), 'data') - return os.path.join(data_dir, filename) diff --git a/astroquery/dace/tests/test_dace_remote.py b/astroquery/dace/tests/test_dace_remote.py deleted file mode 100644 index 0518028239..0000000000 --- a/astroquery/dace/tests/test_dace_remote.py +++ /dev/null @@ -1,19 +0,0 @@ -import pytest -from astroquery.dace import Dace - -HARPS_PUBLICATION = '2009A&A...493..639M' - - -@pytest.mark.remote_data -class TestDaceClassRemote: - - def test_should_get_radial_velocities(self): - radial_velocities_table = Dace.query_radial_velocities('HD40307') - assert radial_velocities_table is not None and 'rv' in radial_velocities_table.colnames - # HARPS is a spectrograph and has to be present for this target because HD40307 has been observed and - # processed by this instrument - assert 'HARPS' in radial_velocities_table['ins_name'] - assert HARPS_PUBLICATION in radial_velocities_table['pub_bibcode'] - public_harps_data = [row for row in radial_velocities_table['pub_bibcode'] if HARPS_PUBLICATION in row] - assert len(public_harps_data) > 100 - assert len(radial_velocities_table['rv_err']) > 100 diff --git a/docs/dace/dace.rst b/docs/dace/dace.rst deleted file mode 100644 index e11371dd94..0000000000 --- a/docs/dace/dace.rst +++ /dev/null @@ -1,52 +0,0 @@ -.. _astroquery.dace: - -************************ -DACE (`astroquery.dace`) -************************ - -This module let you query DACE (Data Analysis Center for Exoplanets) data. This project is developed -at Observatory of Geneva and can be accessed online at https://dace.unige.ch - -Getting started -=============== - - -Query radial velocities ------------------------ -If you need to get radial velocities data for an object you can do the following and get a `~astropy.table.Table` : - - -.. doctest-remote-data:: - - >>> from astroquery.dace import Dace - >>> radial_velocities_table = Dace.query_radial_velocities('HD40307') - >>> radial_velocities_table.pprint(max_lines=5, max_width=120) # doctest: +IGNORE_OUTPUT - berv berv_err ... date_night raw_file - ----------------- -------- ... ---------- ------------------------------------------------------------------------- - 1.73905237267071 NaN ... 1998-11-13 coralie98/DRS-3.3/reduced/1998-11-13/CORALIE.1998-11-14T07:42:28.001.fits - 1.30280483191029 NaN ... 1998-11-21 coralie98/DRS-3.3/reduced/1998-11-21/CORALIE.1998-11-22T07:21:45.001.fits - ... ... ... ... ... - -3.37421721287255 NaN ... 2014-03-31 harps/DRS-3.5/reduced/2014-03-31/HARPS.2014-03-31T23:53:00.821.fits - -3.32906204496065 NaN ... 2014-04-05 harps/DRS-3.5/reduced/2014-04-05/HARPS.2014-04-06T01:00:15.375.fits - Length = 600 rows - - -Troubleshooting -=============== - -If you are repeatedly getting failed queries, or bad/out-of-date results, try clearing your cache: - -.. code-block:: python - - >>> from astroquery.dace import Dace - >>> Dace.clear_cache() - -If this function is unavailable, upgrade your version of astroquery. -The ``clear_cache`` function was introduced in version 0.4.7.dev8479. - - -Reference/API -============= - -.. automodapi:: astroquery.dace - :no-inheritance-diagram: diff --git a/setup.cfg b/setup.cfg index e84a41b727..9561c005f9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -36,7 +36,7 @@ show-response = 1 [tool:pytest] minversion = 6.0 -norecursedirs = build docs/_build astroquery/irsa astroquery/nasa_exoplanet_archive astroquery/ned astroquery/ibe astroquery/irsa_dust astroquery/cds astroquery/sha +norecursedirs = build docs/_build astroquery/irsa astroquery/nasa_exoplanet_archive astroquery/ned astroquery/ibe astroquery/irsa_dust astroquery/cds astroquery/sha astroquery/dace testpaths = astroquery docs doctest_plus = enabled astropy_header = true From 15b82e6f0bc568f08f2ddb16d31571883eabc2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Sat, 21 Dec 2024 20:47:59 -0800 Subject: [PATCH 2/3] Adding changelog --- CHANGES.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 683d229420..09d7c9a9b0 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -31,6 +31,13 @@ casda - Support jobs which are in the SUSPENDED state (used when copying data) [#3134] +dace +^^^^ + +- Module has been removed as it was incompatible with server changes. A + standalone library called dace-query is available to access DACE + data. [#3162] + esa.hubble ^^^^^^^^^^ From fbf55b0f2c0618db3166f176fb91027d8e30fab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Sat, 21 Dec 2024 21:06:46 -0800 Subject: [PATCH 3/3] Remove docs reference --- docs/index.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 992c1b9c74..80b73e963c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -142,7 +142,7 @@ queries based on coordinates or object names. Some simple examples, using SIMBA >>> result_table = Simbad.query_object("m1") >>> result_table.pprint() main_id ra dec coo_err_maj coo_err_min coo_err_angle coo_wavelength coo_bibcode matched_id - deg deg mas mas deg + deg deg mas mas deg ------- ------- ------- ----------- ----------- ------------- -------------- ------------------- ---------- M 1 83.6324 22.0174 5000.0 5000.0 90 X 2022A&A...661A..38P M 1 @@ -156,8 +156,8 @@ All query tools allow coordinate-based queries: >>> r = 5 * u.arcminute >>> result_table = Simbad.query_region(c, radius=r) >>> result_table.pprint(show_unit=True, max_width=80, max_lines=5) - main_id ra ... coo_bibcode - deg ... + main_id ra ... coo_bibcode + deg ... ---------------------------- -------------- ... ------------------- ALMA J053514.4142-052220.792 83.8100591667 ... 2023MNRAS.522...56V ... ... ... ... @@ -182,7 +182,7 @@ uncomment the relevant configuration item(s), and insert your desired value(s). .. _astroquery_cache: - + Caching ------- @@ -222,7 +222,7 @@ Each service's cache is cleared with the ``clear_cache`` function within that se Astroquery-wide settings ^^^^^^^^^^^^^^^^^^^^^^^^ - + Whether caching is active and when cached files expire are controlled centrally through the astroquery ``cache_conf`` module, and shared among all services. Astroquery uses the Astropy configuration infrastructure, information about @@ -255,7 +255,6 @@ The following modules have been completed using a common API: cadc/cadc.rst casda/casda.rst linelists/cdms/cdms.rst - dace/dace.rst esa/hsa/hsa.rst esa/hubble/hubble.rst esa/iso/iso.rst