Message Boards Message Boards

0
|
2116 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Retrieving historic weather data (max temperature)

Posted 1 year ago

Hi;

I am trying to retrieve the historic maximum daily temperature in Egypt (Cario Egypt) on a specific date without any success - see attached notebook.

Since I am new at using the Wolfram Repository, I am sure it is something that I am doing incorrectly.

Thanks,

Mitch Sandlin

Attachments:
POSTED BY: Mitchell Sandlin
4 Replies

Hi Mitchell

Forecast data is only available for dates in the future (hence forecast).

WeatherForecastData[Entity["City", {"Cairo", "Cairo", "Egypt"}], "MaxTemperature", Tomorrow]

For dates in the past use WeatherData

WeatherData[Entity["City", {"Cairo", "Cairo", "Egypt"}], "MaxTemperature",
  {{2021, 10, 1}, {2021, 10, 20}, "Day"}]
POSTED BY: Rohit Namjoshi

Hi Rohit;

Thank you so much for the information. It was extremely helpful. However, the solution you provided created a couple of small questions, regarding the "Tomorrow" keyword and working with TimeSeries, that I am hoping you can help me with - please see attached notebook.

Thanks again,

Mitch Sandlin

Attachments:
POSTED BY: Mitchell Sandlin

Hi Mitchell,

That looks like a bug in the rendering of the summary box. The underlying data is correct.

wf = WeatherForecastData[Entity["City", {"Cairo", "Cairo", "Egypt"}], "MaxTemperature", Tomorrow]
wf["DatePath"]

(* {{DateObject[{2023, 4, 6, 0, 0, 0.}, "Instant", "Gregorian", -5.], Quantity[81.1, "DegreesFahrenheit"]}} *)

A TimeSeries has several properties

ts = WeatherData[Entity["City", {"Cairo", "Cairo", "Egypt"}], 
  "MaxTemperature", {{2021, 10, 23}, {2021, 11, 06}, "Day"}]

ts["Properties"]
(* {"DatePath", "Dates", "FirstDate", "FirstTime", "FirstValue", 
"LastDate", "LastTime", "LastValue", "Path", "PathComponent", 
"PathComponents", "PathFunction", "PathLength", "Times", 
"ValueDimensions", "Values"} *)

"DatePath" was used to get the underlying {date, value} pairs for the forecast. The properties are documented in the "Details and Options" section of the TimeSeries documentation.

POSTED BY: Rohit Namjoshi

I just noticed that the notebook you attached was also trying to convert the TimeSeries to a Dataset. Here is one way to do that

AssociationThread[{"Date", "Temperature"}, #] & // 
  Map[#, ts["DatePath"] ] & // Dataset
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract