calc_speed | R Documentation |
This function calculates wind or current speed from u and v component vector arrays.
calc_speed(l)
l |
A list composed of two environmental arrays (u and v component arrays) for a particular day. |
In each cell, speed (m/s) is given by Pythagoras' Theorem.
The function returns an array comprising wind/current speeds for each cell in the original arrays.
Edward Lavender
This function can be implemented within compute_field_from_fvcom
.
#### Step 1: Read example u and v files into a list # Define the path to the u and v files: path <- system.file("WeStCOMS_files", package = "fvcom.tbx", mustWork = TRUE) path <- paste0(path, "/") path_u <- paste0(path, "uwind_speed") path_v <- paste0(path, "vwind_speed") # Define the source files: source_u <- list.files(path_u, full.names = TRUE)[1] source_v <- list.files(path_v, full.names = TRUE)[1] # Define a list comprising u and v arrays with one element for each day: l <- lapply(list(source_u, source_v), function(source){ print(source) out <- R.matlab::readMat(source)$data print(utils::str(out)) return(out) }) #### Step 2: Compute wind speed wind_speed <- calc_speed(l) hist(wind_speed)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.