Error while parsing years earlier than 4799BC
See original GitHub issueHello! 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)
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (12 by maintainers)
Top Results From Across the Web
Parse error There is a problem parsing the package 4 Easy ...
Parse error There is a problem parsing the package 4 Easy ways to fix, while installing any apk you will get the parse...
Read more >Solved: DataFormat.Error: We couldn't parse the input prov...
Bring the Day column first by dragging, Month column second and Year column last ... In Power Query, go to transform in the...
Read more >Knowledge Graph Essentials and Key Technologies
troduced their Knowledge Graph technology in 2012, and since then, it has become apparent ... c) If the date is earlier than 4799BC,...
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
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.
When trying all the formats, the
fits
case still has to fail informats.py
, probably with aastropy.utils.exceptions.ErfaError: ERFA function "d2dtf" yielded 1 of "unacceptable date (Note 6)"
I could not figure out yet exactly where that exception is caught, but if it could instead be passed back up to_get_time_fmt
, the caller might check for that specific error. Or at least let anErfaWarning
pass though (although those are probably rather cryptic to the user, too).