When reading a FITS table using, I receive a UnitsWarning:

WARNING: UnitsWarning: 'ADU' did not parse as fits unit: At col 0, Unit 'ADU' not supported by the FITS standard. Did you mean AU or adu? If this is meant to be a custom unit, define it with 'u.def_unit'. To have it recognized inside a file reader or other code, enable it with 'u.add_enabled_units'. For details, see [astropy.units.core]

Expected behavior

As per this older pull request #5675, I would not expect this warning to occur when reading a FITS table, only when writing one.

Actual behavior

A warning is issued when reading the FITS table.

Steps to Reproduce

  1. First create a file with a bad unit.
  2. When writing this bad file a Warning occurs as expected.
  3. Close your python session, since warnings do not re-occur in the same session.
  4. In a new python session open the file.
  5. Opening the file produces a Warning.

For creating the bad file:

from astropy.table import Table

t1 = Table([[1,2], [3,4]], names=['a', 'b'])
t1['a'].unit = 'm/s'
t1['b'].unit = 'ADU'

t1.write('test.fits', overwrite=True)

For reading the bad file:

from astropy.table import Table'test.fits')

System Details

Linux-4.19.0-5-amd64-x86_64-with-glibc2.28 Python 3.9.7 (default, Sep 16 2021, 13:09:58) Numpy 1.23.3 pyerfa astropy 5.2.1 Scipy 1.9.2 Matplotlib 3.6.1


Welcome to Astropy 👋 and thank you for your first issue!

A project member will respond to you as soon as possible; in the meantime, please double-check the guidelines for submitting issues and make sure you've provided the requested details.

GitHub issues in the Astropy repository are used to track bug reports and feature requests; If your issue poses a question about how to use Astropy, please instead raise your question in the Astropy Discourse user forum and close this issue.

If you feel that this issue has not been responded to in a timely manner, please send a message directly to the development mailing list. If the issue is urgent or sensitive in nature (e.g., a security vulnerability) please send an e-mail directly to the private e-mail [email protected]


Since #5675 the behavior changed because some people want to see the warnings. So we added an option to specify the behavior when reading a file in #11843. Warnings are shown by default and can be hidden with:'test.fits', unit_parse_strict='silent')

Thank you for the clarification. Personally I think it would still be preferable to have these warnings turned off by default, since the user will not be able to change the file format in many cases.

Regardless, since this is intended behavior, feel free to close this issue.


@talensgj , FITS has a lot of history and it is tough to get all the users happy at the same time. We thank you for your patience.


@pllim, I fully understand. Maybe an option could be added to set this behavior globally?


Maybe an option could be added to set this behavior globally?

Like using ? It is technically possible but has a cost of offering too many ways to do the same thing. Feel free to start a discussion at with a proposal if you wish. Thank you!

© 2022 - All rights reserved.