Skip to content

Commit acc5b91

Browse files
committed
feat: support more deprecated fields
or at least return better error messages for the fields that don't exist anymore
1 parent cdba705 commit acc5b91

File tree

5 files changed

+97
-17
lines changed

5 files changed

+97
-17
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ simbad
2525
- Fixed adding a list of fluxes with the deprecated notation
2626
``Simbad.add_votable_fields("flux(U)", "flux(J)")`` [#3186]
2727

28+
- Support more of the 0.4.7 votable fields. Raise more significant error messages
29+
for the discontinued ones. [#3186]
30+
31+
- Fix the deprecated votable fields ``otype(V)`` and ``otype(S)`` [#3186]
2832

2933
Infrastructure, Utility and Other Changes and Additions
3034
-------------------------------------------------------

astroquery/simbad/core.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,19 @@ def list_votable_fields(self):
234234
>>> options = Simbad.list_votable_fields() # doctest: +REMOTE_DATA
235235
>>> # to print only the available bundles of columns
236236
>>> options[options["type"] == "bundle of basic columns"][["name", "description"]] # doctest: +REMOTE_DATA
237-
<Table length=8>
238-
name description
239-
object object
240-
------------- ----------------------------------------------------
241-
coordinates all fields related with coordinates
242-
dim major and minor axis, angle and inclination
243-
dimensions all fields related to object dimensions
244-
morphtype all fields related to the morphological type
245-
parallax all fields related to parallaxes
246-
propermotions all fields related with the proper motions
247-
sp all fields related with the spectral type
248-
velocity all fields related with radial velocity and redshift
237+
<Table length=9>
238+
name description
239+
object object
240+
------------- -------------------------------------------------------
241+
coordinates all fields related with coordinates
242+
dim major and minor axis, angle and inclination
243+
dimensions all fields related to object dimensions
244+
morphtype all fields related to the morphological type
245+
parallax all fields related to parallaxes
246+
pm proper motion values in right ascension and declination
247+
propermotions all fields related with the proper motions
248+
sp all fields related with the spectral type
249+
velocity all fields related with radial velocity and redshift
249250
"""
250251
# get the tables with a simple link to basic
251252
query_tables = """SELECT DISTINCT table_name AS name, tables.description

astroquery/simbad/data/query_criteria_fields.json

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@
3333
"tap_column": ["ra", "dec", "ra_prec", "dec_prec"],
3434
"type": "bundle"
3535
},
36+
"dec(d)": {
37+
"tap_column": "dec",
38+
"type": "alias"
39+
},
40+
"dec_prec": {
41+
"description": "precision code for the coordinates (ra and dec are no longer distinct)",
42+
"tap_column": "coo_qual",
43+
"type": "alias"
44+
},
45+
"diameter": {
46+
"descriptions": "all measurements of diameter",
47+
"tap_table": "mesdiameter",
48+
"type": "alias table"
49+
},
3650
"dim": {
3751
"description": "major and minor axis, angle and inclination",
3852
"tap_startswith": "galdim_",
@@ -187,14 +201,22 @@
187201
"tap_column": "morph_type",
188202
"type": "alias"
189203
},
190-
"otype(V)": {
204+
"otype(v)": {
191205
"tap_table": "otypedef",
192206
"type": "alias table"
193207
},
194-
"otype(S)": {
208+
"otype(n)": {
195209
"tap_table": "otypedef",
196210
"type": "alias table"
197211
},
212+
"otype(3)": {
213+
"tap_column": "otype",
214+
"type": "alias"
215+
},
216+
"otype(s)": {
217+
"tap_column": "otype",
218+
"type": "alias"
219+
},
198220
"parallax": {
199221
"description": "all fields related to parallaxes",
200222
"tap_startswith": "plx_",
@@ -210,6 +232,11 @@
210232
"tap_column": "plx_err",
211233
"type": "alias"
212234
},
235+
"pm": {
236+
"description": "proper motion values in right ascension and declination",
237+
"tap_column": ["pmra", "pmdec"],
238+
"type": "bundle"
239+
},
213240
"pm_err_maja": {
214241
"description": "major axis of the error ellipse",
215242
"tap_column": "pm_err_maj",
@@ -225,11 +252,20 @@
225252
"tap_startswith": "pm",
226253
"type": "bundle"
227254
},
255+
"ra(d)": {
256+
"tap_column": "ra",
257+
"type": "alias"
258+
},
228259
"radvel": {
229260
"description": "Radial velocity",
230261
"tap_column": "rvz_radvel",
231262
"type": "alias"
232263
},
264+
"ra_prec": {
265+
"description": "precision code for the coordinates (ra and dec are no longer distinct)",
266+
"tap_column": "coo_qual",
267+
"type": "alias"
268+
},
233269
"redshift": {
234270
"type": "alias",
235271
"tap_column": "rvz_redshift"
@@ -268,6 +304,10 @@
268304
"type": "alias",
269305
"tap_column": "sp_type"
270306
},
307+
"td1": {
308+
"description": "UV fluxes from TD1 satellite,by Thompson et al.",
309+
"type": "historical measurement"
310+
},
271311
"v*": {
272312
"description": "variable stars parameters extracted mainly from the General Catalog of Variable Stars by Kukarkin et al. USSR Academy of Sciences (3rd edition in 1969,and continuations)",
273313
"type": "alias table",

astroquery/simbad/tests/test_simbad.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ def test_add_votable_fields():
261261
# a table which name has changed should raise a warning too
262262
with pytest.warns(DeprecationWarning, match="'distance' has been renamed 'mesdistance'*"):
263263
simbad_instance.add_votable_fields("distance")
264+
265+
266+
@pytest.mark.usefixtures("_mock_simbad_class")
267+
@pytest.mark.usefixtures("_mock_basic_columns")
268+
@pytest.mark.usefixtures("_mock_linked_to_basic")
269+
def test_add_votable_fields_errors():
264270
# errors are raised for the deprecated fields with options
265271
simbad_instance = simbad.SimbadClass()
266272
with pytest.raises(ValueError, match=r"The votable fields \'flux_\*\*\*\(filtername\)\' are removed *"):
@@ -269,7 +275,9 @@ def test_add_votable_fields():
269275
simbad_instance.add_votable_fields("flux(u)")
270276
assert "u_" in str(simbad_instance.columns_in_output)
271277
with pytest.raises(ValueError, match="Coordinates conversion and formatting is no longer supported*"):
272-
simbad_instance.add_votable_fields("coo(s)", "dec(d)")
278+
simbad_instance.add_votable_fields("coo(s)")
279+
with pytest.warns(DeprecationWarning, match=r"\'dec\(d\)\' has been renamed \'dec\'. *"):
280+
simbad_instance.add_votable_fields("dec(d)")
273281
with pytest.raises(ValueError, match="Catalog Ids are no longer supported as an output option.*"):
274282
simbad_instance.add_votable_fields("ID(Gaia)")
275283
with pytest.raises(ValueError, match="Selecting a range of years for bibcode is removed.*"):
@@ -281,7 +289,18 @@ def test_add_votable_fields():
281289
with pytest.raises(ValueError, match="'alltype' is not one of the accepted options which can be "
282290
"listed with 'list_votable_fields'. Did you mean 'alltypes' or 'otype' or 'otypes'?"):
283291
simbad_instance.add_votable_fields("ALLTYPE")
284-
# bundles and tables require a connection to the tap_schema and are thus tested in test_simbad_remote
292+
# successive positions no longer ins SIMBAD (for years)
293+
with pytest.raises(ValueError, match="Successive measurements of the positions *"):
294+
simbad_instance.add_votable_fields("pos")
295+
# no longer stores sp_nature
296+
with pytest.raises(ValueError, match="Spectral nature is no longer stored in SIMBAD. *"):
297+
simbad_instance.add_votable_fields("sp_nature")
298+
# typed_id had only been added for astroquery's interaction with the old API
299+
with pytest.raises(ValueError, match="'typed_id' is no longer a votable field. *"):
300+
simbad_instance.add_votable_fields("typed_id")
301+
# uvb and others no longer have their table in SIMBAD
302+
with pytest.raises(ValueError, match="Magnitudes are now handled very differently in SIMBAD. *"):
303+
simbad_instance.add_votable_fields("ubv")
285304

286305

287306
@pytest.mark.usefixtures("_mock_simbad_class")

astroquery/simbad/utils.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,29 @@ def _catch_deprecated_fields_with_arguments(votable_field):
3333
"Coordinates are now per default in degrees and in the ICRS frame.")
3434
if votable_field.startswith("id("):
3535
raise ValueError("Catalog Ids are no longer supported as an output option. "
36-
"A good replacement can be `~astroquery.simbad.SimbadClass.query_cat`")
36+
"Good replacements can be `~astroquery.simbad.SimbadClass.query_cat` "
37+
"or `~astroquery.simbad.SimbadClass.query_objectids`.")
3738
if votable_field.startswith("bibcodelist("):
3839
raise ValueError("Selecting a range of years for bibcode is removed. You can still use "
3940
"bibcodelist without parenthesis and get the full list of bibliographic references.")
4041
if votable_field in ["membership", "link_bibcode"]:
4142
raise ValueError("The hierarchy information is no longer an additional field. "
4243
"It has been replaced by the 'query_hierarchy' method.")
44+
if votable_field in ["pos", "posa"]:
45+
raise ValueError("Successive measurements of the positions are no longer stored "
46+
"in SIMBAD. The columns 'ra' and 'dec' contain the most precise "
47+
"measurement recorded by the SIMBAD team. For historical values, "
48+
"search within VizieR (accessible via 'astroquery.vizier').")
49+
if votable_field == "sp_nature":
50+
raise ValueError("Spectral nature is no longer stored in SIMBAD. You can get the "
51+
"of the spectral type classification in 'sp_bibcode'.")
52+
if votable_field == "typed_id":
53+
raise ValueError("'typed_id' is no longer a votable field. It is now added by "
54+
"default in 'query_objects' and 'query_region'")
55+
if votable_field in ["ubv", "uvby1", "uvby"]:
56+
raise ValueError("Magnitudes are now handled very differently in SIMBAD. See this "
57+
"section of the documentation: "
58+
"https://astroquery.readthedocs.io/en/latest/simbad/simbad_evolution.html#optical-filters")
4359

4460
# ----------------------------
4561
# Support wildcard argument

0 commit comments

Comments
 (0)