Getting Started With riweather
¶
Finding a weather station¶
Suppose you need weather data at a certain latitude and longitude. To list all weather stations in order of their distance to that site, use riweather.rank_stations
.
This gives us the name and USAF identifiers of all ISD weather stations in the United States, along with their latitudes and longitudes and their distances (in meters) to the target site. The “years” column is a list of years for which there is available weather data from that station. The “quality” column contains the quality of the data file for the corresponding year—this is based on the number of observations in the file.
You probably don’t need all of the thousands of weather stations that are returned, so let’s be more efficient and limit our search to stations that have data for 2024 and are within 20 km of our site.
Erie Municipal Airport is the closest station. To access its weather data, first create a Station
object using its USAF ID.
Alternatively, use riweather.select_station
, selecting the first station in the table by passing rank=0
.
Finding a station from a ZIP code¶
Only have a ZIP code for your site and not a precise latitude and longitude? No problem. If you pass a ZIP code to riweather.rank_stations
instead of lat/lon, it will rank the weather stations by their distances from the center point of the ZIP code tabulation area (ZCTA).
Behind the scenes, this uses the function riweather.zcta_to_lat_lon
to determine the center point.
Visualizing weather stations on a map¶
We can verify the location of our site and the nearest weather stations by plotting them on an interactive map with riweather.plot_stations
. The pin represents the lat/lon site and the cloud icons represent the weather stations. Click on a station to see its name, and click on a line to see the distance between a station and the site.
Warning
It’s probably not a good idea to plot the entire set of 2,000+ stations on a map. Make sure ranked_stations
is filtered down to a reasonable size first.
Fetching weather data¶
Let’s see how complete we can expect the data to be when we pull it by looking at the quality report.
The data for 2024 is "high"
quality, with more than 2,000 observations in each month and no months that are missing. Assuming they are evenly spaced, that corresponds to one observation roughly every 20 minutes.
Now we can use riweather.Station.fetch_data
to get weather data. We need air temperatures in Fahrenheit for 2024, hour-ending to align with a set of electricity meter readings, in the US Mountain time zone.
Other data points may be available as well, depending on the weather station. For example, we can pull wind speed (in meters per second) as well: