Arithmetic operation on dimensionless mag units
See original GitHub issueDescription
Not sure whether this is a bug or just a misunderstanding: I am wondering how dimensionless units work; especially the conversion to linear.
Expected behavior
I would expect that u.mag
works equivalently to f.e. u.ABmag
when it comes to conversion:
>>> import astropy.units as u
>>> m = 12 * u.ABmag
>>> print(m)
12.0 mag(AB)
>>> print(m.to(u.erg/u.s/u.m**2/u.Hz))
5.754399373371543e-21 erg / (Hz m2 s)
>>> flux = 1e-20 * u.erg/u.s/u.m**2/u.Hz
>>> print(flux.to(u.ABmag))
11.399999999999997 mag(AB)
i.e. u.mag
should be convertible to and from a dimensionless unit.
Actual behavior
>>> import astropy.units as u
>>> m = 1 * u.mag
>>> print(m)
1.0 mag
>>> print(m.to(''))
Traceback (most recent call last):
[…]
File "/usr/lib/python3/dist-packages/astropy/units/core.py", line 1027, in _apply_equivalencies
raise UnitConversionError(
astropy.units.core.UnitConversionError: 'mag' and '' (dimensionless) are not convertible
>>> f = u.Quantity(10.0)
>>> print(f.to(u.mag))
Traceback (most recent call last):
[…]
File "/usr/lib/python3/dist-packages/astropy/units/core.py", line 1027, in _apply_equivalencies
raise UnitConversionError(
astropy.units.core.UnitConversionError: '' (dimensionless) and 'mag' are not convertible
Specific question: what is the “preferred” way to convert to copy to/from dimensionless magnitudes (except explicitly using -2.5*log10(f)
)?
Steps to Reproduce
See above
System Details
Astropy 5.0rc1
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
Dimensionless quantity - Wikipedia
A dimensionless quantity is a quantity to which no physical dimension is assigned, with a corresponding SI unit of measurement of one (or...
Read more >Dimensionless Unit - an overview | ScienceDirect Topics
Coupling constant dependence of the bound state energies of electrons with an anomalous magnetic moment in a Coulomb potential. The curves show some...
Read more >Magnitudes and Other Logarithmic Units — Astropy v5.2
This happens generally for division and multiplication, since these processes work only for dimensionless magnitudes (otherwise, the physical unit would have to ...
Read more >Dimensionless units in the SI - IOPscience
Here we consider dimensionless units as defined in the SI, e.g. angular units ... Angles play an essential role in mathematics, physics, and...
Read more >The Problem with 'Dimensionless Quantities' - SciTePress
dimensionless quantities that all have the SI unit one. ... The arithmetic, ordering and equivalence operations ... A Treatise on Electricity and Mag-....
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
Maybe we should just stop using the magnitude system…
I think also with dex the calc is wrong. Normally, it is
mag = -2.5*log10(f2/f1)
, which would for f2/f1=2 give -0.7526. Or, more explicit: