Skip to content

Commit d9dde47

Browse files
Jorge Fernandez HernandezJorge Fernandez Hernandez
authored andcommitted
EUCLIDSWRQ-247 New remote tests for euclid
New remote tests for euclid
1 parent 2b851d1 commit d9dde47

File tree

3 files changed

+89
-110
lines changed

3 files changed

+89
-110
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: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
def test_query_object_row_limit():
19+
euclid = EuclidClass()
20+
coord = SkyCoord(ra=265.8, dec=64.1, unit=(u.degree, u.degree), frame='icrs')
21+
width = u.Quantity(0.1, u.deg)
22+
height = u.Quantity(0.1, u.deg)
23+
r = euclid.query_object(coordinate=coord, width=width, height=height, async_job=True, verbose=True)
24+
25+
assert len(r) == 50
26+
27+
euclid.ROW_LIMIT = 10
28+
r = euclid.query_object(coordinate=coord, width=width, height=height, async_job=True)
29+
30+
assert len(r) == 10 == euclid.ROW_LIMIT
31+
32+
euclid.ROW_LIMIT = -1
33+
r = euclid.query_object(coordinate=coord, width=width, height=height, async_job=True, verbose=True)
34+
35+
assert len(r) == 1948
36+
37+
38+
@pytest.mark.remote_data
39+
def test_cone_search_row_limit():
40+
euclid = EuclidClass()
41+
coord = SkyCoord(ra=265.8, dec=64.1, unit=(u.degree, u.degree), frame='icrs')
42+
radius = u.Quantity(0.1, u.deg)
43+
j = euclid.cone_search(coord, radius=radius, async_job=True)
44+
r = j.get_results()
45+
46+
assert len(r) == euclid.ROW_LIMIT
47+
48+
euclid.ROW_LIMIT = 10
49+
j = euclid.cone_search(coord, radius=radius, async_job=True)
50+
r = j.get_results()
51+
52+
assert len(r) == 10 == euclid.ROW_LIMIT
53+
54+
euclid.ROW_LIMIT = -1
55+
j = euclid.cone_search(coord, radius=radius, async_job=True)
56+
r = j.get_results()
57+
58+
assert len(r) == 14606
59+
60+
61+
@pytest.mark.remote_data
62+
def test_search_async_jobs():
63+
euclid = EuclidClass()
64+
jobfilter = Filter()
65+
jobfilter.limit = 10
66+
jobs = euclid.search_async_jobs(jobfilter=jobfilter, verbose=True)
67+
assert len(jobs) == 10
68+
69+
70+
@pytest.mark.remote_data
71+
def test_get_tables():
72+
euclid = EuclidClass()
73+
r = euclid.load_tables()
74+
assert len(r) > 1
75+
76+
table = euclid.load_table("catalogue.mer_catalogue")
77+
assert len(table.columns) == 471

0 commit comments

Comments
 (0)