calc_u2 {evapoRe}R Documentation

Calculate Wind Speed at 2 Meters (u2)

Description

Computes wind speed at 2 meters (u2) based on wind speed measured at a different height ('z_u').

Usage

calc_u2(x, z_u = 10)

## S4 method for signature 'Raster'
calc_u2(x, z_u = 10)

## S4 method for signature 'character'
calc_u2(x, z_u = 10)

## S4 method for signature 'data.table'
calc_u2(x, z_u = 10)

Arguments

x

A 'Raster*' object, a file path ('character') to a raster file, or a 'data.table' containing wind speed data.

z_u

Measurement height (m) of the provided wind speed. Default is 10.

Details

For raster inputs, provide a 'Raster*' object or file path ('character') for wind speed at height 'z_u'. For 'data.table' input, provide a single 'data.table' with columns: '"lon"', '"lat"', '"date"', and '"value"', where '"value"' contains wind speeds at height 'z_u'.

If 'z_u' is 2, the function returns the input unchanged.

Value

Wind speed adjusted to 2 meters, returned as:

Examples


# Raster input
if (requireNamespace("raster", quietly = TRUE)) {
  wind_path <- file.path(tempdir(), "wind_speed.nc")

  if (file.exists(wind_path)) {
    dummie_u <- raster::brick(wind_path)
    u2_raster <- calc_u2(dummie_u, z_u = 10)
  }
}

# File path input
wind_path <- file.path(tempdir(), "wind_speed.nc")
if (file.exists(wind_path)) {
  u2_from_file <- calc_u2(wind_path, z_u = 10)
}

# data.table input
if (requireNamespace("data.table", quietly = TRUE)) {
  dt <- data.table::data.table(
    lon = c(10.0, 10.5),
    lat = c(45.0, 45.5),
    date = as.Date(c("2001-06-01", "2001-06-02")),
    value = c(3.5, 4.1)
  )
  u2_dt <- calc_u2(dt, z_u = 10)
}


[Package evapoRe version 1.0.1 Index]