LLNL / SSAPy

A Python package allowing for fast and precise orbital modeling.
https://software.llnl.gov/SSAPy/
MIT License
36 stars 8 forks source link

Fixed TimeDelta Warning from astropy #20

Closed bbreisch26 closed 2 months ago

bbreisch26 commented 3 months ago

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.