Skip to content

Commit 054526a

Browse files
authored
Merge pull request #3147 from cds-astro/vizier-ucd
fix: search by UCD bugged
2 parents d27ac56 + 4799e0e commit 054526a

File tree

4 files changed

+53
-45
lines changed

4 files changed

+53
-45
lines changed

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ skyview
155155
- Overlay arguments ``lut``, ``grid``, and ``gridlabel`` are removed, as they
156156
only apply to output types not returned by Astroquery [#2979]
157157

158+
vizier
159+
^^^^^^
160+
161+
- Fixed search by UCD -- they were ignored. [#3147]
162+
158163
vsa
159164
^^^
160165

astroquery/vizier/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, *, columns=["*"], column_filters={}, catalog=None,
7878
self.column_filters = column_filters
7979
self.catalog = catalog
8080
self._keywords = None
81-
self.ucd = ucd
81+
self._ucd = ucd
8282
if keywords:
8383
self.keywords = keywords
8484
self.TIMEOUT = timeout
@@ -233,7 +233,7 @@ def find_catalogs(self, keywords, *, include_obsolete=False, verbose=False,
233233
data_payload["-obsolete"] = None
234234

235235
if self.ucd != "":
236-
data_payload["ucd"] = self.ucd
236+
data_payload["-ucd"] = self.ucd
237237

238238
params = "&".join([k if v is None else f"{k}={v}" for k, v in data_payload.items()])
239239

astroquery/vizier/tests/test_vizier_remote.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ def test_findcatalog_maxcatalog(self):
131131
assert len(cats) >= 39 # as of 2024
132132

133133
def test_findcatalog_ucd(self):
134-
# this fails for VizieR 7.33.3, should work in next releases
135134
vizier = Vizier()
136135
ucdresult = vizier(ucd='phys.albedo').find_catalogs('mars', max_catalogs=5000)
137136
result = vizier.find_catalogs('mars', max_catalogs=5000)
@@ -146,12 +145,12 @@ def test_asu_tsv_return_type(self):
146145
result = vizier.query_object("HD 226868", catalog=["NOMAD", "UCAC"], return_type='asu-tsv', cache=False)
147146

148147
assert isinstance(result, list)
149-
assert len(result) == 3
148+
assert len(result) == 2
150149

151150
def test_query_constraints(self):
152151
vizier = Vizier(row_limit=3)
153152
result = vizier.query_constraints(catalog="I/130/main", mB2="=14.7")[0]
154153
# row_limit is taken in account
155154
assert len(result) == 3
156155
# the criteria is respected
157-
assert np.all(np.isclose(result["mB2"], 14.7, rtol=1e-09, atol=1e-09))
156+
assert np.all(np.isclose(result["mB2"].data.data, 14.7, rtol=1e-09, atol=1e-09))

docs/vizier/vizier.rst

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ Table Discover
2020
If you want to search for a set of tables, e.g. based on author name or other keywords,
2121
the :meth:`~astroquery.vizier.VizierClass.find_catalogs` tool can be used:
2222

23+
.. order is not deterministic
2324
.. doctest-remote-data::
2425

2526
>>> from astroquery.vizier import Vizier
26-
>>> catalog_list = Vizier.find_catalogs('hot jupiter exoplanet transit')
27-
>>> for k, v in catalog_list.items():
27+
>>> vizier = Vizier() # this instantiates Vizier with its default parameters
28+
>>> catalog_list = vizier.find_catalogs('hot jupiter exoplanet transit')
29+
>>> for k, v in catalog_list.items(): # doctest: +IGNORE_OUTPUT
2830
... print(k, ":", v.description)
2931
J/A+A/635/A205 : Ultra-hot Jupiter WASP-121b transits (Bourrier+, 2020)
3032
J/ApJ/788/39 : Hot Jupiter exoplanets host stars EW and abundances (Teske+, 2014)
@@ -44,8 +46,8 @@ the complete contents of those catalogs:
4446

4547
.. doctest-remote-data::
4648

47-
>>> catalogs = Vizier.get_catalogs(catalog_list.keys())
48-
>>> print(catalogs)
49+
>>> catalogs = vizier.get_catalogs(catalog_list.keys())
50+
>>> print(catalogs) # doctest: +IGNORE_OUTPUT
4951
TableList with 10 tables:
5052
'0:J/A+A/635/A205/20140119' with 7 column(s) and 50 row(s)
5153
'1:J/A+A/635/A205/20140123' with 7 column(s) and 50 row(s)
@@ -64,8 +66,8 @@ way:
6466

6567
.. doctest-remote-data::
6668

67-
>>> catalogs = Vizier.get_catalogs(catalog_list.values())
68-
>>> print(catalogs)
69+
>>> catalogs = vizier.get_catalogs(catalog_list.values())
70+
>>> print(catalogs) # doctest: +IGNORE_OUTPUT
6971
TableList with 10 tables:
7072
'0:J/A+A/635/A205/20140119' with 7 column(s) and 50 row(s)
7173
'1:J/A+A/635/A205/20140123' with 7 column(s) and 50 row(s)
@@ -80,8 +82,8 @@ way:
8082

8183
.. doctest-remote-data::
8284

83-
>>> catalogs = Vizier.get_catalogs(catalog_list.keys())
84-
>>> print(catalogs)
85+
>>> catalogs = vizier.get_catalogs(catalog_list.keys())
86+
>>> print(catalogs) # doctest: +IGNORE_OUTPUT
8587
TableList with 10 tables:
8688
'0:J/A+A/635/A205/20140119' with 7 column(s) and 50 row(s)
8789
'1:J/A+A/635/A205/20140123' with 7 column(s) and 50 row(s)
@@ -99,9 +101,9 @@ complete catalog, you need to change that:
99101

100102
.. doctest-remote-data::
101103

102-
>>> Vizier.ROW_LIMIT = -1
103-
>>> catalogs = Vizier.get_catalogs(catalog_list.keys())
104-
>>> print(catalogs)
104+
>>> vizier.ROW_LIMIT = -1
105+
>>> catalogs = vizier.get_catalogs(catalog_list.keys())
106+
>>> print(catalogs) # doctest: +IGNORE_OUTPUT
105107
TableList with 10 tables:
106108
'0:J/A+A/635/A205/20140119' with 7 column(s) and 235 row(s)
107109
'1:J/A+A/635/A205/20140123' with 7 column(s) and 195 row(s)
@@ -113,7 +115,7 @@ complete catalog, you need to change that:
113115
'7:J/AJ/157/217/transits' with 8 column(s) and 236 row(s)
114116
'8:J/A+A/635/A122/table2' with 4 column(s) and 18 row(s)
115117
'9:J/A+A/635/A122/table3' with 4 column(s) and 17 row(s)
116-
>>> Vizier.ROW_LIMIT = 50
118+
>>> vizier.ROW_LIMIT = 50
117119

118120
Get a catalog's associated metadata
119121
-----------------------------------
@@ -160,11 +162,11 @@ For instance to query Sirius across all catalogs:
160162
.. doctest-remote-data::
161163

162164
>>> from astroquery.vizier import Vizier
163-
>>> vizier = Vizier()
164-
>>> result = vizier.query_object("sirius")
165+
>>> vizier = Vizier(row_limit=10)
166+
>>> result = vizier.query_object("sirius") # doctest: +IGNORE_WARNINGS
165167
>>> print(result)
166-
TableList with 416 tables:
167-
'0:METAobj' with 5 column(s) and 7 row(s)
168+
TableList with ... tables:
169+
'0:METAobj' with 5 column(s) and 7 row(s)
168170
'1:ReadMeObj' with 5 column(s) and 7 row(s)
169171
'2:I/34/greenw2a' with 16 column(s) and 1 row(s)
170172
...
@@ -210,22 +212,23 @@ quasar 3C 273:
210212

211213
>>> from astroquery.vizier import Vizier
212214
>>> from astropy.coordinates import Angle
213-
>>> result = Vizier.query_region("3C 273", radius=Angle(0.1, "deg"), catalog='GSC')
215+
>>> vizier = Vizier()
216+
>>> result = vizier.query_region("3C 273", radius=Angle(0.1, "deg"), catalog='GSC')
214217

215218
Note that the radius may also be specified as a string in the format
216219
expected by `~astropy.coordinates.Angle`. So the above query may also
217220
be written as:
218221

219222
.. doctest-remote-data::
220223

221-
>>> result = Vizier.query_region("3C 273", radius="0d6m0s", catalog='GSC')
224+
>>> result = vizier.query_region("3C 273", radius="0d6m0s", catalog='GSC')
222225

223226
Or using angular units and quantities from `astropy.units`:
224227

225228
.. doctest-remote-data::
226229

227230
>>> import astropy.units as u
228-
>>> result = Vizier.query_region("3C 273", radius=0.1*u.deg, catalog='GSC')
231+
>>> result = vizier.query_region("3C 273", radius=0.1*u.deg, catalog='GSC')
229232

230233
To see the result:
231234

@@ -249,17 +252,17 @@ dimension.
249252
>>> from astroquery.vizier import Vizier
250253
>>> import astropy.units as u
251254
>>> import astropy.coordinates as coord
252-
>>> result = Vizier.query_region(coord.SkyCoord(ra=299.590, dec=35.201,
255+
>>> vizier = Vizier()
256+
>>> result = vizier.query_region(coord.SkyCoord(ra=299.590, dec=35.201,
253257
... unit=(u.deg, u.deg),
254258
... frame='icrs'),
255259
... width="30m",
256260
... catalog=["NOMAD", "UCAC"])
257261
>>> print(result)
258-
TableList with 4 tables:
262+
TableList with 3 tables:
259263
'0:I/297/out' with 19 column(s) and 50 row(s)
260-
'1:I/289/out' with 13 column(s) and 50 row(s)
261-
'2:I/322A/out' with 24 column(s) and 50 row(s)
262-
'3:I/340/ucac5' with 20 column(s) and 50 row(s)
264+
'1:I/322A/out' with 24 column(s) and 50 row(s)
265+
'2:I/340/ucac5' with 20 column(s) and 50 row(s)
263266

264267

265268
One more thing to note in the above example is that the coordinates may be
@@ -279,7 +282,8 @@ constraints on the columns of the returned tables by mean of the ``column_filter
279282
>>> from astroquery.vizier import Vizier
280283
>>> import astropy.units as u
281284
>>> from astropy.coordinates import SkyCoord
282-
>>> result = Vizier.query_region(SkyCoord.from_name('M81'),
285+
>>> vizier = Vizier()
286+
>>> result = vizier.query_region(SkyCoord.from_name('M81'),
283287
... radius=10*u.arcmin,
284288
... catalog='I/345/gaia2',
285289
... column_filters={'Gmag': '<19'})
@@ -296,27 +300,27 @@ on the Vizier class.
296300

297301
.. doctest-remote-data::
298302

299-
>>> v = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'],
303+
>>> vizier = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'],
300304
... column_filters={"Vmag":">10"}, keywords=["optical", "xry"]) # doctest: +IGNORE_WARNINGS
301305

302-
Note that whenever an unknown keyword is specified, a warning is emitted and
306+
Note that whenever an unknown keyword is specified (here ``xry``) a warning is emitted and
303307
that keyword is discarded from further consideration. The behavior for
304308
searching with these keywords is the same as defined for the web
305309
interface (`for details see here`_). Now we call the different query methods on
306310
this Vizier instance:
307311

312+
.. output can be in any order here
308313
.. doctest-remote-data::
309314

310-
>>> v = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'],
311-
... column_filters={"Vmag":">10"}, keywords=["optical", "xry"]) # doctest: +IGNORE_WARNINGS
312-
>>> result = v.query_object("HD 226868", catalog=["NOMAD", "UCAC"])
315+
>>> vizier = Vizier(columns=['_RAJ2000', '_DEJ2000','B-V', 'Vmag', 'Plx'],
316+
... column_filters={"Vmag":">10"}, keywords=["optical"])
317+
>>> result = vizier.query_object("HD 226868", catalog=["NOMAD", "UCAC"])
313318
>>> print(result)
314-
TableList with 4 tables:
319+
TableList with 3 tables:
315320
'0:I/297/out' with 3 column(s) and 50 row(s)
316-
'1:I/289/out' with 2 column(s) and 18 row(s)
317-
'2:I/322A/out' with 3 column(s) and 10 row(s)
318-
'3:I/340/ucac5' with 2 column(s) and 26 row(s)
319-
>>> print(result['I/322A/out'])
321+
'1:I/322A/out' with 3 column(s) and 10 row(s)
322+
'2:I/340/ucac5' with 2 column(s) and 26 row(s)
323+
>>> print(result['I/322A/out']) # doctest: +IGNORE_OUTPUT
320324
_RAJ2000 _DEJ2000 Vmag
321325
deg deg mag
322326
------------- ------------- ------
@@ -340,15 +344,15 @@ the ``"+"`` in front of ``"_r"``.
340344

341345
.. doctest-remote-data::
342346

343-
>>> v = Vizier(columns=["*", "+_r"], catalog="II/246")
344-
>>> result = v.query_region("HD 226868", radius="20s")
347+
>>> vizier = Vizier(columns=["*", "+_r"], catalog="II/246")
348+
>>> result = vizier.query_region("HD 226868", radius="20s")
345349
>>> print(result[0])
346350
_r RAJ2000 DEJ2000 _2MASS Jmag ... Bflg Cflg Xflg Aflg
347351
deg deg mag ...
348352
------ ---------- ---------- ---------------- ------ ... ---- ---- ---- ----
349353
0.134 299.590280 35.201599 19582166+3512057 6.872 ... 111 000 0 0
350354
10.135 299.587491 35.203217 19582099+3512115 10.285 ... 111 c00 0 0
351-
11.167 299.588599 35.198849 19582126+3511558 13.111 ... 002 00c 0 0
355+
11.167 299.588599 35.198849 19582126+3511558 13.111 ... 2 00c 0 0
352356
12.288 299.586356 35.200542 19582072+3512019 14.553 ... 111 ccc 0 0
353357
17.691 299.586254 35.197994 19582070+3511527 16.413 ... 100 c00 0 0
354358

@@ -394,9 +398,9 @@ index to the ``agn`` table (not the 0-based python convention).
394398
_q RAJ2000 DEJ2000 _2MASS Jmag ... Rflg Bflg Cflg Xflg Aflg
395399
deg deg mag ...
396400
--- ---------- ---------- ---------------- ------ ... ---- ---- ---- ---- ----
397-
1 10.686015 41.269630 00424464+4116106 9.399 ... 020 020 0c0 2 0
401+
1 10.686015 41.269630 00424464+4116106 9.399 ... 20 20 0c0 2 0
398402
1 10.685657 41.269550 00424455+4116103 10.773 ... 200 200 c00 2 0
399-
1 10.685837 41.270599 00424460+4116141 9.880 ... 020 020 0c0 2 0
403+
1 10.685837 41.270599 00424460+4116141 9.880 ... 20 20 0c0 2 0
400404
1 10.683263 41.267456 00424398+4116028 12.136 ... 200 100 c00 2 0
401405
1 10.683465 41.269676 00424403+4116108 11.507 ... 200 100 c00 2 0
402406
3 27.238636 5.906066 01485727+0554218 8.961 ... 112 111 000 0 0

0 commit comments

Comments
 (0)