sl.trajectory.remaptime: Remap Times of Trajectories on Sphere

sl.trajectory.remaptimeR Documentation

Remap Times of Trajectories on Sphere

Description

Remap longitudes and latitudes of one or more trajectories on a sphere to a new time axis.

Usage

sl.trajectory.remaptime(oldtime, oldlat, oldlon, newtime, method = "linear", extrapolate = FALSE, return.remapinfo = FALSE, verbose = TRUE)

Arguments

oldtime

a numeric vector of length N > 1 specifying the original time axis; must increase strict monotonously.

oldlat

a numeric vector of length N or a numeric NxL matrix specifying the original latitudes of one or more trajectories.

oldlon

a numeric vector of length N or a numeric NxL matrix specifying the original longitudes of one or more trajectories.

newtime

a numeric vector of length M specifying the new time axis; must increase strict monotonously if M > 1.

method

a character specifying the interpolation method. Must be one of "linear" (default) and "nearestneighbour".

extrapolate

a logical value specifying whether or not to extrapolate to times outside the original time range. Default is FALSE which implies that corresponding locations will be NA. If TRUE, the method specified in the argument method will be used also for the extrapolation.

return.remapinfo

a logical value specifying whether or not to return information on the remapping (nearest-neighbour-before indices and weights). Default is FALSE.

verbose

a logical value specifying whether to produce warnings, in particular when the new time axis reaches outside the original time axis. Default is TRUE.

Value

Lat

a numeric vector of length M or a numeric NxL matrix with the latitudes of the trajectory/trajectories at the times specified in newtime.

Lon

a numeric vector of length M or a numeric NxL matrix with the longitudes of the trajectory/trajectories at the times specified in newtime.

If return.remapinfo=TRUE, an additional list element remapinfo is returned, with the following sub-elements:

weights.left.ind

an integer vector of length M with the indices of the original points directly before the corresponding new points.

weights.left

an numeric vector of length M with the weights given to the points provided in weights.left.ind; the respective subsequent points were given the weights (1-weights.left).

Note

This function is used in the R-package SIDFEx to remap ice drift forecast trajectories.

Author(s)

Helge Goessling

Examples

sl.trajectory.remaptime(oldtime = 1:4, oldlat = 2:5, oldlon = seq(0,15,5), newtime = seq(2,5,pi/10), extrapolate = TRUE)
# Should return warnings related to the extrapolation and the following output:
# $Lat
#  [1] 3.000000 3.316975 3.631464 3.943230 4.259835 4.575002 4.886745 5.194824 5.499004 5.799052
#
# $Lon
#  [1]  5.000000  6.569664  8.140331  9.712088 11.281895 12.852290 14.424061 15.997287 17.572041 19.148394

FESOM/spheRlab documentation built on April 6, 2024, 6:52 p.m.