This function prepares the arena, i.e. the flow field and the polygon structure, for use by the other functions in package BiomassTracking.

prepare.arena(file_U = NULL, file_V = NULL, file_S = NULL,
  n = dim(file_U)[2], m = dim(file_U)[1], na.string = "-9999",
  eddy = FALSE, smooth = FALSE, noise_sd = 0)

Arguments

file_U

Describes the U data, see details.

file_V

Describes the V data, see details.

file_S

Describes the S data, see details.

n

Zonal dimension of the arena, if needed.

m

Meridional dimension of the arena, if needed.

na.string

The character string denoting NA in the input files.

eddy

If TRUE, an eddy is added in the middle of the arena.

smooth

If TRUE, the flow field is smoothed with a 3x3 moving average.

noise_sd

The standard deviation of Gaussian noise added to the flow field.

Value

An object of class arena, describing the arena in which the function is too be used. It is a list containing elements lat, lon, U, V and S (in that order).

lon, lat

Vectors storing the latitude and longitude values of the grid points used.

U, V

Matrices with the corresponding flow velocities in west-east and south-north direction.

S

A matrix in which each grid points has an integer number, either giving the polygon it belongs to (if > 0) or stating that this grid point lies on land (if == 0).

Details

The data descriptors file\_U, file\_V and file\_S can come in a number of different formats. If they are filenames, the respective data is loaded from these files. In case the data is already loaded, they can also be data.frames. If they are NULL, a default construction is invoked, where the values n and m are needed and the flow is straight in west-east direction. They can also be matrices giving the respective data directly.

In the usual case, the data is loaded from files and then prepared to be used. The matrices U and V are interpolated in every NA position that is not land, while the velocities on land are set to 0. The component perpendicular to land of the sea velocities directly at the land-sea boundary is set to 0 if it points towards land, so that particles wouldn't cross the boundary if an ideal particle tracking algorithm was used.

The data is then rescaled, as the files are supposed to be in m/s format while the particle tracking algorithms act on a longitude/latitude grid. Therefore, the values of 'U' and 'V' are rescaled to degree lon/day and degree lat/day, respectively. Note that this rescaling includes a relative increase of the southern U-velocities compared to the northern U-velocities, because the longitudinal distances are smaller in the South. Also note that the whole algorithm is meant to work in the southern hemisphere and has to be adapted to the Northern Hemisphere if that is wanted.

Warning

This function is written only for the Southern Hemisphere, but can be adapted easily to the Northern Hemisphere.

References

TODO: my report

Author

Thorsten Lenser

Examples


data(Udata)
data(Vdata)
data(Sdata)
arena = prepare.arena(Udata,Vdata,Sdata)
plot(arena)