Skip to content

Commit

Permalink
Merge pull request #163 from sot/fix-convert-time-spk
Browse files Browse the repository at this point in the history
Allow None input to convert_time_format_spk
  • Loading branch information
taldcroft authored Dec 11, 2023
2 parents 87d5d60 + c041710 commit d6be88f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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)

0 comments on commit d6be88f

Please sign in to comment.