Skip to content

Commit 612fd82

Browse files
committed
docs: add warning and column_filters fix
1 parent a6ebb21 commit 612fd82

File tree

1 file changed

+70
-23
lines changed

1 file changed

+70
-23
lines changed

docs/eso/eso.rst

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ ESO Queries (`astroquery.eso`)
1212
**The WDB (Web DataBase) API is being deprecated and replaced by TAP (Table Access Protocol)**,
1313
a standardized interface for querying astronomical datasets using ADQL (Astronomical Data Query Language).
1414
While the Python interface remains the same, the values accepted by the ``columns`` and ``column_filters``
15-
parameters must reflect TAP's field names and ADQL syntax. This means that
15+
parameters must reflect TAP field names and ADQL syntax. This means that,
1616
although the structure of your code won't need to change, **the values you pass to the arguments**
1717
``columns`` **and** ``column_filters`` **must be revised** to comply with the new format.
1818

19-
In TAP, column_filters accepts SQL-like ADQL expressions. For example:
19+
In TAP, ``column_filters`` accepts ADQL expressions. For example:
2020

2121
.. doctest-skip::
2222

@@ -29,6 +29,7 @@ ESO Queries (`astroquery.eso`)
2929
}
3030

3131
Please review your queries carefully and update them accordingly to ensure compatibility with the new astroquery versions.
32+
See section :ref:`column-filters-fix`
3233

3334

3435
Getting started
@@ -223,12 +224,13 @@ return two columns: the date of observation and the name of the object.
223224

224225
.. doctest-remote-data::
225226
>>> table = eso.query_instrument(
226-
'midi',
227-
column_filters={
228-
'object':'NGC4151',
229-
'exp_start': "between '2008-01-01' and '2009-05-12'"
230-
},
231-
columns=['object', 'date_obs'])
227+
... 'midi',
228+
... column_filters={
229+
... 'object':'NGC4151',
230+
... 'exp_start': "between '2008-01-01' and '2009-05-12'"
231+
... },
232+
... columns=['object', 'date_obs']
233+
... )
232234
>>> table
233235
<Table length=196>
234236
object date_obs
@@ -263,16 +265,13 @@ query all-sky images from APICAM with ``luminance`` filter.
263265

264266
>>> eso.maxrec = -1 # Return all results
265267
# (i.e. do not truncate the query even if it is slow)
266-
>>> table = eso.query_main(column_filters={'instrument': 'APICAM',
267-
'filter_path': 'LUMINANCE'})
268-
269268
>>> table = eso.query_main(
270-
column_filters={
271-
'instrument': 'APICAM',
272-
'filter_path': 'LUMINANCE',
273-
'exp_start': "between '2019-04-26' and '2019-04-27'"
274-
}
275-
)
269+
... column_filters={
270+
... 'instrument': 'APICAM',
271+
... 'filter_path': 'LUMINANCE',
272+
... 'exp_start': "between '2019-04-26' and '2019-04-27'"
273+
... }
274+
... )
276275
>>> print(len(table))
277276
215
278277
>>> print(table.columns)
@@ -361,12 +360,11 @@ This method is detailed in the example below.
361360
.. doctest-remote-data::
362361

363362
>>> table = eso.query_instrument('midi',
364-
column_filters={
365-
'object': 'NGC4151',
366-
'date_obs': "<='2008-01-01'"
367-
},
368-
columns=['object', 'date_obs', 'dp_id'])
369-
363+
... column_filters={
364+
... 'object': 'NGC4151',
365+
... 'date_obs': "<='2008-01-01'"
366+
... },
367+
... columns=['object', 'date_obs', 'dp_id'])
370368
>>> table_headers = eso.get_headers(table["dp_id"])
371369
>>> len(table_headers.columns)
372370
336
@@ -431,6 +429,9 @@ in the call to :meth:`~astroquery.eso.EsoClass.retrieve_data`.
431429
Troubleshooting
432430
===============
433431

432+
Clearing the cache
433+
------------------
434+
434435
If you are repeatedly getting failed queries, or bad/out-of-date results, try clearing your cache:
435436

436437
.. code-block:: python
@@ -441,6 +442,52 @@ If you are repeatedly getting failed queries, or bad/out-of-date results, try cl
441442
If this function is unavailable, upgrade your version of astroquery.
442443
The ``clear_cache`` function was introduced in version 0.4.7.dev8479.
443444

445+
.. _column-filters-fix:
446+
447+
Using the correct ``column_filters``
448+
------------------------------------
449+
450+
Two concrete and relevant examples of fields present in WDB but not present in TAP/ADQL
451+
are ``stime`` and ``etime``. The following snippet shows how to adapt the filters to
452+
the TAP / ADQL syntax:
453+
454+
.. doctest-skip::
455+
456+
# The following filters won't work:
457+
column_filters = {
458+
'stime': '2024-01-01'
459+
'etime': '2024-12-31'
460+
}
461+
462+
# Replace by:
463+
column_filters = {
464+
'exp_start': "between '2024-01-01' and '2024-12-31'"
465+
}
466+
467+
# --- #
468+
469+
# The following filters won't work:
470+
column_filters = {
471+
'stime': '2024-01-01'
472+
}
473+
474+
# Replace by:
475+
column_filters = {
476+
'exp_start': "> '2024-01-01'"
477+
}
478+
479+
# --- #
480+
481+
# The following filters won't work:
482+
column_filters = {
483+
'etime': '2024-12-31'
484+
}
485+
486+
# Replace by:
487+
column_filters = {
488+
'exp_start': "< '2024-12-31'"
489+
}
490+
444491

445492
Reference/API
446493
=============

0 commit comments

Comments
 (0)