METEO 810
Weather and Climate Data Sets

NetCDF, the NARR, and R

Prioritize...

In this section, you will link the NetCDF libraries with R through the package "ncdf4". You will also retrieve a file from the North American Regional Reanalysis to test the R/NetCDF interface.

Read...

The first thing that we want to do is install the ncdf4 package which is a set of function calls that connect R to the NetCDF libraries that you installed. This will allow us to read NetCDF files directly into R and perform all the graphing and analysis that we have done with other sources of data.

Do you remember how to install a package in R-Studio? When you are finished, you should be able to type the command: nc_version() at the R-prompt and be answered back with the version of the installed library. If you don't remember, I have placed the commands below (click to reveal).

Installing Package ncdf4...
> install.packages("ncdf4")
> library(ncdf4)

Now that we have the ncdf4 library installed, let's get some data. There are many sources of geophysical data in NetCDF format. However, we are going to be looking at data from the North American Regional Reanalysis (NARR, pronounced like "car"). 

To understand how a model reanalysis is created, recall that a traditional numerical model is "initialized" by mapping various point and spatial observations onto a defined grid (a process called "data assimilation"). The numerical model then applies mathematical equations to advance the model forecast variables in time. As time goes on, however, errors grow within these predicted fields so that eventually they are useless as predictors. A model reanalysis differs from a prognostic model in that it uses historical data for its initialization. This means that at regular time periods, more observations can be added to the model to "correct" (or nudge) the predicted fields. This technique doesn't eliminate error altogether, but it gives you a long-term, continuous (in time and space) record of data for vast numbers of observed and calculated variables. If used properly, reanalysis data can prove an invaluable input stream to weather and climate analytics decisions.

Before proceeding further, read these two articles on model reanalysis...

NARR Reading Assignment

  • For an overview, start with the Wikipedia page.
  • Next, read this paper on the NARR published in the Bulletin of the American Meteorological Society.
  • Finally, go to the ESRL/PSD NARR homepage and browse the information/links provided. Note that there are some handy plotting pages that will allow you to get quick graphics of NARR output.

If you go looking for NARR data, you will find the raw source to be Research Data Archive (RDA) at the National Centers for Atmospheric Research (NCAR). Here all of the NARR data is housed, from 1979 to present day. The problem with this site is that all of the raw data are stored in huge (~1 GB) files in GRIB format. This means that we will need to do considerable work to dig out the variables that we might want to analyze. We'll get to that problem later in the lesson. For now, let's return to the ESRL/PSD NARR homepage where the NARR files have been segmented and converted to NetCDF format. Yay!

Your next goal is to select a NARR output file (in NetCDF format) and save it to your local hard drive. Notice on the page that NARR data is separated into three categories: pressure-level data, subsurface data, and mono-level data. We are interested in the mono-level data because we want surface temperatures (mono-level data is any surface in the model that is not defined by a constant pressure level). Clicking on the mono-level link takes you to a page with a huge table which lists all of the available variables. Find the variable for 3-hour temperature and click on the download file prefix (should be "air.sfc.yyyy.nc"). This will take you to a folder containing all of the yearly files. Grab one of your choosing (scroll down) and save it to your local drive (I chose 1988). To check that everything worked correctly, you can open a command prompt in the folder you saved the file and type: ncdump -h air.sfc.1988.nc (or whatever your file is named) and see a description of the file header (the different variables and dimensions that describe the data). 

Now we are ready to dig into the data! Read on.