knitr::opts_chunk$set(echo = TRUE)

In this vignette, we show how we prepared the monthly mean planetary boundary layer heights data that can be downloaded using the get_data() function specifying the data = "pblheight".

First, we load the packages that we will need for completing this task.

library(disperseR)
library(data.table)
library(tidyverse)

In case you have not yet created your project folder use the following command.

disperseR::create_dirs()

First we specify the file names and the url where we download the data from. We used the data available on the ESRL website.

directory <- hpbl_dir
file <- file.path(directory, 'hpbl.mon.mean.nc')
url <-'https://www.esrl.noaa.gov/psd/repository/entry/get/hpbl.mon.mean.nc?entryid=synth%3Ae570c8f9-ec09-4e89-93b4-babd5651e7a9%3AL05BUlIvTW9udGhsaWVzL21vbm9sZXZlbC9ocGJsLm1vbi5tZWFuLm5j'

If the file does not exist in the folder download it as follows:

if (!file.exists(file)){
  download.file(url = url, destfile = file)
}

Before reading in, it is necessary to set the system time zone to UTC so that the dates are formatted correctly in the raster files.

Sys.setenv(TZ = 'UTC')
hpbl_rasterin <- suppressWarnings(raster::brick(x = file, varname = 'hpbl'))

The following is done to fix error in the dataset. For more information please see here

crs(hpbl_rasterin) <- "+proj=lcc +x_0=5632642.22547 +y_0=4612545.65137 +lat_0=50 +lon_0=-107 +lat_1=50"

Now hpbl_rasterin is prepared and ready to use.



lhenneman/disperseR documentation built on Nov. 14, 2021, 6:24 p.m.