Skip to content

Commit 3a37b07

Browse files
committed
fix: use the real column names rather than the IDs that astropy generates
1 parent f1a7888 commit 3a37b07

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

CHANGES.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ vizier
163163

164164
- Fixed search by UCD -- they were ignored. [#3147]
165165

166+
- Fixed column names -- some characters were replaced by ``_`` instead of keeping
167+
the original name [#3153]
168+
166169
vsa
167170
^^^
168171

astroquery/vizier/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ def _parse_vizier_votable(data, *, verbose=False, invalid='warn',
844844
name = t.name
845845
if name not in table_dict.keys():
846846
table_dict[name] = []
847-
table_dict[name] += [t.to_table()]
847+
table_dict[name] += [t.to_table(use_names_over_ids=True)]
848848
for name in table_dict.keys():
849849
if len(table_dict[name]) > 1:
850850
table_dict[name] = tbl.vstack(table_dict[name])

astroquery/vizier/tests/test_vizier_remote.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ def test_vizier_column_restriction(self):
7272
for table in result:
7373
assert 'Bmag' not in table.columns
7474

75+
def test_vizier_column_exotic_characters(self):
76+
# column names can contain any ascii characters. This checks that they are not
77+
# replaced by underscores, see issue #3124
78+
result = Vizier(columns=["r'mag"],
79+
row_limit=1).get_catalogs(catalog="II/336/apass9")[0]
80+
assert "r'mag" in result.colnames
81+
7582
@pytest.mark.parametrize('all', ('all', '*'))
7683
def test_alls_withaddition(self, all):
7784
# Check that all the expected columns are there plus the _r

docs/vizier/vizier.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ To access an individual table from the `~astroquery.utils.TableList` object:
182182

183183
>>> interesting_table = result['IX/8/catalog']
184184
>>> print(interesting_table)
185-
_2XRS RAB1950 DEB1950 Xname ... Int _RA.icrs _DE.icrs
185+
2XRS RAB1950 DEB1950 Xname ... Int _RA.icrs _DE.icrs
186186
... uJy
187187
--------- ------------ ------------ ----- ... --- ------------ ------------
188188
06429-166 06 42 54.000 -16 39 00.00 ... -- 06 45 08.088 -16 42 11.29
@@ -347,7 +347,7 @@ the ``"+"`` in front of ``"_r"``.
347347
>>> vizier = Vizier(columns=["*", "+_r"], catalog="II/246")
348348
>>> result = vizier.query_region("HD 226868", radius="20s")
349349
>>> print(result[0])
350-
_r RAJ2000 DEJ2000 _2MASS Jmag ... Bflg Cflg Xflg Aflg
350+
_r RAJ2000 DEJ2000 2MASS Jmag ... Bflg Cflg Xflg Aflg
351351
deg deg mag ...
352352
------ ---------- ---------- ---------------- ------ ... ---- ---- ---- ----
353353
0.134 299.590280 35.201599 19582166+3512057 6.872 ... 111 000 0 0
@@ -395,8 +395,8 @@ index to the ``agn`` table (not the 0-based python convention).
395395

396396
>>> guide = Vizier(catalog="II/246", column_filters={"Kmag":"<9.0"}).query_region(agn, radius="30s", inner_radius="2s")[0]
397397
>>> guide.pprint()
398-
_q RAJ2000 DEJ2000 _2MASS Jmag ... Rflg Bflg Cflg Xflg Aflg
399-
deg deg mag ...
398+
_q RAJ2000 DEJ2000 2MASS Jmag ... Rflg Bflg Cflg Xflg Aflg
399+
deg deg mag ...
400400
--- ---------- ---------- ---------------- ------ ... ---- ---- ---- ---- ----
401401
1 10.686015 41.269630 00424464+4116106 9.399 ... 20 20 0c0 2 0
402402
1 10.685657 41.269550 00424455+4116103 10.773 ... 200 200 c00 2 0

0 commit comments

Comments
 (0)