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.

Error while parsing years earlier than 4799BC

See original GitHub issue

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)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
mhvkcommented, Sep 16, 2019

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.

0reactions
dhomeiercommented, Oct 3, 2019

The error message is a bit trickier to get right, since without an explicit format, the initializer simply tries all unique formats. But at least when one does give an explicit format, the message perhaps could be clearer.

When trying all the formats, the fits case still has to fail in formats.py, probably with a astropy.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 an ErfaWarning pass though (although those are probably rather cryptic to the user, too).

Read more comments on GitHub >

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

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