Current data is read from files managed by currentsfiles. Dates are matched to file names by finding the nearest match in time within a short duration. By default only one time step is returned with both U and V components. Multiple dates can be returned for magnitude or direction, U or V only.

readcurr(
  date,
  time.resolution = c("daily"),
  xylim = NULL,
  lon180 = TRUE,
  magonly = FALSE,
  dironly = FALSE,
  uonly = FALSE,
  vonly = FALSE,
  latest = TRUE,
  returnfiles = FALSE,
  ...,
  inputfiles = NULL
)

Arguments

date

date or dates of data to read, see Details

time.resolution

time resolution to read

xylim

spatial extents to crop from source data, can be anything accepted by extent, see Details

lon180

defaults to TRUE, to "rotate" Pacific view 0, 360 data to Atlantic view -180, 180

magonly

return just the magnitude from the U and V components

dironly

return just the direction from the U and V, in degrees N=0, E=90, S=180, W=270

uonly

return just the U component of velocity

vonly

return just the V component of velocity components, in degrees (0 north, 90 east, 180 south, 270 west)

latest

if TRUE (and date not supplied) return the latest time available, otherwise the earliest

returnfiles

ignore options and just return the file names and dates

...

passed to brick, primarily for filename

Value

raster object with the "U" (meridional/horizontal/X) and "V" (zonal/vertical/Y) components of velocity in m/s. Setting either of the (mutually exclusive) magonly

and dironly arguments returns the magnitude (in m/s) or direction (in degrees relative to North) of the velocity vectors.

Details

This is the "DT merged all satellites Global Ocean Gridded SSALTO/DUACS Sea Surface Height L4 product and derived variables" See References.

Note

These data for daily files are stored in longitude/latitude projection on the sphere between longitudes in the Pacific view [0, 360], the default behaviour is to reset this to Atlantic view [-180, 180] with lon180.

See also

icefiles for details on the repository of data files, raster for the return value

Examples

## read a single time slice, and plot the directions [0,360) as an image with arrows
x <- readcurr(dironly = TRUE)
#> Error in .vrt_dsn(files$fullname, sds = "ugos", bands = 1L): could not find function ".vrt_dsn"
## get a local extent for a zoom plot
e <- extent(projectExtent(raster(extent(130, 150, -50, -30), crs = "+proj=longlat"), projection(x)))
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'extent': object 'x' not found
x <- crop(readcurr(), e)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'crop': could not find function ".vrt_dsn"
crds <- coordinates(x)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'obj' in selecting a method for function 'coordinates': object 'x' not found
scale <- 1.5
vlen <- function(x) sqrt(x[[1]]^2 + x[[2]]^2)
plot(vlen(crop(x, e)))
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'plot': error in evaluating the argument 'x' in selecting a method for function 'crop': object 'x' not found
x1 <- crds[,1]
#> Error in eval(expr, envir, enclos): object 'crds' not found
y1 <- crds[,2]
#> Error in eval(expr, envir, enclos): object 'crds' not found
x2 <- crds[,1] + values(x[[1]]) * scale
#> Error in eval(expr, envir, enclos): object 'crds' not found
y2 <- crds[,2] + values(x[[1]]) * scale
#> Error in eval(expr, envir, enclos): object 'crds' not found
arrows(x1, y1, x2, y2, length = 0.03)
#> Error in arrows(x1, y1, x2, y2, length = 0.03): object 'x1' not found