Group Abstract Group Abstract

Message Boards Message Boards

Combine TimeSeriesThread and WeatherData?

POSTED BY: Christopher Fox
4 Replies

Thank you again, Henrik. That makes it perfectly clear, and I've built an example that demonstrates if the time/date stamps match for the two time series, WeatherData works as expected:

DateListPlot[
 TimeSeriesThread[
  First[#] - Last[#] &, {WeatherData["Richmond", 
    "MaxTemperature", {{2017, 1, 1}, {2017, 12, 31}, "Day"}], 
   WeatherData["Syracuse", 
    "MaxTemperature", {{2017, 1, 1}, {2017, 12, 31}, "Day"}]}]]

Thanks again for your help.

POSTED BY: Christopher Fox

Thank you, Henrik.

I realized my "off by one" error on my drive in to work this morning as I was thinking about this problem further.

There's an example of TimeSeriesThread that is based on calendar dates from FinancialData:

goog = FinancialData["GOOGL", "2012"];
appl = FinancialData["AAPL", "2012"];
DateListPlot[TimeSeriesThread[First[#] - Last[#] &, {goog, appl}]]

Any thoughts as to why this works, but not a WeatherData?

Thanks again for your help.

POSTED BY: Christopher Fox
POSTED BY: Henrik Schachner

Hi Christopher,

I guess TimeSeriesThread is not suitable for your problem, because the output you want cannot be assigned to a specific date but just to a month in general. So the simplest solution would probably be to extract just the temperatures (which are sorted in monthly order anyway):

wd = WeatherData["Syracuse", "MaxTemperature", {{#, 1, 1}, {#, 12, 31}, "Month"}] & /@ Range[2000, 2017];
meanTemps = Mean /@ Transpose[Map[Last, Normal@wd, {2}]];
ListLinePlot[meanTemps, AxesLabel -> {"month", Automatic}]

By they way: The number in question is 18 (i.e. Range[2000, 2017] // Length)

I hope this helps, regards -- Henrik

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard