trackit_3D: Trackit 3D

Description Usage Arguments Details Value Examples

View source: R/trackit_3D.R

Description

Function to track particles through a 3D ROMS-field.

Usage

1
2
trackit_3D(pts, romsobject, w_sink = 100, time = 50, romsparams = NULL,
  loop_trackit = FALSE, time_steps_in_s = 1800)

Arguments

pts

input points

w_sink

sinking rate m/days

time

total number of days to run the model

loop_trackit

Default is FALSE, automatically turns TRUE when called from loopit_2D3D

kdtree

kd tree

Details

Due to the limitation of RAM available, time is restricted depending on the number of particles (too long runs might give an error because the generated vector is too large)

Value

list(ptrack = ptrack, pnow = pnow, plast = plast, stopindex = stopindex, indices = indices, indices_2D = indices_2D)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
data(surface_chl)
data(toyROMS)
pts <- create_points_pattern(surface_chl, multi=100)
track <- trackit_3D(pts = pts, romsobject = toyROMS)

## checking the results
plot(pts)
points(track$pnow, col = "red")

# library(rgl)
# plot3d(pts, zlim = c(-1500,1))
# plot3d(track$pnow, col = "red", add = TRUE)

## better:
library(rasterVis)
library(rgdal)

ra <- raster(nrow = 50, ncol = 50, ext = extent(surface_chl))
r_roms <- rasterize(x = cbind(as.vector(toyROMS$lon_u), as.vector(toyROMS$lat_u)), y = ra, field = as.vector(-toyROMS$h))
pr <- projectRaster(r_roms, crs = "+proj=laea +lon_0=137 +lat_0=-66")  #get the right projection (through the centre)

plot3D(pr, adjust = FALSE, zfac = 50)                    # plot bathymetry with 50x exaggerated depth
points <- matrix(NA, ncol=3, nrow=dim(track$ptrack)[1])  # get Tracking-points
for(i in seq_len(dim(track$ptrack)[1])){
  points[i,] <- track$ptrack[i,,track$stopindex[i]] 
}
pointsxy <- project(as.matrix(points[,1:2]), projection(pr))  #projection on Tracking-points
points3d(pointsxy[,1], pointsxy[,2], points[,3]*50)

ptsxy <- project(as.matrix(pts[,1:2]), projection(pr))  #projection on Tracking-points
points3d(ptsxy[,1], ptsxy[,2], pts[,3]*50, col = "red")

janjansen86/ptrackr documentation built on May 18, 2019, 2:38 p.m.