question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

u.Magnitude() does not produce a FITS conform output

See original GitHub issue

Description

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:open
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
olebolecommented, Aug 2, 2022

@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 is mag(ST/arcsec²). STmag/arcsec² is just lazy writing and not to be taken literally.

0reactions
pllimcommented, Aug 2, 2022

Ah, okay. Thanks for clarification and sorry for the noise!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found