astropy: Problem with "decimalyear" applied to MaskedColumn type
Description
The “decimalyear” type produces odd errors when applied to the MaskedColumn type. The “jyear” type does not, and appears to behave properly.
Expected behavior
I would expect “decimalyear” and “jyear” to work similarly, although the difference between them is not clear from the documentation.
How to Reproduce
# Begin decimalyear_test.py
# A simple illustration of possible bug in "decimalyear"
import astropy
from astropy.coordinates import SkyCoord
from astropy.units import Quantity
from astroquery.gaia import Gaia
from astropy.time import Time
coord = SkyCoord(ra=0.0, dec=0.0, unit=astropy.units.deg)
width = Quantity(0.05, unit=astropy.units.deg)
height = Quantity(0.05, unit=astropy.units.deg)
Gaia.MAIN_GAIA_TABLE = "gaiadr3.gaia_source"
searchout = Gaia.query_object_async(coordinate=coord, width=width, height=height)
epochs=searchout['ref_epoch']
print(epochs,"\n")
print("epochs is instance of MaskedColumn:", isinstance(epochs, astropy.table.column.MaskedColumn),"\n")
print("epochs in jyear: ",Time(epochs,format='jyear'),"\n")
print("epochs in decimalyear: ",Time(epochs,format='decimalyear'))
print("\n")
epoch2=Time(2016.0,format='jyear')
print("epoch2 in jyear=", epoch2)
epoch3=Time(2016.0,format='decimalyear')
print("epoch3 in decimalyear=", epoch3)
# End decimalyear_test.py
Versions
Linux-5.19.0-35-generic-x86_64-with-glibc2.35 Python 3.9.13 (main, Aug 25 2022, 23:26:10) [GCC 11.2.0] astropy 5.1
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (9 by maintainers)
There is a bug, in that the units are used if a
Quantity
is passed intodecimalyear
– I think the solution is to explicitly forbid having units for this class, since the scale of the unityear
is different than that assumed here (like forbyear
).p.s.
365.2425
is what one would get if a Gregorian year were used! Caesar didn’t bother with the details for his Julian calendar too much…It is still a problem in astropy5.3.dev756+gc0a24c1dc Here is the printout :