Message Boards Message Boards

GROUPS:

Finding a weather station with the longest record?

Posted 6 days ago
270 Views
|
4 Replies
|
11 Total Likes
|

Hi,

How do I find a weather station with the longest recorded daily air temperature data among all stations using Mathematica?

I appreciate your help.

allWeatherstations = WeatherData[]

fullformStations = FullForm /@ allWeatherstations

enter image description here

POSTED BY: Alex Teymouri
4 Replies

By "longest" I guess you mean with "maximum number of data points". There are a lot of weather stations data in the WL database (~ 35K).

In[1]:= EntityList[EntityClass["WeatherStation", All]] // Length

Out[1]= 35172

However, they are categorized into several EntityClass.

In[2]:= EntityValue["WeatherStation","EntityClasses"]

Out[2]= {EntityClass["WeatherStation", "WMO"], EntityClass["WeatherStation", "CWOP"], EntityClass["WeatherStation", "NCDC"], EntityClass["WeatherStation", "WBAN"], EntityClass["WeatherStation", All]}

Let's take one of that classes with a minimum (seven) number of stations:

In[3]:= EntityList[EntityClass["WeatherStation", "WBAN"]]

Out[3]= {Entity["WeatherStation", "CYUB"],Entity["WeatherStation", "K1H2"],Entity["WeatherStation", "KDTA"], Entity["WeatherStation", "KNAK"], Entity["WeatherStation", "KNFE"],Entity["WeatherStation", "KVKS"], Entity["WeatherStation", "MYEM"]}

We can identify the geographic location of the above stations as follows:

In[4]:= GeoIdentify["Country", #] & /@ GeoPosition /@ EntityList[EntityClass["WeatherStation", "WBAN"]]

Out[4]= {{Entity["Country", "Canada"]}, {Entity["Country", "UnitedStates"]}, {Entity["Country", "UnitedStates"]}, {}, {Entity["Country", "UnitedStates"]}, {Entity["Country", "UnitedStates"]}, {Entity["Country", "Bahamas"]}}

Next, for the temperature data between 1 Aug 2022 and 2 Aug 2022, we use the function AirTemperatureData :

In[5]:= airTemp = Join @@ (<|# -> AirTemperatureData[#, {DateObject[{2022, 8, 1}],DateObject[{2022, 8, 2}]}]|> &/ @ EntityList[EntityClass["WeatherStation", "WBAN"]]) // DeleteMissing

The output of the above In[5] is a list of TimeSeries with the corresponding number of data points.

By creating Association between stations and their data and using DeleteMissing to remove missing data entries, we can visualize the data (available for three) using DateListPlot function:

DateListPlot[airTemp, PlotMarkers -> Automatic, PlotRange -> Automatic, PlotLegends -> Automatic, FrameLabel -> {"Time", "Temperature (°C)"}]

enter image description here

Hence, the weather station (within the specific EntityClass of "WBAN") having the maximum number of data points is K1H2.

POSTED BY: Adiba Shaikh
Posted 5 days ago

An interesting solution way. Thank you, Adiba.

I mean introducing the station with the longest records (historical time series e.g. 1990-2022) in Mathematica. I will try to use your explanations for finding this station.

I appreciate your time and help.

Alex

POSTED BY: Alex Teymouri

Hi Alex,

You are welcome!

Now that I understand what you meant - let me provide you with a more specific response.

You can check the historical data in any of the previously mentioned EntityClass of weather stations as follows.

For the first 10 stations within EntityClass["WeatherStation", "WMO"], I found data far back to around the 1940s for some of them. Here, I am looking for the monthly mean temperature for the last hundred years.

In[1]:= <|# -> DateListPlot[WeatherData[#, "MeanTemperature", {{1922}, {2022}, "Month"}], 
     Joined -> True]|> & /@ EntityList[EntityClass["WeatherStation", "WMO"]][[1 ;; 10]]

Output: enter image description here

Also, I would like to mention the Wolfram Data Repository which has various recent and historical meteorological datasets that you may find helpful.

POSTED BY: Adiba Shaikh

Dear Adiba,

Thank you so much for this interesting way to find the station with the longest historical record.

I really really appreciate your time.

Have a good day :)

POSTED BY: Alex Teymouri
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