astroquery: Vizier search often emits UnitsWarning: Unit 'e' not supported by the VOUnit standard.

When performing Vizier search, it often emits the following (arguably useless) warning.

UnitsWarning: Unit 'e' not supported by the VOUnit standard.  [astropy.units.format.vounit]

It appears that if the search result contains data with the unit of electron (e.g., flux), the warning is emitted.

Example

The following code snippet would emit the warning.

def search_nearby(ra, dec, catalog_name="I/345/gaia2", radius_arcsec=30):    
    c1 = SkyCoord(ra, dec, frame="icrs", unit="deg")
    columns = ["RAJ2000", "DEJ2000", "Source", "Gmag", "FG"]

    result = Vizier(columns=columns).query_region(
        c1,
        catalog=[catalog_name],
        radius=Angle(radius_arcsec, "arcsec"),
    )
    return result[catalog_name]

ra, dec = 263.59892769, 74.47212807
result = search_nearby(ra, dec)
result

If one removes column "FG" (G-band mean flux, with the unit of e-/s) from result, there will be no warning.

Environment:

Astroquery: 0.4.6 Astropy: 5.0.3

Some older version of Astroquery + Astropy does not emits the warnings, e.g., Astroquery: 0.4.2 Astropy: 4.2.1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

You can do something like:

import warnings
from astropy.units import UnitsWarning
warnings.filterwarnings("ignore", category=UnitsWarning)

at the beginning of your file.

@bsipocz @keflavich : it’s bothering enough people that I’d consider filtering the UnitsWarning for the VizieR module while waiting for an eventual upstream fix. What do you think?

The intent of the code in VizierClass.parse_vizier_votable() seems to be that VOTable-related warnings should be silenced unless the user specifies verbose=True: https://github.com/astropy/astroquery/blob/db3f08b454f24474e84d5d7850ed6c909458848c/astroquery/vizier/core.py#L753-L759 However, only VOWarning instances are suppressed and the reported UnitsWarning is not such an instance: https://github.com/astropy/astroquery/blob/db3f08b454f24474e84d5d7850ed6c909458848c/astroquery/utils/commons.py#L338-L345 If there is agreement that astroquery.astroquery.utils.commons.suppress_vo_warnings() should also suppress VOTable-related UnitsWarning instances then I can open a pull request for that.

I was looking in adding the filter, and I cannot reproduce the warnings anymore. I tried the catalogs I/345/gaia2 and I/239/tyc_main and the following versions:

  • astropy: 7.0.0 and 6.1.7
  • astroquery: 0.4.7, 0.4.8, and current master (ca584f6783ff7965c4eed22776a18a2348cd15bb)

My guess is that something must have changed in astropy, but I could not pinpoint it.

Should we close the issue? Otherwise I’d like a reproducer with fairly recent versions.

Yes, I think that’s reasonable. Maybe make it opt out.

Just to add to the conversation, right now there is no plan to change the units in already published VizieR tables.

I looked a bit more into this and came to the conclusion that the reported issue is caused by a bug in astropy, see https://github.com/astropy/astropy/issues/13017#issuecomment-1084791646 for details.

When working with gaia you may want to use astroquery.gaia instead than pulling the whole catalogue from vizier.

Anyway, the noise is good, it has its well-intended purpose, and I don’t think we should start fixing things for the purpose of silencing those, basically, astroquery shouldn’t be the one making decisions for the user (you can always decide to silence warnings), or cleanup for the data provider. But we should consider adding some workaround during our parsing steps until the data providers fix their non-standard usage.

somewhat related to #2349. In the ideal world the data providers would release fits files that adhere to fits standards and votables that are VO compliant, but being pragmatic I think we could add some workarounds into astroquery, either by silencing these warnings within astroquery, or fix the units ourselves (for heasarch I think the latter makes sense, vizier is a bit different as there could be a lot of non-vo compliant content that were pulled from papers).