diff --git a/gwcs/coordinate_frames.py b/gwcs/coordinate_frames.py index 5131a4d4..ead793ba 100644 --- a/gwcs/coordinate_frames.py +++ b/gwcs/coordinate_frames.py @@ -552,6 +552,13 @@ def _convert_to_time(self, dt, *, unit, **kwargs): if not hasattr(dt, 'unit'): dt = dt * unit + is_nan = np.isnan(dt) + if is_nan.any(): + dt[is_nan] = 0 + out = self.reference_frame + dt + out[is_nan] = np.nan + return out + return self.reference_frame + dt def coordinate_to_quantity(self, *coords): diff --git a/gwcs/tests/test_coordinate_systems.py b/gwcs/tests/test_coordinate_systems.py index 967657f8..6b0149e3 100644 --- a/gwcs/tests/test_coordinate_systems.py +++ b/gwcs/tests/test_coordinate_systems.py @@ -203,6 +203,13 @@ def test_temporal_absolute(): assert t.coordinates("2018-01-01T00:00:00") == Time("2018-01-01T00:00:00", scale='tai') +def test_temporal_nan(): + t = cf.TemporalFrame(reference_frame=Time("2018-01-01T00:00:00"), unit=u.s) + + ret = t._convert_to_time([0, np.nan]*u.s, unit=u.s) + assert np.allclose(ret.mask, [False, True]) + + @pytest.mark.parametrize('inp', [ (10 * u.deg, 20 * u.deg), ((10 * u.deg, 20 * u.deg),),