vignettes/1 Download and process NLDAS.Rmd
1 Download and process NLDAS.Rmd
This article describes downloading and processing total incoming shortwave radiation (W m-2) using the StreamLightUtils package. Total incoming shortwave radiation (W m-2) is provided by the National Land Data Assimilation System (NLDAS) at hourly timesteps at 0.125 degree spatial resolution. There are two potential workflows available: 1.) download data for a single site, and 2.) bulk download of data for many sites.
Incoming shortwave radiation data at a single site can be downloaded using the function NLDAS_DL which has the following structure:
NLDAS_DL(save_dir, Site_ID, Lat, Lon, startDate)
Once the data has been downloaded it requires some processing to format date and time information and extract the relevant data. The downloaded NLDAS data can be processed using the function NLDAS_proc which has the following structure:
NLDAS_proc(read_dir, Site_IDs)
#Set the download location (add your own directory)
working_dir <- "C:/"
#Download NLDAS data at NC_NHC
NLDAS_DL(
save_dir = working_dir,
Site_ID = "NC_NHC",
Lat = 35.9925,
Lon = -79.0460,
startDate = "2017-01-01"
)
#Process the downloaded data
NLDAS_processed <- NLDAS_proc(
read_dir = working_dir,
Site_IDs = "NC_NHC"
)
Incoming shortwave radiation data at multiple sites can be downloaded using the function NLDAS_DL_bulk which has the following structure:
NLDAS_DL_bulk(save_dir, site_locs, startDate)
Recall from earlier that our table of site information has a column called “startDate”, so here the optional parameter is not used. If data fails to download for a site, the NLDAS_DL_bulk function will automatically check and retry downloading data for all sites with missing data. However, it is possible that data does not exist for a site. Consequently, it is prudent to confirm the successfully downloaded sites.
#Read in a table with initial site information
sites <- data(NC_site_basic)
#Download NLDAS data at NC_NHC
NLDAS_DL_bulk(
save_dir = working_dir,
site_locs = sites
)
#List of successfully downloaded sites
NLDAS_list <- stringr::str_sub(list.files(working_dir), 1, -11)
#Processing the downloaded NLDAS data
NLDAS_processed <- StreamLightUtils::NLDAS_proc(read_dir = working_dir, NLDAS_list)