Appendix B — Production of HYSPLIT trajectory files

Author

David Carslaw

As discussed in Chapter 10, openair can import pre-calculated trajectory data for specified locations for whole years run at a 3-hour interval. The data are stored on a Ricardo webserver to make it easy to import 96-hour back trajectory data. Several users have requested how they can run HYSPLIT themselves e.g. for different trajectory start heights or for many locations. It should be noted that Hysplit is a powerful and flexible model and to exploit its full potential, users should consider using Hysplit directly (Stein et al., 2015).

Stein, A.F., Draxler, R.R., Rolph, G.D., Stunder, B.J.B., Cohen, M.D., Ngan, F., 2015. NOAAs HYSPLIT Atmospheric Transport and Dispersion Modeling System. Bulletin of the American Meteorological Society 96, 2059–2077. https://doi.org/10.1175/bams-d-14-00110.1

A well-written R package called splitr by Rich Iannone (see here) provides a lot of flexibility for working with different meteorological inputs and Hysplit options. Users should consider splitr if they want more control over Hysplit options — especially for the detailed investigation of short time periods such as pollution episodes where higher resolution meteorological data is useful.

This focus of this section is to run Hysplit with the Reanalysis meteorological data over periods of a year to allow for the analysis of longer-term air quality data analysis. The code below assumes that full years are run, but it could be adopted for shorter periods. There are three main parts to producing trajectory files:

  1. Download and install the NOAA Hysplit model, somewhere with write access (see below).

  2. Download the monthly meteorological (.gbl) files also from the NOAA website.

  3. Obtain the code to run Hysplit.

To run back trajectories it is necessary to download the meteorological data files. The easiest way to download the meteorological files is using the function below.

getMet <- function(year = 2013, month = 1,
                   path_met = "~/TrajData/") {
  for (i in seq_along(year)) {
    for (j in seq_along(month)) {
      download.file(
        url = paste0(
          "https://www.ready.noaa.gov/data/archives/reanalysis/RP",
          year[i], sprintf("%02d", month[j]), ".gbl"
        ),
        destfile = paste0(
          path_met, "RP", year[i],
          sprintf("%02d", month[j]), ".gbl"
        ),
        mode = "wb"
      )
    }
  }
}

The function will download monthly met files (each about 120 MB) to the chosen directory. Note that the met data files only need be downloaded once. For example, to download files for 2013:

getMet(year = 2013, month = 1:12)

It is first necessary on ensure that the devtools package is installed, which is needed to load some R functions stored as a GitHub gist (some code that can be shared publicly). Copy the code below and paste it into R, which will load the necessary functions needed to run Hysplit.

library(devtools)
source_gist("https://gist.github.com/davidcarslaw/c67e33a04ff6e1be0cd7357796e4bdf5",
            filename = "run_hysplit.R")

Now there should be several loaded functions, including run_hysplit. To run Hysplit, have a look at the examples here.

For example

data_out <- run_hysplit(
latitude = 36.134, 
 longitude = -5.347, 
  runtime = -96, 
  start_height = 10, 
  model_height = 10000, 
  start = 2015,
  end = "2015-01-10",
  hysplit_exec = "~/hysplit/exec", 
  hysplit_input = "~/trajData", 
  hysplit_output = "~/temp",
  site = "gibraltar")

The data_out can then be used directly in openair trajectory functions. The code will also return information from Hysplit such as pressure, temperature, terrain and boundary layer height.

Most of the options should be self-explanatory but hysplit_exec is the path to the Hysplit executable, hysplit_input is the path to the meteorological files (downloaded as described above) and hysplit_output is the directory where Hysplit will write its temporary files.

Once run it is then advisable to store the data somewhere. Save it like:

saveRDS(data_out, file = "~/trajProc/myTrajData.rds")

Then it is easy to read in later and use e.g.

traj <- readRDS("~/trajProc/myTrajData.rds")