Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed TimeDelta Warning from astropy #20

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

bbreisch26
Copy link
Contributor

Fixes #19

Comparison of behavior:

Current koe_plot t variable code:

>>> Time("2025-01-01", scale='utc') + np.linspace(0, int(1 * 365.25), int(365.25 * 24))
WARNING: TimeDeltaMissingUnitWarning: Numerical value without unit or explicit format passed to TimeDelta, assuming days [astropy.time.core]
<Time object: scale='utc' format='iso' value=['2025-01-01 00:00:00.000' '2025-01-01 00:59:57.946'
 '2025-01-01 01:59:55.893' ... '2025-12-31 22:00:04.107'
 '2025-12-31 23:00:02.054' '2026-01-01 00:00:00.000']>
>>> len(Time("2025-01-01", scale='utc') + np.linspace(0, int(1 * 365.25), int(365.25 * 24)))
8766

Updated koe_plot t variable code - this passes the Time object directly to np.linspace, which is supported by astropy>=5.1.

>>> np.linspace(Time("2025-01-01", scale='utc'), Time("2026-01-01", scale='utc'), int(365.25*24))
<Time object: scale='utc' format='iso' value=['2025-01-01 00:00:00.000' '2025-01-01 00:59:57.946'
 '2025-01-01 01:59:55.893' ... '2025-12-31 22:00:04.107'
 '2025-12-31 23:00:02.054' '2026-01-01 00:00:00.000']>
>>> len(np.linspace(Time("2025-01-01", scale='utc'), Time("2026-01-01", scale='utc'), int(365.25*24)))
8766

As you can see, the updated code produces the same astropy Time object without raising the warning.

Copy link
Contributor

@igoumiri igoumiri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! (I can't merge it myself though)

@aperloff aperloff merged commit 88abe22 into LLNL:main Sep 12, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SSAPy PlotUtils koe_plot() astropy TimeDelta Warning
3 participants