Creating a Time Series Forecast with NDFD Grip Data
0:00:00 Introduction: The video demonstrates how to generate a time series forecast for a specific location using raw NDFD (National Digital Forecast Database) data, similar to the National Weather Service (NWS) website's point-and-click forecast feature.
0:00:14 Importing Libraries: The process begins by importing necessary libraries, including pygrib for handling GRIB files, numpy for numerical operations, matplotlib.pyplot for plotting, and datetime for time-related functions.
0:01:38 Accessing GRIB Data: The presenter has pre-downloaded the GRIB data. The pygrib.open command is used to access the temperature data from the GRIB file.
0:01:56 Extracting Latitude and Longitude: Latitude and longitude information is extracted from a GRIB message using the msg.latlons() method. grbs.rewind() is used to reset the GRIB file pointer to the beginning.
0:02:53 Finding the Closest Grid Point: The script calculates the closest grid point to a target location (Boulder, CO, in this example) by finding the minimum squared distance between the target coordinates and the grid points. The numpy.argmin and numpy.unravel_index functions are used to determine the 2D index of the closest point.
0:05:21 Extracting Time Series Data: The code iterates through the GRIB messages, appending the valid date/time (msg.validDate) and the temperature value at the closest grid point to separate lists.
0:06:25 Unit and Time Zone Handling: Units (Kelvin) are attached to the temperature data using metpy.units, and the values are converted to Fahrenheit. The naive datetime objects are made timezone-aware (UTC) and then converted to the local time zone (Mountain Standard Time).
0:07:52 Plotting the Time Series: The matplotlib.pyplot.subplots function creates a figure and axes. The ax.plot_date function plots the local time versus temperature in Fahrenheit.
0:08:28 Adding Labels and Reference Line: Axis labels and a horizontal line at 32Β°F are added to the plot for clarity.
0:09:24 Handling Snow Accumulation Data: The process is repeated with a different GRIB file containing snow accumulation data. The video demonstrates the use of numpy.cumsum to calculate the cumulative snow accumulation over time.
0:10:46 Conclusion: The video concludes by highlighting the utility of pygrib for working with NDFD forecast data and generating time series for specific locations.