4

I have noticed some surprising behavior when executing the MoonPosition function. When I provide a range of dates, I get a TemporalData answer:

do1 = DateObject[{2016, 1, 1}];
do2 = DateObject[{2016, 1, 5}];
dr1 = DateRange[do1, do2];
mp1 = MoonPosition[dr1];
FullForm[mp1]
(* TemporalData[TimeSeries,List[List[List[List[Quantity... *)

However, if the DataRange comprises only one date, the function call fails:

dr2 = DateRange[do1, do1];
mp1 = MoonPosition[dr1];
mp2 = MoonPosition[dr2]
(* TemporalData::tpspc: The time specification {{{2016,1,1,0,0,0.}}} should be one of Automatic ... *)

If I use a single DataObject, rather than a singleton DateRange, I do get a result:

mp3 = MoonPosition[do1];
FullForm[mp3]
(* List[Quantity[... *)

This behavior became apparent when I was writing a function to derive the longitude of the Moon's positions at various times:

MoonLongitudesInRadians[y_Integer, d1_Integer: 1, d2_Integer: 0]

Notice that to make this work, I have to coerce both the input AND the output to MoonPosition (two cases for input - DateRange and DateObject; and two cases for output - TemporalData and List).

My question is, am I understanding the expected behavior of MoonPosition correctly? If so, wouldn't a natural extension of its behavior be to allow singleton DataRanges? What is the standard way for making this suggestion to the Mathematica developers?

Spencer Rugaber
  • 894
  • 4
  • 11
  • 1
    Couple of things I notice - this doesn't give an error in 11, and the output from MoonPosition[dr2] is the exact same in version 10 and 11. What changed is that apparently you can now have a TimeSeries object with only 1 time point, whereas previously you couldn't. – Jason B. Aug 10 '16 at 18:21
  • Thanks for trying it out in 11. I have a workaround for now. – Spencer Rugaber Aug 17 '16 at 15:19

1 Answers1

1

Jason B.'s answer concerning v11 holds true for v12. I consider the question answered.

Couple of things I notice - this doesn't give an error in 11, and the output from MoonPosition[dr2] is the exact same in version 10 and 11. What changed is that apparently you can now have a TimeSeries object with only 1 time point, whereas previously you couldn't.

– Jason B. Aug 10 '16 at 18:21

Spencer Rugaber
  • 894
  • 4
  • 11