11
$\begingroup$

When retrieving curated data, v10 now returns TimeSeries objects.

For example,

ts = WeatherData["KP60", "Temperature", {{2013, 7, 1}, {2013, 9, 30}}]

DateListPlot[ts]

What is the most convenient way to extract a range from this temporal data, for example for plotting purposes? E.g. only plot the first two weeks of August from this data.

I know I can simply convert it to a list using Normal and then use e.g. Select to filter. Is there anything better?

$\endgroup$
  • $\begingroup$ Congratulations on being our foremost question poster! $\endgroup$ – Mr.Wizard Jul 27 '14 at 15:45
  • $\begingroup$ WeatherData fails when I try w/ 10.0.1: ibraryFunction::versint: The version number 1 of the library is from a previous WolframLibrary that cannot support integers as large as 4472425792. Anyone else? $\endgroup$ – alancalvitti Sep 29 '14 at 17:43
16
$\begingroup$

One of the new operations on TimeSeries objects is TimeSeriesWindow. I think it does what you need.

ts = WeatherData["KP60", "Temperature", {{2013, 7, 1}, {2013, 9, 30}}];
DateListPlot[TimeSeriesWindow[ts, {{2013, 8, 1}, {2013, 8, 14}}]]

enter image description here

$\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.