| califlopp | R Documentation |
Calculation of the flow of particles between polygons by two integration methods: integration by a cubature method and integration on a grid of points.
califlopp(file, dispf=c(1,2), param=NULL, resfile = NULL)
file |
Pathname of the polygons-file. See details. |
dispf |
The required dispersion functions. Vector of integers or vector of R functions. The maximum length of this vector is 5.
|
param |
Optional list of parameters. Valid components are
|
resfile |
Optional pathname of a result-file. When set,
the results are written on it. This file can be read
by using function
|
The polygons-file
The coordinates of the polygons should be provided in an ASCII file,
denoted here "polygons-file". The unit is the meter. The vertices should
be ordered clockwise. The polygons can be closed
or not, but without holes. The first line contains the number of polygons.
The following lines depend of the input
parameter:
input=1Two lines per polygon: on the first one, an identifier (a positive integer), followed by the x-coordinates, on the second one, the same identifier followed by the y-coordinates. The function export.listpoly generates such a file from R structures
input=2Three lines per polygon: on the first one, an identifier (a positive integer), followed by a name for the polygon and by the number of its vertices, on the second one, the x-coordinates, and on the third one, the y-coordinates.
The individual dispersion functions
The individual dispersion functions can either be compiled or R functions.
Five compiled dispersal functions are
provided (see argument dispf). To replace them by yours,
you have to download the source of RCALI,
modify and compile it.
Suppose that you have download the tar-archive
in the directory MyDir.
The steps to customize the dispersion functions are:
1/ Replace one or several functions in
MyDir/RCALI/src/functions.cc by yours:
The dispersion function has one argument,
the current point, p, of class Point.
You can use p.getX()
and p.getY() to get the coordinates of the current point
(in meters*SCALE, where SCALE is the rescaling
parameter defined in the file src/calicinfig.h),
p.dist0(), the distance of p
from the origin (in meters*SCALE)
and p.angle0(), the angle (in degrees, in [-\pi, +\pi]) between the line (0,p)
and the horizontal line.
2/ Create a directory MyDir/RCALI/libs,
place you in MyDir/RCALI/src and type in:
R CMD SHLIB -o ../libs/RCALI.so *.cc
to create the compiled shared library.
3/ To use in a R-session:
source("MyDir/RCALI/R/sourceDir.R")
sourceDir("MyDir/RCALI/R")
dyn.load("MyDir/RCALI/libs/RCALI.so")
The help-files are viewable by opening in a browser
MyDir/RCALI/inst/doc/html/00Index.html
You can also build the tar.gz file again, after modifications,
and install it as a library
by using the standard R commands R CMD build and
R CMD INSTALL --html.
Two R dispersal functions are provided, fpollen and
fseed, the functions used in Genesys.
You can define your own R dispersal function:
it should have one vector
argument, the localization of the current point, p.
The first element of this vector is the distance of p from the origin
(in meters) and the second one is the angle (in degrees, in [-\pi, +\pi]) between the line (0,p)
and the horizontal line (i.e, stating x and y are the coordinates
of p, the angle is
atan2(y,x)*\frac{180}{\pi})
The parameters
The argument param is a list which valid components are:
inputformat of the polygons-file. 1 or 2 (see above). Default 2
outputoutput required on the screen: 0 nothing, 1: all results, 2: progression numbers, 3: the integrated flows and their means per squared meter. Default 1
verboseTRUE, if output is required about polygons convexity and landscape translation. Default FALSE
warn.polyTRUE, if output is required about polygons simplification. Default FALSE
warn.convTRUE, if output is required when cubature convergence is not reached. Default TRUE
delimseparator character between values in the polygons-file. Default: tabulate
send.and.receiveTRUE, if results are required from sending polygons to target polygons and from target polygons to sending polygons (case of anisotropic functions). Default FALSE
polyrequired pairs of polygons. List of vectors of length 2, or two-columns matrix. If only one pair is required, it may be a vector of length 2. Default: all pairs of polygons.
method string equal to cub for cubature method, grid for the grid
method. Default: cub
dz integer vector, whose length is greater or equal to the number of
required dispersion functions. dz[i] is the distance in meters
beyond which the ist dispersion function is considered as
nul. Default in a standard configuration: 0,21,0,1000,0
for functions number 1 to 5, respectively.
dp integer vector, whose length is greater or equal
to the number of
required dispersion functions. dp[i] is the distance in meters
beyond which the ist dispersion function is calculated between
centroids only. Default in a standard configuration: 100, 0, 0,
500, 0
for functions number 1 to 5, respectively.
In addition, when method is cub:
maxptsmaximal number of evaluation points required for each function. Vector of length equal to the number of required functions. Default in a standard configuration: 100000
relerrelative error required for each function. Vector of length equal to the number of required functions. Should be positive when method is cubature. Default in a standard configuration: 1.0e-3
abserabsolute error required for each function. Vector of length equal to the number of required functions. Should be positive when method is cubature. Default in a standard configuration: 1.0e-3
tz integer vector, whose length is greater
or equal to the number of
required dispersion functions. Mode of triangulation for the
cubature method.
tz[i] should be 1, if, for the ist dispersion
function,
triangulation from (0,0) has to be done
when (0,0) is included in the integration area and, 0 if not.
1 is recommended when the dispersion function is very "sharp"
at the origin. Default in a standard configuration: 0,1,0,0,0
for functions number 1 to 5, respectively.
When method is grid:
seedseed of the random generator.
stepstep of the grid on the x-axis and on the y-axis in meter. Vector of length 2.
nrmaximal number of replications or grids.
The result-file
When the argument resfile is set, a file is created.
On this file, the values are separated by tabulates.
Its contains, when the method is cub,
"npoly:", "input-file:", "nfunc:", "method:", each of these identifiers followed by the actual values.
the identifiers of both polygons; the integrated flow divided by the area of the second polygon, for each dispersal function; the areas of both polygons; then, for each dispersal function, the integrated flow, the lower and upper bounds of the confidence interval, the absolute error, and the number of evaluations.
Its contains, when the method is grid,
"npoly:", "input-file:", "nfunc:", "method:", "stepx:", "stepy:", each of these identifiers followed by the actual values.
the identifiers of both polygons; the integrated flow divided by the area of the second polygon, for each dispersal function; the areas of both polygons; then, for each dispersal function, the integrated flow, and the standard deviation.
This file can be read in a R-session by using the function
getRes or read.table, with option
skip=1.
Nothing. To store the results, set the argument resfile,
then use the function
getRes or read.table, with option
skip=1
This function creates a temporary file to store the
parameters, usually in the directory tmp of the user. This file
is destroyed at the end of execution.
A. Bouvier
- The CaliFloPP software: http://genome.jouy.inra.fr/logiciels/califlopp/
- Main reference paper: A. Bouvier, K. Kieu, K. Adamczyk, and H. Monod. Computation of
integrated flow of particles between polygons. Environmental Modelling
& Software, 24:843–849, 2009.
- N. Colbach, and all.Genesys: a model of the influence of cropping
system on gene escape from herbicide tolerant rapeseed crops to rape
volunteers. Agriculture, Ecosystems and Environnement, 83:235–270, 2001.
getRes
# Grid method with compiled constant and seed dispersion functions:
param <- list(method="grid", grid=list(step=c(50,50)))
## Not run: califlopp("MyPolygonsFile",dispf=c(3,1), param=param)
# Cubature method with a R dispersion function:
param <- list( output=1, input=2, dz=0, dp=100, tz=0)
## Not run: califlopp("MyPolygonsFile", dispf=fpollen, param=param)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.