Skip to content

Commit

Permalink
version 1.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Clement Calenge authored and gaborcsardi committed Feb 13, 2009
1 parent a3101fe commit 447c15c
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 32 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,6 +1,6 @@
Package: adehabitat
Version: 1.8.1
Date: 2009/02/11
Version: 1.8.2
Date: 2009/02/13
Title: Analysis of habitat selection by animals
Author: Clement Calenge, contributions from Mathieu Basille, Stephane Dray and Scott Fortmann-Roe
Maintainer: Clement Calenge <clement.calenge@oncfs.gouv.fr>
Expand All @@ -9,4 +9,4 @@ Suggests: gpclib, sp, spatstat, MASS, tkrplot, shapefiles, CircStats
Description: A collection of tools for the analysis of habitat selection by animals
License: GPL (>= 2)
URL: https://www.faunalia.it/animove/trac/
Packaged: Wed Feb 11 16:52:24 2009; calenge
Packaged: Fri Feb 13 18:24:20 2009; calenge
4 changes: 3 additions & 1 deletion R/kernelbb.r
@@ -1,5 +1,6 @@
"kernelbb" <- function(tr, sig1, sig2, grid = 40,
same4all=FALSE, byburst=FALSE, extent = 0.5)
same4all=FALSE, byburst=FALSE, extent = 0.5,
nalpha=25)
{
## verifications
x <- ltraj2traj(tr)
Expand Down Expand Up @@ -121,6 +122,7 @@
as.double(xyg$y), as.integer(ncol(grid)),as.integer(nrow(grid)),
as.integer(nrow(df)), as.double(sig12), as.double (sig22),
as.double(df$x), as.double(df$y), as.double(date),
as.integer(1000000), as.integer(nalpha),
PACKAGE="adehabitat")
UD <- matrix(toto[[1]], nrow = nrow(grid), byrow = TRUE)
UD <- getascattr(grid, UD)
Expand Down
4 changes: 2 additions & 2 deletions man/adehabitat-package.Rd
Expand Up @@ -19,8 +19,8 @@
\tabular{ll}{
Package: \tab adehabitat\cr
Type: \tab Package\cr
Version: \tab 1.8.1\cr
Date: \tab 2009-02-11\cr
Version: \tab 1.8.2\cr
Date: \tab 2009-02-13\cr
License: \tab GPL version 2 or newer\cr
}

Expand Down
5 changes: 4 additions & 1 deletion man/kernelbb.Rd
Expand Up @@ -13,7 +13,7 @@
}
\usage{
kernelbb(tr, sig1, sig2, grid = 40, same4all = FALSE, byburst = FALSE,
extent = 0.5)
extent = 0.5, nalpha = 25)

