if (FALSE) {
# The following commands download and process Daymet data
# for 10 years of the >30 year of data available since 1980.
daymet_data <- download_daymet(
"testsite_name",
lat = 36.0133,
lon = -84.2625,
start = 2000,
end = 2010,
internal = TRUE
)
# We can now quickly calculate and plot
# daily mean temperature. Also, take note of
# the weird format of the header. This format
# is not altered as to keep compatibility
# with other ways of acquiring Daymet data
# through the ORNL DAAC website.
# The below command lists headers of
# the downloaded nested list.
# This data includes information on the site
# location etc. The true climate data is stored
# in the "data" part of the nested list.
# In this case it can be accessed through
# daymet_data$data. Other attributes include
# for example the tile location (daymet_data$tile),
# the altitude (daymet_data$altitude), etc.
str(daymet_data)
# load the tidyverse (install if necessary)
if(!require(tidyverse)){install.package(tidyverse)}
library(tidyverse)
# Calculate the mean temperature from min
# max temperatures and convert the year and doy
# to a proper date format.
daymet_data$data <- daymet_data$data |>
mutate(
tmean = (tmax..deg.c. + tmin..deg.c.)/2,
date = as.Date(paste(year, yday, sep = "-"), "%Y-%j")
)
# show a simple graph of the mean temperature
plot(daymet_data$data$date,
daymet_data$data$tmean,
xlab = "Date",
ylab = "mean temperature")
# For other practical examples consult the included
# vignette.
}
Run the code above in your browser using DataLab