Skip to content

Commit

Permalink
Replace 'survey' by 'collection' accross eso module
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmcloaiza committed Nov 28, 2024
1 parent 365b479 commit 79ff276
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
48 changes: 24 additions & 24 deletions astroquery/eso/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def tap_url():
def __init__(self):
super().__init__()
self._instrument_list = None
self._survey_list = None
self._collection_list = None
self._auth_info: Optional[AuthInfo] = None

def _activate_form(self, response, *, form_index=0, form_id=None, inputs={},
Expand Down Expand Up @@ -189,7 +189,7 @@ def _activate_form(self, response, *, form_index=0, form_id=None, inputs={},
value = form_elem.select(
'option[value]')[0].get('value')
else:
# survey form just uses text, not value
# form just uses text, not value
for option in form_elem.select('option'):
if option.get('selected') is not None:
value = str(option.string)
Expand Down Expand Up @@ -362,39 +362,39 @@ def list_instruments(self, *, cache=True):

# TODO remove hardcoded values
def list_collections(self, *, cache=True):
""" List all the available surveys (phase 3) in the ESO archive.
""" List all the available collections (phase 3) in the ESO archive.
Returns
-------
survey_list : list of strings
collection_list : list of strings
cache : bool
Defaults to True. If set overrides global caching behavior.
See :ref:`caching documentation <astroquery_cache>`.
"""
if self._survey_list is None:
self._survey_list = []
if self._collection_list is None:
self._collection_list = []
tap = pyvo.dal.TAPService(EsoClass.tap_url())
query = """

Check warning on line 377 in astroquery/eso/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/eso/core.py#L374-L377

Added lines #L374 - L377 were not covered by tests
SELECT distinct obs_collection from ivoa.ObsCore where obs_collection != 'ALMA'
"""

res = tap.search(query)
self._survey_list = list(res["obs_collection"].data)
return self._survey_list
self._collection_list = list(res["obs_collection"].data)
return self._collection_list

Check warning on line 383 in astroquery/eso/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/eso/core.py#L381-L383

Added lines #L381 - L383 were not covered by tests


def query_collections(self, *, surveys='', cache=True,
def query_collections(self, *, collections='', cache=True,
help=False, open_form=False, **kwargs):
"""
Query survey Phase 3 data contained in the ESO archive.
Query collection Phase 3 data contained in the ESO archive.
Parameters
----------
survey : string or list
Name of the survey(s) to query. Should beone or more of the
names returned by `~astroquery.eso.EsoClass.list_surveys`. If
collection : string or list
Name of the collection(s) to query. Should beone or more of the
names returned by `~astroquery.eso.EsoClass.list_collections`. If
specified as a string, should be a comma-separated list of
survey names.
collection names.
cache : bool
Defaults to True. If set overrides global caching behavior.
See :ref:`caching documentation <astroquery_cache>`.
Expand All @@ -403,7 +403,7 @@ def query_collections(self, *, surveys='', cache=True,
-------
table : `~astropy.table.Table` or `None`
A table representing the data available in the archive for the
specified survey, matching the constraints specified in ``kwargs``.
specified collection, matching the constraints specified in ``kwargs``.
The number of rows returned is capped by the ROW_LIMIT
configuration item. `None` is returned when the query has no
results.
Expand All @@ -414,24 +414,24 @@ def query_collections(self, *, surveys='', cache=True,
if open_form:
webbrowser.open(url)
elif help:
self._print_surveys_help(url, cache=cache)
self._print_collections_help(url, cache=cache)

Check warning on line 417 in astroquery/eso/core.py

View check run for this annotation

Codecov / codecov/patch

astroquery/eso/core.py#L417

Added line #L417 was not covered by tests
else:
survey_form = self._request("GET", url, cache=cache)
collection_form = self._request("GET", url, cache=cache)
query_dict = kwargs
query_dict["wdbo"] = "csv/download"
if isinstance(surveys, str):
surveys = surveys.split(",")
query_dict['collection_name'] = surveys
if isinstance(collections, str):
collections = collections.split(",")
query_dict['collection_name'] = collections
if self.ROW_LIMIT >= 0:
query_dict["max_rows_returned"] = int(self.ROW_LIMIT)
else:
query_dict["max_rows_returned"] = 10000

survey_response = self._activate_form(survey_form, form_index=0,
collection_response = self._activate_form(collection_form, form_index=0,
form_id='queryform',
inputs=query_dict, cache=cache)

content = survey_response.content
content = collection_response.content
# First line is always garbage
content = content.split(b'\n', 1)[1]
log.debug("Response content:\n{0}".format(content))
Expand Down Expand Up @@ -972,12 +972,12 @@ def _print_query_help(self, url, *, cache=True):
log.info("\n".join(result_string))
return result_string

def _print_surveys_help(self, url, *, cache=True):
def _print_collections_help(self, url, *, cache=True):
"""
Download a form and print it in a quasi-human-readable way
"""
log.info("List of the parameters accepted by the "
"surveys query.")
"collections query.")
log.info("The presence of a column in the result table can be "
"controlled if prefixed with a [ ] checkbox.")
log.info("The default columns in the result table are shown as "
Expand Down
36 changes: 18 additions & 18 deletions astroquery/eso/tests/test_eso_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# TODO: make this a configuration item
SKIP_SLOW = True

SGRA_SURVEYS = ['195.B-0283', 'GIRAFFE', 'HARPS', 'HAWKI', 'KMOS',
SGRA_COLLECTIONS = ['195.B-0283', 'GIRAFFE', 'HARPS', 'HAWKI', 'KMOS',
'ERIS-SPIFFIER',
'MW-BULGE-PSFPHOT', 'VPHASplus', 'VVV', 'VVVX', 'XSHOOTER']

Expand All @@ -37,31 +37,31 @@ def test_SgrAstar(self, tmp_path):
result_i = eso.query_instrument('midi', coord1=266.41681662,
coord2=-29.00782497, cache=False)

surveys = eso.list_surveys(cache=False)
assert len(surveys) > 0
# result_s = eso.query_surveys('VVV', target='Sgr A*')
collections = eso.list_collections(cache=False)
assert len(collections) > 0
# result_s = eso.query_collections('VVV', target='Sgr A*')
# Equivalent, does not depend on SESAME:
result_s = eso.query_surveys(surveys='VVV', coord1=266.41681662,
result_s = eso.query_collections(collections='VVV', coord1=266.41681662,
coord2=-29.00782497,
box='01 00 00',
cache=False)

assert 'midi' in instruments
assert result_i is not None
assert 'VVV' in surveys
assert 'VVV' in collections
assert result_s is not None
assert 'Object' in result_s.colnames
assert 'b333' in result_s['Object']

def test_multisurvey(self, tmp_path):
def test_multicollection(self, tmp_path):

eso = Eso()
eso.cache_location = tmp_path
eso.ROW_LIMIT = 1000
# first b333 was at 157
# first pistol....?

result_s = eso.query_surveys(surveys=['VVV', 'XSHOOTER'],
result_s = eso.query_collections(collections=['VVV', 'XSHOOTER'],
coord1=266.41681662,
coord2=-29.00782497,
box='01 00 00',
Expand All @@ -75,12 +75,12 @@ def test_multisurvey(self, tmp_path):
def test_empty_return(self):
# test for empty return with an object from the North
eso = Eso()
surveys = eso.list_surveys(cache=False)
assert len(surveys) > 0
collections = eso.list_collections(cache=False)
assert len(collections) > 0

# Avoid SESAME
with pytest.warns(NoResultsWarning):
result_s = eso.query_surveys(surveys=surveys[0], coord1=202.469575,
result_s = eso.query_collections(collections=collections[0], coord1=202.469575,
coord2=47.195258, cache=False)

assert result_s is None
Expand Down Expand Up @@ -161,28 +161,28 @@ def test_each_instrument_SgrAstar(self, tmp_path):
else:
assert len(result) > 0

def test_each_survey_and_SgrAstar(self, tmp_path):
def test_each_collection_and_SgrAstar(self, tmp_path):
eso = Eso()
eso.cache_location = tmp_path
eso.ROW_LIMIT = 5

surveys = eso.list_surveys(cache=False)
for survey in surveys:
if survey in SGRA_SURVEYS:
result_s = eso.query_surveys(surveys=survey, coord1=266.41681662,
collections = eso.list_collections(cache=False)
for collection in collections:
if collection in SGRA_COLLECTIONS:
result_s = eso.query_collections(collections=collection, coord1=266.41681662,
coord2=-29.00782497,
box='01 00 00',
cache=False)
assert len(result_s) > 0
else:
with pytest.warns(NoResultsWarning):
result_s = eso.query_surveys(surveys=survey, coord1=266.41681662,
result_s = eso.query_collections(collections=collection, coord1=266.41681662,
coord2=-29.00782497,
box='01 00 00',
cache=False)
assert result_s is None

generic_result = eso.query_surveys(surveys=survey)
generic_result = eso.query_collections(collections=collection)
assert len(generic_result) > 0

def test_mixed_case_instrument(self, tmp_path):
Expand Down
18 changes: 9 additions & 9 deletions docs/eso/eso.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is a python interface for querying the ESO archive web service.
For now, it supports the following:

- listing available instruments
- listing available surveys (phase 3)
- listing available collections (phase 3)
- searching all instrument specific raw data: http://archive.eso.org/cms/eso-data/instrument-specific-query-forms.html
- searching data products (phase 3): http://archive.eso.org/wdb/wdb/adp/phase3_main/form
- downloading data by dataset identifiers: http://archive.eso.org/cms/eso-data/eso-data-direct-retrieval.html
Expand Down Expand Up @@ -276,28 +276,28 @@ Query the ESO archive for reduced data
======================================

In addition to raw data, ESO makes available processed data.
In this section, we show how to obtain these processed survey data from the archive.
In this section, we show how to obtain these processed collection data from the archive.

Identify available surveys
Identify available collections
--------------------------

The list of available surveys can be obtained with :meth:`astroquery.eso.EsoClass.list_surveys` as follows:
The list of available collections can be obtained with :meth:`astroquery.eso.EsoClass.list_collections` as follows:

.. doctest-remote-data::

>>> surveys = eso.list_surveys()
>>> collections = eso.list_collections()

Query a specific survey with constraints
Query a specific collection with constraints
----------------------------------------

Let's assume that we work with the ``HARPS`` survey, and that we are interested in
Let's assume that we work with the ``HARPS`` collection, and that we are interested in
target ``HD203608``.
The archive can be queried as follows:


.. doctest-remote-data::

>>> table = eso.query_surveys(surveys='HARPS', cache=False, target="HD203608")
>>> table = eso.query_collections(collections='HARPS', cache=False, target="HD203608")

The returned table has an ``ARCFILE`` column. It can be used to retrieve the datasets with
:meth:`astroquery.eso.EsoClass.retrieve_data` (see next section).
Expand Down Expand Up @@ -356,7 +356,7 @@ Downloading datasets from the archive
=====================================

Continuing from the query with constraints example, the first two datasets are selected,
using their data product IDs ``DP.ID`` (or ``ARCFILE`` for surveys), and retrieved from the ESO archive.
using their data product IDs ``DP.ID`` (or ``ARCFILE`` for collections), and retrieved from the ESO archive.

.. doctest-skip::

Expand Down

0 comments on commit 79ff276

Please sign in to comment.