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

SSAPy PlotUtils koe_plot() astropy TimeDelta Warning #19

Closed bbreisch26 closed 2 months ago

bbreisch26 commented 3 months ago

Describe the bug The latest version of SSAPy raises the following warning upon import:

> python
Python 3.10.10 (main, Mar 21 2023, 18:45:11) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssapy
WARNING: TimeDeltaMissingUnitWarning: Numerical value without unit or explicit format passed to TimeDelta, assuming days [astropy.time.core]

To Reproduce SSAPy version: 9ed512e Astropy version: 6.1.2 Steps to reproduce the behavior:

  1. Install SSAPy
  2. Import SSAPy (import ssapy)

I have tracked this warning through the __init__.py file where it imports plotUtils.py. The warning is raised by the following function signature in plotUtils.py: def koe_plot(r, v, t=Time("2025-01-01", scale='utc') + np.linspace(0, int(1 * 365.25), int(365.25 * 24)), elements=['a', 'e', 'i'], save_path=False, body='Earth'):

Specifically this is raised by astropy's TimeDelta function because the np.linspace array that is added to the Time object does not have a specified unit.

A proposed solution: Change the keo_plot signature to: def koe_plot(r, v, t= np.linspace(Time("2025-01-01", scale='utc'), Time("2026-01-01", scale='utc'), int(365.25*24)), elements=['a', 'e', 'i'], save_path=False, body='Earth'):

This is supported by Astropy>=5.1 (source)

Desktop (please complete the following information):