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

Allow None input to convert_time_format_spk #163

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chandra_aca/planets.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def convert_time_format_spk(time, fmt_out):
ndarray or numpy scalar
Converted time or times
"""
if fmt_out not in ("jd", "secs"):
if fmt_out not in ("jd", "secs") or time is None:
return getattr(CxoTime(time).tdb, fmt_out)

# Check if input is in "secs" by determining if it is a float type scalar or array
Expand Down
9 changes: 9 additions & 0 deletions chandra_aca/tests/test_planets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from testr.test_helper import has_internet

from chandra_aca.planets import (
convert_time_format_spk,
get_planet_angular_sep,
get_planet_barycentric,
get_planet_chandra,
Expand Down Expand Up @@ -194,3 +195,11 @@ def test_get_planet_ang_separation_array(obs_pos, exp_sep):
ra0, dec0 = 304.89116, -20.08328
sep = get_planet_angular_sep("jupiter", ra0, dec0, times, observer_position=obs_pos)
assert np.allclose(sep * 3600, exp_sep, atol=1e-2, rtol=0)


def test_convert_time_format_spk_none():
"""Test bug fix where convert_time_format_spk failed when time was None"""
time0 = convert_time_format_spk(None, "secs")
time1 = CxoTime(None).secs
# Times within 10 seconds
assert np.isclose(time0, time1, atol=10, rtol=0)