# NOT RUN {
# }
# NOT RUN {
# RunTimeProfile example using residences, nonresidences and sensor events
# Load crocodile data and convert to a VTrack archive format
data(crocs)
Vcrocs <- ReadInputData(infile=crocs,
iHoursToAdd=10,
dateformat = NULL,
sVemcoFormat='1.0')
# Load receiver data and generate the circuitous distance matrix
data(PointsCircuitous_crocs)
CircuitousDM <- GenerateCircuitousDistance(PointsCircuitous_crocs)
# Extract depth data for transmitter #139
T139 <- ExtractData(Vcrocs,sQueryTransmitterList = c("139"))
T139_R <- ExtractUniqueValues(T139,5)
# Extract residence and non residence events
T139Res<- RunResidenceExtraction(T139,
"RECEIVERID",
2,
43200,
sDistanceMatrix=CircuitousDM)
# The residences event table
T139resid <- T139Res$residences
# The nonresidences event table
T139nonresid <- T139Res$nonresidences
# Generate plot dimentions
par(mfrow=c(2,2),las=1,bty="l")
## Plot a
# RESIDENCES: duration/day
Vres_D <- RunTimeProfile(T139resid,"STARTTIME","day")
day_res <- tapply(Vres_D$TIMEMAX,Vres_D$DATETIME,sum)[1:25]/(60*60)
numnames <- as.Date(as.character(names(day_res)))
plot(as.vector(day_res)~numnames,pch=16,
xlab="Day",ylab="Duration (h)",main="",ylim=c(0,23))
## Plot b
# MOVEMENTS: distance/month
Vmove_M <- RunTimeProfile(T139nonresid,"STARTTIME","month")
mon_mov <- tapply(Vmove_M$DISTANCE,Vmove_M$DATETIME,mean)/1000
numnames <- as.numeric(as.character(names(mon_mov)))
movdata <- rep(0,12)
movdata[numnames] <- as.vector(mon_mov)
names(movdata)<-as.character(1:12)
plot(as.vector(movdata)[9:12]~ names(movdata)[9:12],pch=16,xaxt="n",
xlab="Month",ylab="Min distance (km)",main="")
axis(side=1,las=1, at=seq(9,12),labels=month.name[9:12])
## Plot c
# DEPTH EVENTS: frequency/diel cycle
# Extract increasing depth sensor events for transmitter 139
T139dives <- RunSensorEventExtraction(T139,
"INCREASE",
"RECEIVERID",
"m",
0.5,
(1*60*60),
(60*60),
0.5)
# The sensor logtable
T139divelog <- T139dives$logtable
# The sensor event file
T139diveevent <- T139dives$event
# Remove timeout events
T139diveevent<-subset(T139diveevent,T139diveevent$ENDREASON=="return")
Vdiv_C <- RunTimeProfile(T139diveevent,"STARTTIME","circadian")
cir_div <- tapply(Vdiv_C$FREQ,Vdiv_C$DATETIME,mean)
numnames <- as.numeric(as.character(names(cir_div)))
divdata <- rep(0,24)
divdata[numnames+1] <- as.vector(cir_div)
names(divdata)<-as.character(0:23)
plot(as.vector(divdata)~ names(divdata),pch=16,
xlab="24 hr cycle",ylab="Number of depth events",main="")
# }
Run the code above in your browser using DataLab