Learn R Programming

apsimx (version 2.2)

get_daymet_apsim_met: Get DAYMET data for an APSIM met file

Description

Uses get_daymet from the FedData package to download data to create an APSIM met file.

Usage

get_daymet_apsim_met(
  lonlat,
  years,
  wrt.dir = ".",
  filename = NULL,
  width.height = c(0.1 * 1.263012, 0.1),
  template,
  label = NULL,
  elements = c("dayl", "prcp", "srad", "swe", "tmax", "tmin", "vp"),
  region = "na",
  tempo = "day",
  extraction.dir = paste0(tempdir(), "/FedData/extractions/daymet/", label, "/"),
  force.redo = FALSE,
  cleanup = FALSE
)

Arguments

lonlat

Longitude and latitude vector

years

a numeric vector of years to extract

wrt.dir

write directory

filename

file name for writing out to disk

width.height

width and height of the cropped area (default 0.001, 0.001)

template

A Raster or Spatial object to serve as a template for cropping (see get_daymet).

label

a character string naming the area (see get_daymet)

elements
region
tempo
extraction.dir
force.redo
cleanup

whether to delete download directories (default is FALSE). If the intention is for cleanup to delete all the files, ‘raw.dir’ and ‘extraction.dir’ should be supplied, supplying a sinlge name, such as ‘RAW’ and ‘EXTRACTION’.

Value

It returns an object of class ‘met’ and writes a file to disk when filename is supplied.

Details

This function requires the FedData pacakge.

If the filename is not provided it will not write the file to disk, but it will return an object of class ‘met’. This is useful in case manipulation is required before writing to disk. The variable ‘srad’ as downloaded from daymet is average solar radiation, so it is converted to total. Daily total radiation (MJ/m2/day) can be calculated as follows: ((srad (W/m2) * dayl (s/day)) / 1,000,000) Vapor Pressure Deficit (vp) should be in hecto Pascals

Examples

Run this code
# NOT RUN {
require(FedData)
## I write to a temp directory but replace as needed
tmp.dir <- tempdir()
dmet12 <- get_daymet_apsim_met(lonlat = c(-93,42),
                               extraction.dir = paste0(tmp.dir,"/FedData/extractions/daymet/"),
                               years = 2012)
summary(dmet12)
## Check for reasonable ranges 
check_apsim_met(dmet12)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab