detect_transmissions: Simulate detection of transmitter signals in a receiver...

View source: R/sim-detect_transmissions.r

detect_transmissionsR Documentation

Simulate detection of transmitter signals in a receiver network

Description

Simulates detection of transmitter signals in a receiver network based on detection range curve (detection probability as a function of distance), location of transmitter, and location of receivers.

Usage

detect_transmissions(trnsLoc = NA, recLoc = NA, detRngFun = NA,
  EPSG = 3175, sp_out = TRUE, show_progress = TRUE)

Arguments

trnsLoc

A three-column data frame with locations (numeric columns named 'x' and 'y') and timestamps (numeric or POSIXct column named 'et') where signals were transmitted.

recLoc

A two-column data frame with receiver locations (numeric columns named 'x' and 'y')

detRngFun

A function that defines detection range curve; must accept a numeric vector of distances and return a numeric vector of detection probabilities at each distance.

EPSG

Numeric EPSG code of the coordinate system used for simulations. Default is 3175, a projected coordinate system for the North American Great Lakes Basin and St. Lawrence River system. http://spatialreference.org/ref/epsg/nad83-great-lakes-and-st-lawrence-albers/

sp_out

Logical. If TRUE (default) then output is a SpatialPointsDataFrame object. If FALSE, then output is a data.frame.

show_progress

Logical. Progress bar and status messages will be shown if TRUE (default) and not shown if FALSE.

Details

Distances between each signal transmission location and receiver are calculated using pythagorean theorem in CRS specified by EPSG. The probability of detecting each signal on each receiver is determined from the detection range curve. Detection of each signal on each receiver is determined stochastically by draws from a Bernoulli distribution with probability p (detection prob).

This function was written to be used along with transmit_along_path.

Value

A SpatialPointsDataFrame comprised of (1) a spatial component with the coordinates of receivers that recorded each detection and (2) a data frame component with the following columns:

trns_id

Unique signal transmission ID

recv_id

Unique receiver ID

recv_x

Receiver x coordinate

recv_y

Receiver y coordinate

trns_x

Transmitter x coordinate at time of transmission

trns_y

Transmitter y coordinate at time of transmission

etime

Elapsed time

Only the data frame component is returned when sp_out = FALSE.

Author(s)

C. Holbrook (cholbrook@usgs.gov)

See Also

transmit_along_path to simulate transmissions along a path (i.e., create trnsLoc).

Examples


library(sp) #for plot methods for spatial objects

#make a simple path in polygon
mypath <- crw_in_polygon(data.frame(x = c(0, 0, 1000, 1000), 
  y = c(0, 1000, 1000, 0)), stepLen=100, nsteps=50)
plot(mypath,type='l',xlim=c(0,1000),ylim=c(0,1000)) #view path

#add receivers
recs <- expand.grid(c(250,750),c(250,750))
names(recs) <- c("x","y") #needed by detect_transmissions
points(recs, pch=15, col="blue")

#simulate tag transmissions
mytrns <- transmit_along_path(mypath,vel=2.0,delayRng=c(60,180),burstDur=5.0)
points(mytrns,pch=21) #add to plot

#Define detection range function (to pass as detRngFun) 
# that returns detection probability for given distance
# assume logistic form of detection range curve where 
#   dm = distance in meters
#   b = intercept and slope
pdrf <- function(dm, b=c(0.5, -1/120)){
  p <- 1/(1+exp(-(b[1]+b[2]*dm)))
  return(p)
}
pdrf(c(100,200,300,400,500)) #view detection probs. at some distances

#simulate detection
mydtc <- detect_transmissions(trnsLoc=mytrns, recLoc=recs, detRngFun=pdrf)
#view transmissions that were detected
points(trns_y~trns_x, data=mydtc,pch=21, bg="red")

#link transmitter and receiver locations for each detection
with(mydtc@data, segments(x0 = trns_x, y0 = trns_y, 
                          x1 = recv_x, y1 = recv_y, 
                          col = "red")) 


jsta/glatos documentation built on July 11, 2022, 7:01 a.m.