WeatherData[]
can give you what you want:
startdate = DateList[];
city = "Amsterdam"
startpoint = 5 (*hours ago: for amsterdam, the most recent data was not available...*)
range = 48 (*in hours*)
data = WeatherData[city,"Temperature", #] & /@
(DatePlus[DateList[], {-#, "Hour"}][[1 ;; 4]] & /@ Range[startpoint, range]);
For some reason WeatherData
returns the temperature for every half hour, although I asked for hours, but you can delete the odd elements if you want to.
And finally: getting rid of the weird layout with timestamps embedded:
Select[Flatten[data, 2], NumberQ]
Result:
{12., 11., 13., 13., 11.9, 12., 12., 12., 12., 10., 11., 9.1, 9.,10., 9.,
9., 9., 9., 8.8, 9., 9., 9., 9., 9., 9., 9., 9., 9., 9., 9.,9., 9., 9.4,
9., 9., 9., 9., 10., 10., 9.6, 10., 10., 10., 10., 10.,10., 9.8, 10.,
10., 10., 10., 10., 10., 10.6, 11., 10., 11., 11.,11., 11., 10.1, 10.,
11., 10., 10., 9., 10., 8.7, 9., 9., 9., 9., 8.,8., 7.9, 8., 8., 8., 8.,
8., 8., 7.6, 8., 8., 8., 8., 8., 8., 7.5,7.,7., 7.6, 8, 8., 7.5, 7, 6.8, 7}
Explanation:
Range[startpoint, range]
This makes a list of all integers from startpoint to range.
(DatePlus[startdate, {-#, "Hour"}][[1 ;; 4]] &/@ Range[startpoint, range])
Then i Map[]
(&/@
or look in the help files) over DatePlus[]
to make a list of every single moment you want to get temperature data from in the form mma displays dates and times.
WeatherData[city,"Temperature", #]
Finally i Map[]
the list over the WeatherData[]
function.
Just change the values you want to enter and you should be ok without understanding the exact code ("Amsterdam" to "New York","Temperature" to "Humidity", etcetera)
Edit: added explanation.
WeatherData
which can retrieve lists of weather readings over various periods of time.Save
can be used to store data in external files between sessions. $\endgroup$WeatherData
you'll need to make the stepsizeAll
and parse out the hourly information (if it's there) since you can't ask for an interval less than a day $\endgroup$