Skip to content

Commit 3c9388e

Browse files
authored
Merge pull request #3407 from esdc-esac-esa-int/ESA_euclid_EUCLIDSWRQ-247_new_remote_tests
2 parents c933200 + f31df50 commit 3c9388e

File tree

3 files changed

+119
-50
lines changed

3 files changed

+119
-50
lines changed

astroquery/esa/euclid/core.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111
import pprint
1212
import tarfile
1313
import zipfile
14-
from collections.abc import Iterable
15-
from datetime import datetime
16-
1714
from astropy import units
1815
from astropy import units as u
1916
from astropy.coordinates import Angle
2017
from astropy.units import Quantity
18+
from collections.abc import Iterable
19+
from datetime import datetime
2120
from requests.exceptions import HTTPError
2221

2322
from astroquery import log
@@ -408,7 +407,8 @@ def query_object(self, coordinate, *, radius=None, width=None, height=None,
408407
height_quantity = self.__get_quantity_input(height, "height")
409408
width_deg = width_quantity.to(units.deg)
410409
height_deg = height_quantity.to(units.deg)
411-
query = ("SELECT DISTANCE(POINT('ICRS'," + self.main_table_ra + "," + self.main_table_dec + "), \
410+
query = ("SELECT " + (("TOP " + str(self.ROW_LIMIT)) if self.ROW_LIMIT > 0 else "")
411+
+ " DISTANCE(POINT('ICRS'," + self.main_table_ra + "," + self.main_table_dec + "), \
412412
POINT('ICRS'," + str(ra) + "," + str(dec) + ")) AS dist, * \
413413
FROM " + self.main_table + " WHERE CONTAINS(\
414414
POINT('ICRS'," + self.main_table_ra + "," + self.main_table_dec + "),\
@@ -560,12 +560,10 @@ def cone_search(self, coordinate, radius, *,
560560
ra_column_name = self.main_table_ra
561561
dec_column_name = self.main_table_dec
562562

563-
"""
564563
if columns:
565564
columns = ','.join(map(str, columns))
566565
else:
567566
columns = "*"
568-
"""
569567

570568
query = """
571569
SELECT
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import astropy.units as u
2+
import pytest
3+
from astropy.coordinates import SkyCoord
4+
5+
from astroquery.esa.euclid import EuclidClass
6+
from astroquery.utils.tap.model.filter import Filter
7+
8+
9+
@pytest.mark.remote_data
10+
def test_query_object_columns_with_radius():
11+
euclid = EuclidClass()
12+
sc = SkyCoord(ra=0 * u.deg, dec=0 * u.deg)
13+
table = euclid.query_object(sc, radius=10 * u.arcsec, columns=['right_ascension'], async_job=True)
14+
assert table.colnames == ['right_ascension', 'dist']
15+
16+
17+
@pytest.mark.remote_data
18+
@pytest.mark.filterwarnings("ignore::astropy.units.UnitsWarning")
19+
def test_query_object_row_limit():
20+
euclid = EuclidClass()
21+
coord = SkyCoord(ra=265.8, dec=64.1, unit=(u.degree, u.degree), frame='icrs')
22+
width = u.Quantity(0.1, u.deg)
23+
height = u.Quantity(0.1, u.deg)
24+
r = euclid.query_object(coordinate=coord, width=width, height=height, async_job=True, verbose=True)
25+
26+
assert len(r) == 50
27+
28+
euclid.ROW_LIMIT = 10
29+
r = euclid.query_object(coordinate=coord, width=width, height=height, async_job=True)
30+
31+
assert len(r) == 10 == euclid.ROW_LIMIT
32+
33+
euclid.ROW_LIMIT = -1
34+
r = euclid.query_object(coordinate=coord, width=width, height=height, async_job=True, verbose=True)
35+
36+
assert len(r) == 1948
37+
38+
39+
@pytest.mark.remote_data
40+
def test_cone_search_row_limit():
41+
euclid = EuclidClass()
42+
coord = SkyCoord(ra=265.8, dec=64.1, unit=(u.degree, u.degree), frame='icrs')
43+
radius = u.Quantity(0.1, u.deg)
44+
j = euclid.cone_search(coord, radius=radius, async_job=True)
45+
r = j.get_results()
46+
47+
assert len(r) == euclid.ROW_LIMIT
48+
49+
euclid.ROW_LIMIT = 10
50+
j = euclid.cone_search(coord, radius=radius, async_job=True)
51+
r = j.get_results()
52+
53+
assert len(r) == 10 == euclid.ROW_LIMIT
54+
55+
euclid.ROW_LIMIT = -1
56+
j = euclid.cone_search(coord, radius=radius, async_job=True)
57+
r = j.get_results()
58+
59+
assert len(r) == 14606
60+
61+
62+
@pytest.mark.remote_data
63+
def test_search_async_jobs():
64+
euclid = EuclidClass()
65+
jobfilter = Filter()
66+
jobfilter.limit = 10
67+
jobs = euclid.search_async_jobs(jobfilter=jobfilter, verbose=True)
68+
assert len(jobs) == 10
69+
70+
71+
@pytest.mark.remote_data
72+
def test_get_tables():
73+
euclid = EuclidClass()
74+
r = euclid.load_tables()
75+
assert len(r) > 1
76+
77+
table = euclid.load_table("catalogue.mer_catalogue")
78+
assert len(table.columns) == 471

docs/esa/euclid/euclid.rst

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
ESA EUCLID Archive (`astroquery.esa.euclid`)
55
********************************************
66

7+
78
Euclid is an ESA mission to map the geometry of the dark Universe. The mission investigates the distance-redshift
89
relationship and the evolution of cosmic structures. The space telescope creates a great map of the large-scale
910
structure of the Universe across space and time by observing billions of galaxies out to 10 billion light-years, across
@@ -80,7 +81,9 @@ Examples
8081

8182
It is highly recommended checking the status of Euclid TAP before executing this module. To do this:
8283

83-
.. doctest-remote-data::
84+
.. almost all code examples require remote-data access, thus only using this
85+
one at the first example
86+
.. doctest-remote-data-all::
8487

8588
>>> from astroquery.esa.euclid import Euclid
8689
>>> Euclid.get_status_messages()
@@ -122,14 +125,10 @@ The description of these data products can be found on the Data Product Definiti
122125

123126
By default, the object *Euclid*
124127

125-
.. doctest-remote-data::
126-
127128
>>> from astroquery.esa.euclid import Euclid
128129

129130
makes use of the *PDR* environment. In order to make use of a different one, it is necessary to instantiate the class EuclidClass
130131

131-
.. doctest-remote-data::
132-
133132
>>> from astroquery.esa.euclid import EuclidClass
134133
>>> euclid = EuclidClass(environment='IDR')
135134

@@ -146,8 +145,6 @@ Table and column metadata are specified by IVOA TAP_ recommendation (to access t
146145

147146
To load only table names metadata (TAP+ capability):
148147

149-
.. doctest-remote-data::
150-
151148
>>> from astroquery.esa.euclid import Euclid
152149
>>> tables = Euclid.load_tables(only_names=True, include_shared_tables=True)
153150
INFO: Retrieving tables... [astroquery.utils.tap.core]
@@ -177,8 +174,6 @@ To load only table names metadata (TAP+ capability):
177174

178175
To load all table metadata (TAP compatible):
179176

180-
.. doctest-remote-data::
181-
182177
>>> from astroquery.esa.euclid import Euclid
183178
>>> tables = Euclid.load_tables()
184179
INFO: Retrieving tables... [astroquery.utils.tap.core]
@@ -193,8 +188,6 @@ To load all table metadata (TAP compatible):
193188

194189
To load only a table (TAP+ capability) and inspect its columns:
195190

196-
.. doctest-remote-data::
197-
198191
>>> from astroquery.esa.euclid import Euclid
199192
>>> raw_detector_table = Euclid.load_table('sedm.raw_detector')
200193
>>> print(raw_detector_table) # doctest: +SKIP
@@ -282,9 +275,6 @@ In the following example, for the Clusters of Galaxies category, and the group G
282275

283276
This query performs a cone search centered at the specified ra/dec coordinates with the provided radius argument.
284277

285-
.. Skipping authentication requiring examples
286-
.. doctest-skip::
287-
288278
>>> #example cone search for source NGC6505
289279
>>> from astroquery.esa.euclid import Euclid
290280
>>> from astropy.coordinates import SkyCoord
@@ -296,33 +286,32 @@ This query performs a cone search centered at the specified ra/dec coordinates w
296286
>>> cone_results = job.get_results()
297287
>>> print("Found", len(cone_results), "results")
298288
Found 27 results
299-
>>> cone_results['tile_index', 'creation_date', 'ra', 'dec', 'file_name', 'file_path', 'datalabs_path', 'filter_name', 'dist'][:5]
289+
>>> cone_results['tile_index', 'creation_date', 'ra', 'dec', 'file_name', 'file_path', 'datalabs_path', 'filter_name', 'dist'][:5] # doctest: +IGNORE_OUTPUT
300290
<Table length=5>
301-
tile_index creation_date ra dec file_name file_path datalabs_path filter_name dist
302-
int64 str23 float64 float64 str88 str55 str43 str11 float64
303-
---------- ----------------------- ----------- ------- ------------------------------------------------------------------------------------- ------------------------------------------------------- ------------------------------------------- ----------- -------------------
304-
102158889 2024-10-26T14:01:21.038 267.3807789 65.4983 EUC_MER_BGSUB-MOSAIC-CFIS-R_TILE102158889-4366B7_20241024T203624.450577Z_00.00.fits /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/MEGACAM /data/euclid_q1/Q1_R1/MER/102158889/MEGACAM MEGACAM_r 0.16895922479034217
305-
102158889 2024-10-26T13:50:13.676 267.3807789 65.4983 EUC_MER_BGSUB-MOSAIC-WISHES-G_TILE102158889-3DC3C3_20241024T205647.635112Z_00.00.fits /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/HSC /data/euclid_q1/Q1_R1/MER/102158889/HSC HSC_g 0.16895922479034217
306-
102158889 2024-10-26T13:37:09.628 267.3807789 65.4983 EUC_MER_BGSUB-MOSAIC-NIR-Y_TILE102158889-AC6585_20241024T225321.344048Z_00.00.fits /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/NISP /data/euclid_q1/Q1_R1/MER/102158889/NISP NIR_Y 0.16895922479034217
307-
102158889 2024-10-26T14:05:09.98 267.3807789 65.4983 EUC_MER_BGSUB-MOSAIC-CFIS-U_TILE102158889-9E97F_20241024T204431.839748Z_00.00.fits /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/MEGACAM /data/euclid_q1/Q1_R1/MER/102158889/MEGACAM MEGACAM_u 0.16895922479034217
308-
102158889 2024-10-26T13:10:32.453 267.3807789 65.4983 EUC_MER_BGSUB-MOSAIC-NIR-H_TILE102158889-ED035A_20241024T212936.705156Z_00.00.fits /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/NISP /data/euclid_q1/Q1_R1/MER/102158889/NISP NIR_H 0.16895922479034217
291+
tile_index creation_date ra dec ... file_path datalabs_path filter_name dist
292+
int64 str23 float64 float64 ... str55 str43 str11 float64
293+
---------- ----------------------- ----------- ------- ... ------------------------------------------------------- ------------------------------------------- ----------- -------------------
294+
102158889 2024-10-26T14:01:21.038 267.3807789 65.4983 ... /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/MEGACAM /data/euclid_q1/Q1_R1/MER/102158889/MEGACAM MEGACAM_r 0.16895922479034217
295+
102158889 2024-10-26T13:50:13.676 267.3807789 65.4983 ... /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/HSC /data/euclid_q1/Q1_R1/MER/102158889/HSC HSC_g 0.16895922479034217
296+
102158889 2024-10-26T13:37:09.628 267.3807789 65.4983 ... /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/NISP /data/euclid_q1/Q1_R1/MER/102158889/NISP NIR_Y 0.16895922479034217
297+
102158889 2024-10-26T14:05:09.98 267.3807789 65.4983 ... /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/MEGACAM /data/euclid_q1/Q1_R1/MER/102158889/MEGACAM MEGACAM_u 0.16895922479034217
298+
102158889 2024-10-26T13:10:32.453 267.3807789 65.4983 ... /euclid/repository_idr/iqr1/Q1_R1/MER/102158889/NISP /data/euclid_q1/Q1_R1/MER/102158889/NISP NIR_H 0.16895922479034217
309299

310300

311301

312302
Queries return a limited number of rows controlled by ``Euclid.ROW_LIMIT``. To change the default behaviour set this appropriately.
313303

314-
.. Skipping authentication requiring examples
315-
.. doctest-skip::
316-
317304
>>> Euclid.ROW_LIMIT = 2
318305
>>> job = Euclid.cone_search(coordinate=coord, radius=radius, table_name="sedm.mosaic_product", ra_column_name="ra", dec_column_name="dec", columns="*", async_job=True)
306+
INFO: Query finished. [astroquery.utils.tap.core]
319307
>>> cone_results = job.get_results()
320-
>>> print("Found", len(cone_results), "results")
308+
>>> print(f"Found {len(cone_results)} results")
321309
Found 2 results
322310

323-
324311
To return an unlimited number of rows set ``Euclid.ROW_LIMIT`` to -1.
325312

313+
>>> Euclid.ROW_LIMIT = -1
314+
326315

327316
1.3. Query object
328317
^^^^^^^^^^^^^^^^^
@@ -336,19 +325,15 @@ The following example searches for all the sources contained in an squared regio
336325

337326
The method returns the job results as astropy.table
338327

339-
340-
.. Skipping authentication requiring examples
341-
.. doctest-skip::
342-
343328
>>> # Search for objects around a given position with the default catalog catalogue.mer_catalogue
344329
>>> from astroquery.esa.euclid import Euclid
345330
>>> from astropy.coordinates import SkyCoord
346331
>>> import astropy.units as u
347332
>>> coord = SkyCoord(ra=60.3372780005097, dec=-49.93184727724773, unit=(u.degree, u.degree), frame='icrs')
348-
>>> table = Euclid.query_object(coordinate=coord, width=u.Quantity(0.1, u.deg), height= u.Quantity(0.1, u.deg))
333+
>>> table = Euclid.query_object(coordinate=coord, width=u.Quantity(0.1, u.deg), height= u.Quantity(0.1, u.deg)) # doctest: +IGNORE_WARNINGS
349334
>>> print("Found a total of", len(table), "query results")
350335
Found a total of 2000 query results
351-
>>> print(table)
336+
>>> print(table) # doctest: +IGNORE_OUTPUT
352337
dist avg_trans_wave_g_ext_decam avg_trans_wave_g_ext_hsc avg_trans_wave_g_ext_jpcam avg_trans_wave_g_ext_lsst avg_trans_wave_h avg_trans_wave_i_ext_decam ... sersic_fract_z_ext_panstarrs_disk_sersic sersic_fract_z_ext_panstarrs_disk_sersic_err she_flag spurious_flag spurious_prob variable_flag vis_det
353338
--------------------- -------------------------- ------------------------ -------------------------- ------------------------- ---------------- -------------------------- ... ---------------------------------------- -------------------------------------------- -------- ------------- ---------------------- ------------- -------
354339
3.566798805594703e-06 4826.7998046875 -- -- -- -- 7826.669921875 ... -- -- -- 0 0.15743961930274963 -- 1
@@ -371,20 +356,17 @@ Synchronous queries like this one return a limited number of rows -> 2000
371356

372357
The previous query can be executed as an asynchronous version:
373358

374-
.. Skipping authentication requiring examples
375-
.. doctest-skip::
376-
377359
>>> from astroquery.esa.euclid import Euclid
378360
>>> from astropy.coordinates import SkyCoord
379361
>>> import astropy.units as u
380362
>>> coord = SkyCoord(ra=60.3372780005097, dec=-49.93184727724773, unit=(u.degree, u.degree), frame='icrs')
381363
>>> width=u.Quantity(0.1, u.deg)
382364
>>> height= u.Quantity(0.1, u.deg)
383-
>>> table_async = Euclid.query_object(coordinate=coord, width=width, height=height, async_job=True)
365+
>>> table_async = Euclid.query_object(coordinate=coord, width=width, height=height, async_job=True) # doctest: +IGNORE_WARNINGS
384366
INFO: Query finished. [astroquery.utils.tap.core]
385-
>>> print("Found a total of", len(table_async), "query results")
367+
>>> print(f"Found a total of {len(table_async)} query results")
386368
Found a total of 2895 query results
387-
>>> print(table_async)
369+
>>> print(table_async) # doctest: +IGNORE_OUTPUT
388370
dist avg_trans_wave_g_ext_decam avg_trans_wave_g_ext_hsc avg_trans_wave_g_ext_jpcam avg_trans_wave_g_ext_lsst avg_trans_wave_h avg_trans_wave_i_ext_decam ... sersic_fract_z_ext_panstarrs_disk_sersic sersic_fract_z_ext_panstarrs_disk_sersic_err she_flag spurious_flag spurious_prob variable_flag vis_det
389371
--------------------- -------------------------- ------------------------ -------------------------- ------------------------- ---------------- -------------------------- ... ---------------------------------------- -------------------------------------------- -------- ------------- ---------------------- ------------- -------
390372
3.566798805594703e-06 4826.7998046875 -- -- -- -- 7826.669921875 ... -- -- -- 0 0.15743961930274963 -- 1
@@ -835,13 +817,24 @@ In the Euclid archive user tables can be shared among user groups.
835817

836818
To obtain a list of the tables shared to a user type the following:
837819

838-
.. Skipping authentication requiring examples
839-
.. doctest-skip::
840-
841820
>>> from astroquery.esa.euclid import Euclid
842821
>>> tables = Euclid.load_tables(only_names=True, include_shared_tables=True)
822+
INFO: Retrieving tables... [astroquery.utils.tap.core]
823+
INFO: Parsing tables... [astroquery.utils.tap.core]
824+
INFO: Done. [astroquery.utils.tap.core]
843825
>>> for table in tables:
844826
... print(table.get_qualified_name())
827+
catalogue.mer_catalogue
828+
catalogue.mer_cutouts
829+
catalogue.mer_morphology
830+
catalogue.phz_classification
831+
catalogue.phz_galaxy_sed
832+
...
833+
tap_schema.columns
834+
tap_schema.key_columns
835+
tap_schema.keys
836+
tap_schema.schemas
837+
tap_schema.tables
845838

846839
.. _uploading_table_to_user_space:
847840

@@ -977,7 +970,7 @@ table named: user_<your_login_name>.'t'<job_id>:
977970

978971
>>> from astroquery.esa.euclid import Euclid
979972
>>> Euclid.login()
980-
>>> job_1 = Euclid.launch_job_async("select top 10 * from Eucliddr3.Euclid_source")
973+
>>> job_1 = Euclid.launch_job_async("select top 10 * from catalogue.mer_catalogue")
981974
>>> Euclid.upload_table_from_job(job=job_1)
982975
Created table 't1539932994481O' from job: '1539932994481O'.
983976

0 commit comments

Comments
 (0)