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.

ErfaWarning: ERFA function "d2dtf" yielded 1 of "dubious year (Note 5)" when using `astropy.time.Time.to_datetime()`

See original GitHub issue

I keep getting these warnings from the ERFA library when converting certain times to datetime objects:

/Users/lzkelley/anaconda3/lib/python3.5/site-packages/astropy/_erfa/core.py:118: ErfaWarning: ERFA function "d2dtf" yielded 1 of "dubious year (Note 5)"

No idea why, but I can reproduce it with:

> t = 1693612800.0
> ap.time.Time(t, format='unix').to_datetime()

File "/Users/lzkelley/anaconda3/bin/ipython", line 6, in <module>
    sys.exit(IPython.start_ipython())
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/IPython/__init__.py", line 119, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/IPython/terminal/ipapp.py", line 348, in start
    self.shell.mainloop()
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/IPython/terminal/interactiveshell.py", line 440, in mainloop
    self.interact()
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/IPython/terminal/interactiveshell.py", line 431, in interact
    self.run_cell(code, store_history=True)
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2717, in run_cell
    interactivity=interactivity, compiler=compiler, result=result)
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2827, in run_ast_nodes
    if self.run_code(code, result):
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-185-04e6f34e68d8>", line 1, in <module>
    ap.time.Time(t, format='unix').to_datetime()
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/astropy/time/core.py", line 1444, in to_datetime
    return tm._shaped_like_input(tm._time.to_value(timezone))
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/astropy/time/formats.py", line 596, in to_value
    self.jd1, self.jd2)
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/astropy/_erfa/core.py", line 21906, in d2dtf
    check_errwarn(c_retval_out, 'd2dtf')
  File "/Users/lzkelley/anaconda3/lib/python3.5/site-packages/astropy/_erfa/core.py", line 118, in check_errwarn
    warnings.warn('ERFA function "' + func_name + '" yielded ' + wmsg, ErfaWarning)
  File "/Users/lzkelley/Programs/zcode/zcode/inout/inout_core.py", line 845, in warn_with_traceback
    traceback.print_stack()
/Users/lzkelley/anaconda3/lib/python3.5/site-packages/astropy/_erfa/core.py:118: ErfaWarning: ERFA function "d2dtf" yielded 1 of "dubious year (Note 5)"
  warnings.warn('ERFA function "' + func_name + '" yielded ' + wmsg, ErfaWarning)
Out[185]: datetime.datetime(2023, 9, 2, 0, 0)

ap.version.githash: ‘552a2de83e23b89192a91b423eb69d35ef5424df’ ap.version.version: ‘1.3’

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
pllimcommented, Sep 13, 2019

This has continued to confuse users downstream. I just got asked this question again today. @astrofrog said we should definitely make the warning less cryptic.

cc @bhilbert4

1reaction
lzkelleycommented, Feb 14, 2017

The note that the warning refers to is (from astropy/_erfa/core.py, which must be autogenerated somehow??):

    5) The warning status "dubious year" flags UTCs that predate the
       introduction of the time scale or that are too far in the future
       to be trusted.  See eraDat for further details.

what does “too far in the future to be trusted” mean? What sets the scale-time of trustability?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Time and Dates (astropy.time) — Astropy v5.2
time package is based on fast and memory efficient PyERFA wrappers around the ERFA time and calendar routines. All time manipulations and arithmetic...
Read more >
ErfaWarning and time-related AiapyUserWarning ... - GitLab
import astropy.units as u from astropy.time import Time from ... "taiutc" yielded 1 of "dubious year (Note 4)" warnings.warn('ERFA function ...
Read more >
dtf2d — PyERFA v2.0.0.2.dev13+gfb1f520
Encode date and time fields into 2-part Julian Date (or in the case of UTC ... next two +2 = time is after...
Read more >
Times and timestamps — GWpy 2.1.1 documentation
All gravitational-wave data are recorded with timestamps in the GPS time system (recording the absolute number of seconds since the start of the...
Read more >
Time and Dates (astropy.time) - The University of Texas at Austin
The basic way to use astropy.time is to create a Time object by supplying one or more input time values as well as...
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