liker(tr, rangesig1, sig2, le = 1000,
byburst = FALSE, plotit = TRUE)
Expand Down Expand Up @@ -42,6 +42,9 @@ liker(tr, rangesig1, sig2, le = 1000,
\item{extent}{a value indicating the extent of the grid used for the
estimation (the extent of the grid on the abscissa is equal to
\code{(min(xy[,1]) + extent * diff(range(xy[,1])))}).}
\item{nalpha}{a parameter used internally to compute the integral
of the Brownian bridge. The integral is computed by cutting each
step built by two relocations into \code{nalpha} sub-intervals. }
\item{rangesig1}{the range of possible values of sig1 within which
the likelihood should be maximized.}
\item{le}{The number of values of sig1 tested within the specified
Expand Down
58 changes: 33 additions & 25 deletions src/tests.c
Expand Up @@ -180,7 +180,8 @@ void integrno(double *XG, double *X1, double *X2,
double *sig2, double *alpha, double *res);
void kernelbb(double *grille, double *xgri, double *ygri, int *ncolgri,
int *nliggri, int *nloc, double *sig1, double *sig2,
double *xlo, double *ylo, double *Tr);
double *xlo, double *ylo, double *Tr, int *controlbox,
int *nalpha);
void ligpoly(double *x, double *y, double r, double *xp, double *yp);
void buflig(double **x, double r, double **carte, double *xg, double *yg);
void bufligr(double *xr, double *rr, double *carter,
Expand Down Expand Up @@ -6048,7 +6049,7 @@ double maxdt(double *T)
/* keeps all the steps for which at least one relocation is
available in the box */
int consdanslabox(double *Xg, double **xy,
int nl, int *indcons, double maxvh)
int nl, int *indcons, double maxvh, int controlbox)
{
int i,k,cons;
double tmp1, tmp2, a, b;
Expand All @@ -6059,19 +6060,19 @@ int consdanslabox(double *Xg, double **xy,

cons = 0;

if (xy[i][1] > (Xg[1] - (4 * maxvh)) ) {
if (xy[i][1] < (Xg[1] + (4 * maxvh)) ) {
if (xy[i][2] > (Xg[2] - (4 * maxvh)) ) {
if (xy[i][2] < (Xg[2] + (4 * maxvh)) ) {
if (xy[i][1] > (Xg[1] - (controlbox * maxvh)) ) {
if (xy[i][1] < (Xg[1] + (controlbox * maxvh)) ) {
if (xy[i][2] > (Xg[2] - (controlbox * maxvh)) ) {
if (xy[i][2] < (Xg[2] + (controlbox * maxvh)) ) {
cons = 1;
}
}
}
}
if (xy[i+1][1] > (Xg[1] - (4 * maxvh)) ) {
if (xy[i+1][1] < (Xg[1] + (4 * maxvh)) ) {
if (xy[i+1][2] > (Xg[2] - (4 * maxvh)) ) {
if (xy[i+1][2] < (Xg[2] + (4 * maxvh)) ) {
if (xy[i+1][1] > (Xg[1] - (controlbox * maxvh)) ) {
if (xy[i+1][1] < (Xg[1] + (controlbox * maxvh)) ) {
if (xy[i+1][2] > (Xg[2] - (controlbox * maxvh)) ) {
if (xy[i+1][2] < (Xg[2] + (controlbox * maxvh)) ) {
cons = 1;
}
}
Expand All @@ -6081,17 +6082,17 @@ int consdanslabox(double *Xg, double **xy,
if (cons == 0) {
a = (xy[i+1][2] - xy[i][2]) / (xy[i+1][1] - xy[i][1]);
b = xy[i+1][2] - a * xy[i+1][1];
tmp1 = a * (Xg[1] - (4 * maxvh)) + b;
tmp2 = a * (Xg[1] + (4 * maxvh)) + b;
tmp1 = a * (Xg[1] - (controlbox * maxvh)) + b;
tmp2 = a * (Xg[1] + (controlbox * maxvh)) + b;

if (tmp1 <= (Xg[2] + (4 * maxvh))) {
if (tmp1 >= (Xg[2] - (4 * maxvh))) {
if (tmp1 <= (Xg[2] + (controlbox * maxvh))) {
if (tmp1 >= (Xg[2] - (controlbox * maxvh))) {
cons = 1;
}
}

if (tmp2 <= (Xg[2] + (4 * maxvh))) {
if (tmp2 >= (Xg[2] - (4 * maxvh))) {
if (tmp2 <= (Xg[2] + (controlbox * maxvh))) {
if (tmp2 >= (Xg[2] - (controlbox * maxvh))) {
cons = 1;
}
}
Expand Down Expand Up @@ -6199,10 +6200,12 @@ void udbbnoeud(double *XG, double **XY, double *T, double *sig1,
}



/* Main Function */
void kernelbb(double *grille, double *xgri, double *ygri, int *ncolgri,
int *nliggri, int *nloc, double *sig1, double *sig2,
double *xlo, double *ylo, double *Tr)
double *xlo, double *ylo, double *Tr, int *controlbox,
int *nalpha)
{
/* Declaration */
int i, j, k, ncg, nlg, nlo, *indcons, ncons;
Expand All @@ -6220,11 +6223,10 @@ void kernelbb(double *grille, double *xgri, double *ygri, int *ncolgri,
vecalloc(&T, nlo);
vecalloc(&yg, ncg);
vecalloc(&Xgr, 2);
vecalloc(&alpha, 25);
vecalloc(&alpha, *nalpha);
vecintalloc(&indcons, nlo);

/* R to C */

/* R to C */
for (i=1; i<=nlo; i++) {
XY[i][1] = xlo[i-1];
XY[i][2] = ylo[i-1];
Expand All @@ -6241,8 +6243,8 @@ void kernelbb(double *grille, double *xgri, double *ygri, int *ncolgri,

/* Build the vector alpha */
alpha[1] = 0;
for (i = 2; i <= 25; i++) {
alpha[i] = ((double) i) / ((double) 25);
for (i = 2; i <= *nalpha; i++) {
alpha[i] = ((double) i) / ((double) *nalpha);
}

/* Maximum dt and sigma for the normal distribution*/
Expand All @@ -6257,20 +6259,26 @@ void kernelbb(double *grille, double *xgri, double *ygri, int *ncolgri,
for (j=1; j<=ncg; j++) {
Xgr[1] = xg[i];
Xgr[2] = yg[j];
ncons = consdanslabox(Xgr, XY, nlo, indcons, maxvh);
/*
ncons = consdanslabox(Xgr, XY, nlo, indcons, maxvh, *controlbox);
*/
ncons = nlo-1;
for (k = 1; k < nlo; k++)
indcons[k]=k;
udbbnoeud(Xgr, XY, T, sig1, sig2, alpha, &tmp, ncons, indcons);
gri[i][j] = tmp;
vol+=tmp;
}
}

/* Standardization of the volume */

for (i=1; i<=nlg; i++) {
for (j=1; j<=ncg; j++) {
gri[i][j] = gri[i][j] / (vol * pow(res,2));
gri[i][j] = gri[i][j] / (vol * pow(res,2));
}
}

/* C to R */
k = 0;
for (i=1; i<=nlg; i++) {
Expand Down

0 comments on commit 447c15c

Please sign in to comment.