Learn R Programming

SitesInterest (version 1.0)

Alt_Alg_mini: Calculates the residence times for circles taken from one trajectory, but applied to another

Description

The circles found from applying Alt_Alg to one trajectory are used to find the residence times of another trajectory passing through these circles.

Usage

Alt_Alg_mini(Circles_name, t_centers, X_centers, Y_centers, Path_name, t, X, Y, R, 
s = 10, m = 500, save = 'n')

Arguments

Circles_name

name of the trajectory used to find the circles

t_centers

array of times when the positions were recorded

X_centers

array of the x-coordinates of the circles' centres

Y_centers

array of the y-coordinates of the circles' centres

Path_name

name of the trajectory that the residence times are found from

t

array of the times that the positions are recorded at

X

array of the x-coordinates describing the trajectory

Y

array of the y-coordinates describing the trajectory

R

radius value to use

s

number of time steps between checks for entrances and exits

m

estimate of the maximum number of crossings across all circles

save

if 'y', save the files

Details

This functions works in a similar way to Alt_Alg, but the circles are found from one trajectory and are applied to another. The results are stored in a csv file `Circles_name'_multi_`Path_name'_UD_alt_R`R'.csv and the crossing times are stored in `Circles_name'_multi_`Path_name'_M_alt_R`R'.csv

References

Munden, R., Borger , L., Wilson, R.P., Redcliffe, J., Loison, A., Garel, M. and Potts, J.P. in review. Making sense of ultra-high-resolution movement data: an algorithm for inferring sites of interest.

See Also

See also Alt_Alg for how to apply the algorithm to continuous data. Alt_Alg_discont perform Alt_Alg_mini on all trjectories, then combining combines the results from each application of Alt_Alg_mini.

Examples

Run this code
# NOT RUN {
##Find the current working directory
wd = getwd()
##Set the working directory as the temporary one
setwd(tempdir())
##Load the data
data(OU_14)
t=unlist(OU_14["t"])
X=unlist(OU_14["X"])
Y=unlist(OU_14["Y"])

##Number of path sections
n=5
##Number of recorded locations
N = length(t)

##A list of arrays of the time recoding for the 3 of the path segments
t_all = list(t[seq(1,floor(N/n))], t[seq(floor(N/n)*2,floor(N/n)*3)], 
t[seq(floor(N/n)*4,floor(N/n)*5)])

##A list of arrays of the x-coordinates for the 3 of the path segments
X_all = list(X[seq(1,floor(N/n))], X[seq(floor(N/n)*2,floor(N/n)*3)], 
X[seq(floor(N/n)*4,floor(N/n)*5)])

##A list of arrays of the y-coordinates for the 3 of the path segments
Y_all = list(Y[seq(1,floor(N/n))], Y[seq(floor(N/n)*2,floor(N/n)*3)], 
Y[seq(floor(N/n)*4,floor(N/n)*5)])

##Calculates the residence time for one particular path segment
Alt_Alg("OU_14.1",unlist(t_all[1]),unlist(X_all[1]),unlist(Y_all[1]),0.3,first='y',save='y')

##Load the data of the circles found from Alt_Alg
df = read.csv(paste("OU_14.1","_UD_alt_R",0.3,".csv",sep=''))
t_centers = unlist(df[1])
X_centers = unlist(df[2])
Y_centers = unlist(df[3])

##Calculates the residence time from path segment 3, using circles from path segment 1
Alt_Alg_mini("OU14.1", t_centers, X_centers, Y_centers, "OU_14.3", unlist(t_all[2]), 
unlist(X_all[2]), unlist(Y_all[2]), 0.3,save='y')

##Reset the original working directory
setwd(wd)
# }

Run the code above in your browser using DataLab