Skip to content

Simulation Function for Animal Tracks#7

Open
MIKA19325 wants to merge 13 commits into
citoverse:mainfrom
MIKA19325:Simulation
Open

Simulation Function for Animal Tracks#7
MIKA19325 wants to merge 13 commits into
citoverse:mainfrom
MIKA19325:Simulation

Conversation

@MIKA19325
Copy link
Copy Markdown
Collaborator

Implemented function to simulate animal tracks from multimodal inputs (numeric and spacial imagery data) together with a working example

@MaximilianPi MaximilianPi self-requested a review April 28, 2026 12:59
@MaximilianPi
Copy link
Copy Markdown
Contributor

  • unit tests?

Comment thread R/simulation.R Outdated
} else {numericRasters <- list()}

# Kernel extraction helper function:
extractKernelValues_vec <- function(raster, xs, ys, kernelDim, kernelFun) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

als pkg function definieren

Comment thread R/simulation.R Outdated


# Kernel value calculation helper function:
computeImageValues <- function(x, y) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • als pkg function definieren
  • add missing arguments (some data is accessed from the environment, other data (x, y) are passed as arguments

Comment thread R/simulation.R Outdated
n_off <- nrow(offsets)

all_x <- rep(xs, each = n_off) + rep(offsets$dx, times = n_pts) * res_x
all_y <- rep(ys, each = n_off) + rep(offsets$dy, times = n_pts) * res_y
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mit diesen offsets könntest du theoretisch wieder über deine boundaries gehen oder? Müsstest du hier nicht deshalb wie in line 223/224 darauf checken/korrigieren?

Comment thread R/simulation.R
multinom <- stats::rmultinom(1, size = 1, prob = p)
chosenStep <- which(multinom == 1)

simData$x_[i + 1] <- x[chosenStep]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

solltest du hier nicht die xToro coordinates nehmen?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ich benutze den Toro wrap nur um keine NAs in den Umweltdaten zu erzeugen. Die simulierten Tracks sollen nicht gewrapped werden um korrekte step length und turning angels zu behalten, damit die daraus abgeleiteten movement variable distributions stimmen.

Comment thread R/simulation.R Outdated
if (xminAll >= xmaxAll || yminAll >= ymaxAll) stop("The provided layers must have a spatial overlap")

# Adding imageLayer if present: (cutting to size and scaling)
if (!is.null(imageLayers)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast identisch mit dem numericLayer Block? Helper function deklarieren und dann in einen Block zusammensetzen

Comment thread inst/examples/simulation-example.R Outdated
ext = terra::ext(-200, 200, -200, 200)
)

terra::values(dummyImage) <- runif(terra::ncell(dummyImage))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stats::runif

Current versions of the simulation functions and data preparation functions together with unit tests and examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants