astropy: Error while parsing years earlier than 4799BC
Hello! I’m trying to parse a bunch of different dates, and BC ones are among them. And what I’ve noticed, is that if the date is earlier than 4799BC, astropy refuses to parse it and throws this:
Traceback (most recent call last):
File "main.py", line 4, in <module>
print(Time('-04800-01-02T03:04:05', format='fits').unix)
File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/astropy/time/core.py", line 399, in __init__
precision, in_subfmt, out_subfmt)
File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/astropy/time/core.py", line 454, in _init_from_vals
precision, in_subfmt, out_subfmt)
File "/home/runner/.local/share/virtualenvs/python3/lib/python3.7/site-packages/astropy/time/core.py", line 505, in _get_time_fmt
raise ValueError('Input values did not match {0}'.format(err_msg))
ValueError: Input values did not match the format class fits
Here is the code and corresponding repl.it
from astropy.time import Time
print(Time('-04799-01-02T03:04:05', format='fits').unix)
print(Time('-04800-01-02T03:04:05', format='fits').unix)
About this issue
- Original URL
- State: open
- Created 5 years ago
- Comments: 16 (12 by maintainers)
By precise, I meant that the actual day/month and likely time were known… Easiest may be for early ~year accurate times to use
byear
or so. Actually, one probably has to check what people actually mean; it may well be the unit of year, which by definition is 365.25 days (i.e., julian year).My overall feeling is that is it best to special-case those early dates and make an approximation that is clearly described.