Skip to content

Commit

Permalink
feat: support more deprecated fields
Browse files Browse the repository at this point in the history
or at least return better error messages for the fields that don't exist anymore
  • Loading branch information
ManonMarchand committed Jan 20, 2025
1 parent 0132bed commit 6c8c6ed
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ simbad
- Fixed adding a list of fluxes with the deprecated notation
`Simbad.add_votable_fields("flux(U)", "flux(J)")` [#3186]

- Support more of the 0.4.7 votable fields. Raise more significant error messages
for the discontinued ones. [#3186]

- Fix the deprecated votable fields ``otype(V)`` and ``otype(S)`` [#3186]

Infrastructure, Utility and Other Changes and Additions
-------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion astroquery/simbad/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def list_votable_fields(self):
>>> options = Simbad.list_votable_fields() # doctest: +REMOTE_DATA
>>> # to print only the available bundles of columns
>>> options[options["type"] == "bundle of basic columns"][["name", "description"]] # doctest: +REMOTE_DATA
<Table length=8>
<Table length=9>
name description
object object
------------- ----------------------------------------------------
Expand All @@ -243,6 +243,7 @@ def list_votable_fields(self):
dimensions all fields related to object dimensions
morphtype all fields related to the morphological type
parallax all fields related to parallaxes
pm proper motions in right ascension and declination
propermotions all fields related with the proper motions
sp all fields related with the spectral type
velocity all fields related with radial velocity and redshift
Expand Down
36 changes: 34 additions & 2 deletions astroquery/simbad/data/query_criteria_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
"tap_column": ["ra", "dec", "ra_prec", "dec_prec"],
"type": "bundle"
},
"dec_prec": {
"description": "precision code for the coordinates (ra and dec are no longer distinct)",
"tap_column": "coo_qual",
"type": "alias"
},
"diameter": {
"descriptions": "all measurements of diameter",
"tap_table": "mesdiameter",
"type": "alias table"
},
"dim": {
"description": "major and minor axis, angle and inclination",
"tap_startswith": "galdim_",
Expand Down Expand Up @@ -187,14 +197,22 @@
"tap_column": "morph_type",
"type": "alias"
},
"otype(V)": {
"otype(v)": {
"tap_table": "otypedef",
"type": "alias table"
},
"otype(S)": {
"otype(n)": {
"tap_table": "otypedef",
"type": "alias table"
},
"otype(3)": {
"tap_column": "otype",
"type": "alias"
},
"otype(s)": {
"tap_column": "otype",
"type": "alias"
},
"parallax": {
"description": "all fields related to parallaxes",
"tap_startswith": "plx_",
Expand All @@ -210,6 +228,11 @@
"tap_column": "plx_err",
"type": "alias"
},
"pm": {
"description": "proper motion values in right ascension and declination",
"tap_column": ["pmra", "pmdec"],
"type": "bundle"
},
"pm_err_maja": {
"description": "major axis of the error ellipse",
"tap_column": "pm_err_maj",
Expand All @@ -230,6 +253,11 @@
"tap_column": "rvz_radvel",
"type": "alias"
},
"ra_prec": {
"description": "precision code for the coordinates (ra and dec are no longer distinct)",
"tap_column": "coo_qual",
"type": "alias"
},
"redshift": {
"type": "alias",
"tap_column": "rvz_redshift"
Expand Down Expand Up @@ -268,6 +296,10 @@
"type": "alias",
"tap_column": "sp_type"
},
"td1": {
"description": "UV fluxes from TD1 satellite,by Thompson et al.",
"type": "historical measurement"
},
"v*": {
"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)",
"type": "alias table",
Expand Down
19 changes: 18 additions & 1 deletion astroquery/simbad/tests/test_simbad.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ def test_add_votable_fields():
# a table which name has changed should raise a warning too
with pytest.warns(DeprecationWarning, match="'distance' has been renamed 'mesdistance'*"):
simbad_instance.add_votable_fields("distance")


@pytest.mark.usefixtures("_mock_simbad_class")
@pytest.mark.usefixtures("_mock_basic_columns")
@pytest.mark.usefixtures("_mock_linked_to_basic")
def test_add_votable_fields_errors():
# errors are raised for the deprecated fields with options
simbad_instance = simbad.SimbadClass()
with pytest.raises(ValueError, match=r"The votable fields \'flux_\*\*\*\(filtername\)\' are removed *"):
Expand All @@ -281,7 +287,18 @@ def test_add_votable_fields():
with pytest.raises(ValueError, match="'alltype' is not one of the accepted options which can be "
"listed with 'list_votable_fields'. Did you mean 'alltypes' or 'otype' or 'otypes'?"):
simbad_instance.add_votable_fields("ALLTYPE")
# bundles and tables require a connection to the tap_schema and are thus tested in test_simbad_remote
# successive positions no longer ins SIMBAD (for years)
with pytest.raises(ValueError, match="Successive measurements of the positions *"):
simbad_instance.add_votable_fields("pos")
# no longer stores sp_nature
with pytest.raises(ValueError, match="Spectral nature is no longer stored in SIMBAD. *"):
simbad_instance.add_votable_fields("sp_nature")
# typed_id had only been added for astroquery's interaction with the old API
with pytest.raises(ValueError, match="'typed_id' is no longer a votable field. *"):
simbad_instance.add_votable_fields("typed_id")
# uvb and others no longer have their table in SIMBAD
with pytest.raises(ValueError, match="Magnitudes are now handled very differently in SIMBAD. *"):
simbad_instance.add_votable_fields("ubv")


@pytest.mark.usefixtures("_mock_simbad_class")
Expand Down
18 changes: 17 additions & 1 deletion astroquery/simbad/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,29 @@ def _catch_deprecated_fields_with_arguments(votable_field):
"Coordinates are now per default in degrees and in the ICRS frame.")
if votable_field.startswith("id("):
raise ValueError("Catalog Ids are no longer supported as an output option. "
"A good replacement can be `~astroquery.simbad.SimbadClass.query_cat`")
"Good replacements can be `~astroquery.simbad.SimbadClass.query_cat` "
"or `~astroquery.simbad.SimbadClass.query_objectids`.")
if votable_field.startswith("bibcodelist("):
raise ValueError("Selecting a range of years for bibcode is removed. You can still use "
"bibcodelist without parenthesis and get the full list of bibliographic references.")
if votable_field in ["membership", "link_bibcode"]:
raise ValueError("The hierarchy information is no longer an additional field. "
"It has been replaced by the 'query_hierarchy' method.")
if votable_field in ["pos", "posa"]:
raise ValueError("Successive measurements of the positions are no longer stored "
"in SIMBAD. The columns 'ra' and 'dec' contain the most precise "
"measurement recorded by the SIMBAD team. For historical values, "
"search within VizieR (accessible via 'astroquery.vizier').")
if votable_field == "sp_nature":
raise ValueError("Spectral nature is no longer stored in SIMBAD. You can get the "
"of the spectral type classification in 'sp_bibcode'.")
if votable_field == "typed_id":
raise ValueError("'typed_id' is no longer a votable field. It is now added by "
"default in 'query_objects' and 'query_region'")
if votable_field in ["ubv", "uvby1", "uvby"]:
raise ValueError("Magnitudes are now handled very differently in SIMBAD. See this "
"section of the documentation: "
"https://astroquery.readthedocs.io/en/latest/simbad/simbad_evolution.html#optical-filters")

# ----------------------------
# Support wildcard argument
Expand Down

0 comments on commit 6c8c6ed

Please sign in to comment.