The issue came up when getInpSync() failed for my dataset. Debugging found the issue to be in buildToaListGross().
The failure is coming as a generic "subscript out of bounds" error on line:
toa_i_mat[, as.numeric(colnames(toa_i))] <- toa_i
The problem is being created a few steps back:
toa_i <- t(plyr::daply(.data = other_detections, .variables = "hydro_idx", .fun = function(k){
k <- data.table::data.table(k)
return(as.numeric(k[self_detections, roll = "nearest", on = .(epo_roll)]$epofrac))
}))
If the receiver's synch tag has been detected on >1 other receiver, this produces a matrix with nrow = nrow(self_detections) and ncol = number of other hydros it's heard on. However, if it's only heard on one other hydro, it produces a one-row matrix with ncol = number of rows of self_detections. When it then tries to put toa_i into toa_i_mat, the dimensional mismatch hits.
The issue came up when getInpSync() failed for my dataset. Debugging found the issue to be in buildToaListGross().
The failure is coming as a generic "subscript out of bounds" error on line: toa_i_mat[, as.numeric(colnames(toa_i))] <- toa_i
The problem is being created a few steps back: toa_i <- t(plyr::daply(.data = other_detections, .variables = "hydro_idx", .fun = function(k){ k <- data.table::data.table(k) return(as.numeric(k[self_detections, roll = "nearest", on = .(epo_roll)]$epofrac)) }))
If the receiver's synch tag has been detected on >1 other receiver, this produces a matrix with nrow = nrow(self_detections) and ncol = number of other hydros it's heard on. However, if it's only heard on one other hydro, it produces a one-row matrix with ncol = number of rows of self_detections. When it then tries to put toa_i into toa_i_mat, the dimensional mismatch hits.