4
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – Jason B. Aug 10 '16 at 18:21
  • $\begingroup$ Thanks for trying it out in 11. I have a workaround for now. $\endgroup$ – Spencer Rugaber Aug 17 '16 at 15:19
1
$\begingroup$

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.