u.Magnitude() does not produce a FITS conform output
See original GitHub issueDescription
When creating a table column with u.mag()
as unit, the FITS writer refuses to take it as a FITS mag
standard column but serializes it in a astropy specific manner.
Expected behavior
I’d expect that both u.mag
and u.mag()
result in a FITS unit mag
, as their difference is quite subtle.
Steps to Reproduce
>>> from astropy.table import QTable
>>> import astropy.units as u
>>> from astropy.io import fits
>>> QTable({'fmag': [1.0] * u.mag}).write('mag-units.fits')
>>> fits.open('mag-units.fits')[1].header['T*1']
TTYPE1 = 'fmag '
TFORM1 = 'D '
TUNIT1 = 'mag '
>>> QTable({'fmag': [1.0] * u.mag()}).write('mag-magnitude.fits')
WARNING: The unit 'mag(1)' could not be saved in native FITS format and hence will be lost to non-astropy fits readers. Within astropy, the unit can roundtrip using QTable, though one has to enable the unit before reading. [astropy.io.fits.convenience]
>>> fits.open('mag-magnitude.fits')[1].header['T*1']
TTYPE1 = 'fmag '
TFORM1 = 'D '
System Details
- Linux-5.18.0-2-amd64-x86_64-with-glibc2.33
- Python 3.10.5 (main, Jun 8 2022, 09:26:22) [GCC 11.3.0]
- Numpy 1.21.5
- pyerfa 2.0.0.1
- astropy 5.1
- Scipy 1.7.3
- Matplotlib 3.5.2
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Log-transformation and its implications for data analysis - PMC
Despite the common belief that the log transformation can decrease the variability of data and make data conform more closely to the normal...
Read more >How To Interpret R-squared in Regression Analysis
R-squared is a goodness-of-fit measure for linear regression models. This statistic indicates the percentage of the variance in the dependent variable that ...
Read more >Bitwise Operators in Python
In this tutorial, you'll learn how to use Python's bitwise operators to manipulate individual bits of data at the most granular level.
Read more >Relative Strength Index (RSI) Indicator Explained With Formula
The Relative Strength Index (RSI) is a momentum indicator that measures the magnitude of recent price changes to analyze overbought or ...
Read more >An Introduction to t Tests | Definitions, Formula and Examples
have a similar amount of variance within each group being compared (a.k.a. homogeneity of variance). If your data do not fit these assumptions, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@plim Not really, but the other way: ST is a flux unit;
mag(ST)
converts it to a magnitude. If one wants to convert a surface flux, the natural way ismag(ST/arcsec²)
.STmag/arcsec²
is just lazy writing and not to be taken literally.Ah, okay. Thanks for clarification and sorry for the noise!