Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions astroquery/esa/euclid/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@
import pprint
import tarfile
import zipfile
from collections.abc import Iterable
from datetime import datetime

from astropy import units
from astropy import units as u
from astropy.coordinates import Angle
from astropy.units import Quantity
from collections.abc import Iterable
from datetime import datetime
from requests.exceptions import HTTPError

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

"""
if columns:
columns = ','.join(map(str, columns))
else:
columns = "*"
"""

query = """
SELECT
Expand Down
78 changes: 78 additions & 0 deletions astroquery/esa/euclid/tests/test_euclid_remote.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import astropy.units as u
import pytest
from astropy.coordinates import SkyCoord

from astroquery.esa.euclid import EuclidClass
from astroquery.utils.tap.model.filter import Filter


@pytest.mark.remote_data
def test_query_object_columns_with_radius():
euclid = EuclidClass()
sc = SkyCoord(ra=0 * u.deg, dec=0 * u.deg)
table = euclid.query_object(sc, radius=10 * u.arcsec, columns=['right_ascension'], async_job=True)
assert table.colnames == ['right_ascension', 'dist']


@pytest.mark.remote_data
@pytest.mark.filterwarnings("ignore::astropy.units.UnitsWarning")
def test_query_object_row_limit():
euclid = EuclidClass()
coord = SkyCoord(ra=265.8, dec=64.1, unit=(u.degree, u.degree), frame='icrs')
width = u.Quantity(0.1, u.deg)
height = u.Quantity(0.1, u.deg)
r = euclid.query_object(coordinate=coord, width=width, height=height, async_job=True, verbose=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails with a vounit warning, I would put that into a pytest.warns context manager here knowing that we will be able to clean it up once upstream is changing behaviour


assert len(r) == 50

euclid.ROW_LIMIT = 10
r = euclid.query_object(coordinate=coord, width=width, height=height, async_job=True)

assert len(r) == 10 == euclid.ROW_LIMIT

euclid.ROW_LIMIT = -1
r = euclid.query_object(coordinate=coord, width=width, height=height, async_job=True, verbose=True)

assert len(r) == 1948


@pytest.mark.remote_data
def test_cone_search_row_limit():
euclid = EuclidClass()
coord = SkyCoord(ra=265.8, dec=64.1, unit=(u.degree, u.degree), frame='icrs')
radius = u.Quantity(0.1, u.deg)
j = euclid.cone_search(coord, radius=radius, async_job=True)
r = j.get_results()

assert len(r) == euclid.ROW_LIMIT

euclid.ROW_LIMIT = 10
j = euclid.cone_search(coord, radius=radius, async_job=True)
r = j.get_results()

assert len(r) == 10 == euclid.ROW_LIMIT

euclid.ROW_LIMIT = -1
j = euclid.cone_search(coord, radius=radius, async_job=True)
r = j.get_results()

assert len(r) == 14606


@pytest.mark.remote_data
def test_search_async_jobs():
euclid = EuclidClass()
jobfilter = Filter()
jobfilter.limit = 10
jobs = euclid.search_async_jobs(jobfilter=jobfilter, verbose=True)
assert len(jobs) == 10


@pytest.mark.remote_data
def test_get_tables():
euclid = EuclidClass()
r = euclid.load_tables()
assert len(r) > 1

table = euclid.load_table("catalogue.mer_catalogue")
assert len(table.columns) == 471
34 changes: 14 additions & 20 deletions docs/esa/euclid/euclid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,7 @@ In the following example, for the Clusters of Galaxies category, and the group G

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

.. Skipping authentication requiring examples
.. doctest-skip::
.. doctest-remote-data::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this example doesn't require authentication any more? It indeed seems to run for me locally except that we don’t get the expected outputs


>>> #example cone search for source NGC6505
>>> from astroquery.esa.euclid import Euclid
Expand All @@ -298,21 +297,20 @@ This query performs a cone search centered at the specified ra/dec coordinates w
Found 27 results
>>> cone_results['tile_index', 'creation_date', 'ra', 'dec', 'file_name', 'file_path', 'datalabs_path', 'filter_name', 'dist'][:5]
<Table length=5>
tile_index creation_date ra dec file_name file_path datalabs_path filter_name dist
int64 str23 float64 float64 str88 str55 str43 str11 float64
---------- ----------------------- ----------- ------- ------------------------------------------------------------------------------------- ------------------------------------------------------- ------------------------------------------- ----------- -------------------
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
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
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
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
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
tile_index creation_date ra dec ... file_path datalabs_path filter_name dist
int64 str23 float64 float64 ... str55 str43 str11 float64
---------- ----------------------- ----------- ------- ... ------------------------------------------------------- ------------------------------------------- ----------- -------------------
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
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
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
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
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



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

.. Skipping authentication requiring examples
.. doctest-skip::
.. doctest-remote-data::

>>> Euclid.ROW_LIMIT = 2
>>> 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)
Expand All @@ -336,9 +334,7 @@ The following example searches for all the sources contained in an squared regio

The method returns the job results as astropy.table


.. Skipping authentication requiring examples
.. doctest-skip::
.. doctest-remote-data::

>>> # Search for objects around a given position with the default catalog catalogue.mer_catalogue
>>> from astroquery.esa.euclid import Euclid
Expand Down Expand Up @@ -371,8 +367,7 @@ Synchronous queries like this one return a limited number of rows -> 2000

The previous query can be executed as an asynchronous version:

.. Skipping authentication requiring examples
.. doctest-skip::
.. doctest-remote-data::

>>> from astroquery.esa.euclid import Euclid
>>> from astropy.coordinates import SkyCoord
Expand Down Expand Up @@ -835,8 +830,7 @@ In the Euclid archive user tables can be shared among user groups.

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

.. Skipping authentication requiring examples
.. doctest-skip::
.. doctest-remote-data::

>>> from astroquery.esa.euclid import Euclid
>>> tables = Euclid.load_tables(only_names=True, include_shared_tables=True)
Expand Down Expand Up @@ -977,7 +971,7 @@ table named: user_<your_login_name>.'t'<job_id>:

>>> from astroquery.esa.euclid import Euclid
>>> Euclid.login()
>>> job_1 = Euclid.launch_job_async("select top 10 * from Eucliddr3.Euclid_source")
>>> job_1 = Euclid.launch_job_async("select top 10 * from catalogue.mer_catalogue")
>>> Euclid.upload_table_from_job(job=job_1)
Created table 't1539932994481O' from job: '1539932994481O'.

Expand Down
Loading