WeatherData for the 15th day of each month

Suppose we have

WeatherData["Helsinki", "MeanTemperature", {{2007, 1, 1}, {2012, 12, 31}, "Day"}]


How we can have data just for 15th day of each month?

• I have a similar problem: Why does this work? In[73]:= WeatherData["KJFK", "TotalPrecipitation", {{1999, 10, 22}, {1999, 10, 22}, "Day"}] Out[73]= {{{1999, 10, 22}, 0}} But this does not? In[75]:= WeatherData["KJFK", "TotalPrecipitation", {1999, 10, 22}] Out[75]= Missing["NotApplicable"] – jackie Dec 2 '13 at 2:50
• @jackie please look at the answers it will solve most of your problems but FYI don't trust the data in Wolfram Alpha servers 100%. For reliable data you need to pay and buy from reliable meteorological sources.Weather data on Wolfram Alpha servers are not 100 percent accurate , a lot of data missing or repeating itself. – Alex Dec 2 '13 at 12:14

After grabbing the data from WeatherData, use Cases to get only those datapoints obtained on the 15th day:

data = WeatherData["Helsinki",
"MeanTemperature", {{2011, 1, 1}, {2012, 12, 31}, "Day"}];
just15 = Cases[data, x_ /; x[[1, 3]] == 15];

• Hi it seems that I made mistake in writing the question.I changed it sorry – Alex Jun 30 '13 at 1:55
• @Alex that should do the trick, then. Note I changed your start date so I didn't download a whole bunch of weather data. – bobthechemist Jun 30 '13 at 2:26

I was surprised to find that

WeatherData["Helsinki", "MeanTemperature", {{2007, 1, 15}, {2012, 12, 15}, "Month"}]


doesn't work as expected. It instead returns data for the 15th of the first month, then the 1st of every following month. I tried to be clever and generate the dates by hand, and pass them in, but this doesn't go well:

dates[d1_, d2_] :=
DatePlus[d1, {#, "Month"}] & /@ Range[0, DateDifference[d1, d2, "Month"][[1]]]

WeatherData["Helsinki", "MeanTemperature", #] & /@ dates[{2007, 1, 15}, {2012, 12, 15}]

(* {Missing[NotApplicable], Missing[NotApplicable]..... *)


despite the data obviously being available. I don't like the thought of having to import all of the data, then throw away the majority that is unimportant. Anybody know why this method fails?

Edit: More concisely, why does this work:

WeatherData["Helsinki", "MeanTemperature", {{2007, 1, 15}, {2007, 1, 16}, "Day"}]

(* {{{2007, 1, 15}, -0.44}, {{2007, 1, 16}, 2.89}} *)


but this doesn't:

WeatherData["Helsinki", "MeanTemperature", {2007, 1, 15}]

(* Missing[NotApplicable] *)


Edit 2:

One (gross) solution is to use:

WeatherData["Helsinki", "MeanTemperature", {#,#,"Day"}] & /@
dates[{2007, 1, 15}, {2012, 12, 15}]

(* {{{2007, 1, 15}, -0.44}, {{2007, 2, 15}, -5.67}, {{2007, 3, 15}, 3.56}... *)


to pass single day "ranges". The multiple calls to WeatherData end up being much slower than just importing all of the data and filtering it, though.

• 1) If you are stepping by Month, then one might have to assume that the "first" of the month is the stepping stone. i.e. 1 Month is not necessarily 30 days. 2) It seems your @/ idiom is calling WeatherData many times, not just supplying a list of dates, which is related to 3) not returning a value with one date supplied seems like a bug, or perhaps unclear documentation for WeatherData. – Eric Brown Jun 30 '13 at 4:25
• The mapping ( /@ ) simply results in a bunch of single date calls. The documentation says this is possible, but doesn't give an example. Despite months being of different lengths, you can do a DatePlus[] on the 15th of any month and always get the 15th of the next. I assumed that WeatherData[] would be similarly smart about it. – Corey Kelly Jun 30 '13 at 4:28
• It seems DatePlus simply increments the month field of {y,m,d} -- I guess this is the behavior you were hoping for. "gives measurements aggregated over the time period represented by step" would seem to mean only month matters, and the behavior seems consistent with the documentation. (But not consistent with DatePlus, I agree) – Eric Brown Jun 30 '13 at 4:40
• I'm not sure what is meant by "aggregated" in this context. Certainly not averaged, and it only gives one measurement per "step", so I don't see what is aggregating. – Corey Kelly Jun 30 '13 at 4:43
• I interpret it to mean the "Month" of {2007,1,15} would be "MedianTemperature" in Jan. 2007. The next month's date is {2007,2,1} and that would be Feb. 2007. – Eric Brown Jun 30 '13 at 4:46