Skip to content

Commit

Permalink
Reorganised handling of tolerances.
Browse files Browse the repository at this point in the history
   psp.R
   lengths.psp.Rd
	New argument 'squared'

   lineardisc.R
   spatstat-internal.Rd
	New internal function makeLinnetTolerance

   linnet.R
	reorganised/polished code for computing numerical tolerance threshold.

   chicago.rda
   dendrite.rda
   spiders.rda
   simplenet.rda
	Rebuilt datasets.

   circum.R -> boundingcircle.R [Renamed]
   circumradius.Rd -> boundingcircle.Rd [Renamed]
   spatstat-deprecated.Rd
	'circum*' functions renamed 'bounding*'
	eg boundingradius, boundingcircle
	Old names exist but are deprecated.

   edgeRipley.R
   Kest.R
   linearK.R
   linearpcf.R
   linearKmulti.R
   linearpcfmulti.R
   treebranches.R
	Replaced circum* by bounding*

   updates.Rnw
	updated to cover all the above.

   tests/lppstuff.R
	Added test of countends()

   DESCRIPTION
   NEWS
        Nickname changed to 'Pons Asinorum'
	Updated as version 1.46-1.008
  • Loading branch information
baddstats committed Jul 16, 2016
1 parent e4fc91f commit 5e24bd4
Show file tree
Hide file tree
Showing 28 changed files with 329 additions and 213 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: spatstat
Version: 1.46-1.007
Nickname: Ultracrepidarian
Date: 2016-07-15
Version: 1.46-1.008
Nickname: Pons Asinorum
Date: 2016-07-16
Title: Spatial Point Pattern Analysis, Model-Fitting, Simulation, Tests
Author: Adrian Baddeley <Adrian.Baddeley@curtin.edu.au>,
Rolf Turner <r.turner@auckland.ac.nz>
Expand Down
28 changes: 18 additions & 10 deletions NAMESPACE
Expand Up @@ -456,6 +456,16 @@ export("boundingbox.owin")
export("boundingbox.ppp")
export("boundingbox.solist")
export("bounding.box.xy")
export("boundingcentre")
export("boundingcentre.owin")
export("boundingcentre.ppp")
export("boundingcircle")
export("boundingcircle.owin")
export("boundingcircle.ppp")
export("boundingradius")
export("boundingradius.linnet")
export("boundingradius.owin")
export("boundingradius.ppp")
export("box3")
export("boxx")
export("branchlabelfun")
Expand Down Expand Up @@ -516,12 +526,6 @@ export("chop.tess")
export("choptext")
export("circdensity")
export("circticks")
export("circumcentre")
export("circumcentre.owin")
export("circumcentre.ppp")
export("circumcircle")
export("circumcircle.owin")
export("circumcircle.ppp")
export("circumradius")
export("circumradius.linnet")
export("circumradius.owin")
Expand Down Expand Up @@ -1393,6 +1397,7 @@ export("mad.test")
export("majorminorversion")
export("make.even.breaks")
export("makefvlabel")
export("makeLinnetTolerance")
export("make.parseable")
export("makeunits")
export("mapSparseEntries")
Expand Down Expand Up @@ -2841,6 +2846,13 @@ S3method("boundingbox", "im")
S3method("boundingbox", "owin")
S3method("boundingbox", "ppp")
S3method("boundingbox", "solist")
S3method("boundingcentre", "owin")
S3method("boundingcentre", "ppp")
S3method("boundingcircle", "owin")
S3method("boundingcircle", "ppp")
S3method("boundingradius", "linnet")
S3method("boundingradius", "owin")
S3method("boundingradius", "ppp")
S3method("by", "im")
S3method("by", "ppp")
S3method("cbind", "fv")
Expand All @@ -2852,10 +2864,6 @@ S3method("cdf.test", "mppm")
S3method("cdf.test", "ppm")
S3method("cdf.test", "ppp")
S3method("cdf.test", "slrm")
S3method("circumcentre", "owin")
S3method("circumcentre", "ppp")
S3method("circumcircle", "owin")
S3method("circumcircle", "ppp")
S3method("circumradius", "linnet")
S3method("circumradius", "owin")
S3method("circumradius", "ppp")
Expand Down
16 changes: 11 additions & 5 deletions NEWS
@@ -1,21 +1,21 @@

CHANGES IN spatstat VERSION 1.46-1.007
CHANGES IN spatstat VERSION 1.46-1.008

OVERVIEW

o We thank Mehdi Moradi and Jorge Mateu for contributions.

o Circumcentre and circumcircle.

o Non-Gaussian smoothing kernels.

o Important bug fix in linearK, linearpcf

o Version nickname: 'Ultracrepidarian'
o Bounding circle of a spatial object.

o Version nickname: 'Pons Asinorum'

NEW FUNCTIONS

o circumcircle, circumcentre
o boundingcircle, boundingcentre
Find the smallest circle enclosing a window or point pattern.

SIGNIFICANT USER-VISIBLE CHANGES
Expand All @@ -26,13 +26,19 @@ SIGNIFICANT USER-VISIBLE CHANGES
o rcellnumber
New argument 'mu'.

o lengths.psp
New argument 'squared'.

o density.ppp, Smooth.ppp
Computation accelerated by about 15%
in the case where at='points' and kernel='gaussian'.

o linearK, linearpcf
Accelerated.

o circumradius
This function is now deprecated, in favour of 'boundingradius'

BUG FIXES

o linearK, linearpcf, and relatives:
Expand Down
4 changes: 2 additions & 2 deletions R/Kest.R
@@ -1,7 +1,7 @@
#
# Kest.R Estimation of K function
#
# $Revision: 5.118 $ $Date: 2016/04/01 05:55:30 $
# $Revision: 5.119 $ $Date: 2016/07/16 03:08:23 $
#
#
# -------- functions ----------------------------------------
Expand Down Expand Up @@ -292,7 +292,7 @@ function(X, ..., r=NULL, rmax=NULL, breaks=NULL,
wh <- whist(DIJ, breaks$val, edgewt)
numKiso <- cumsum(wh)
denKiso <- lambda2 * areaW
h <- circumradius(W)
h <- boundingradius(W)
numKiso[r >= h] <- NA
K <- bind.ratfv(K,
data.frame(iso=numKiso),
Expand Down
69 changes: 69 additions & 0 deletions R/boundingcircle.R
@@ -0,0 +1,69 @@
#'
#' boundingcircle.R
#'
#' bounding circle and its centre
#'
#' $Revision: 1.5 $ $Date: 2016/07/16 03:07:02 $
#'

circumradius <- function(x, ...) {
.Deprecated(boundingradius)
UseMethod("boundingradius")
}
circumradius.owin <- function(x, ...) {
.Deprecated(boundingradius.owin)
boundingradius.owin(x, ...)
}
circumradius.ppp <- function(x, ...) {
.Deprecated(boundingradius.ppp)
boundingradius.ppp(x, ...)
}

boundingradius <- function(x, ...) {
UseMethod("boundingradius")
}

boundingcentre <- function(x, ...) {
UseMethod("boundingcentre")
}

boundingcircle <- function(x, ...) {
UseMethod("boundingcircle")
}

#' owin

boundingradius.owin <- function(x, ...) {
sqrt(min(fardist(x, ..., squared=TRUE)))
}

boundingcentre.owin <- function(x, ...) {
z <- where.min(fardist(x, ..., squared=TRUE))
Window(z) <- x
return(z)
}

boundingcircle.owin <- function(x, ...) {
d2 <- fardist(x, ..., squared=TRUE)
z <- where.min(d2)
r <- sqrt(min(d2))
w <- disc(centre=z, radius=r)
return(w)
}

#' ppp

boundingradius.ppp <- function(x, ...) {
boundingradius(convexhull(x), ...)
}

boundingcentre.ppp <- function(x, ...) {
z <- boundingcentre(convexhull(x), ...)
Window(z) <- Window(x)
return(z)
}

boundingcircle.ppp <- function(x, ...) {
boundingcircle(convexhull(x), ...)
}

56 changes: 0 additions & 56 deletions R/circum.R

This file was deleted.

8 changes: 4 additions & 4 deletions R/edgeRipley.R
@@ -1,7 +1,7 @@
#
# edgeRipley.R
#
# $Revision: 1.13 $ $Date: 2016/04/25 02:34:40 $
# $Revision: 1.15 $ $Date: 2016/07/16 03:11:15 $
#
# Ripley isotropic edge correction weights
#
Expand Down Expand Up @@ -173,11 +173,11 @@ edge.Ripley <- local({
rmax.Ripley <- function(W) {
W <- as.owin(W)
if(is.rectangle(W))
return(circumradius(W))
return(boundingradius(W))
if(is.polygonal(W) && length(W$bdry) == 1)
return(circumradius(W))
return(boundingradius(W))
## could have multiple connected components
pieces <- tiles(tess(image=connected(W)))
answer <- sapply(pieces, circumradius)
answer <- sapply(pieces, boundingradius)
return(as.numeric(answer))
}
4 changes: 2 additions & 2 deletions R/linearK.R
@@ -1,7 +1,7 @@
#
# linearK
#
# $Revision: 1.37 $ $Date: 2016/07/15 12:09:15 $
# $Revision: 1.38 $ $Date: 2016/07/16 03:08:23 $
#
# K function for point pattern on linear network
#
Expand Down Expand Up @@ -122,7 +122,7 @@ linearKengine <- function(X, ..., r=NULL, reweight=NULL, denom=1,
Y <- as.ppp(X)
W <- Y$window
# determine r values
rmaxdefault <- 0.98 * circumradius(L)
rmaxdefault <- 0.98 * boundingradius(L)
breaks <- handle.r.b.args(r, NULL, W, rmaxdefault=rmaxdefault)
r <- breaks$r
rmax <- breaks$max
Expand Down
4 changes: 2 additions & 2 deletions R/linearKmulti.R
@@ -1,7 +1,7 @@
#
# linearKmulti
#
# $Revision: 1.8 $ $Date: 2016/07/15 12:09:29 $
# $Revision: 1.9 $ $Date: 2016/07/16 03:08:23 $
#
# K functions for multitype point pattern on linear network
#
Expand Down Expand Up @@ -199,7 +199,7 @@ linearKmultiEngine <- function(X, I, J, ..., r=NULL, reweight=NULL, denom=1,
XP <- as.ppp(X)
W <- as.owin(XP)
# determine r values
rmaxdefault <- 0.98 * circumradius(L)
rmaxdefault <- 0.98 * boundingradius(L)
breaks <- handle.r.b.args(r, NULL, W, rmaxdefault=rmaxdefault)
r <- breaks$r
rmax <- breaks$max
Expand Down
19 changes: 15 additions & 4 deletions R/lineardisc.R
Expand Up @@ -209,10 +209,21 @@ countends <- function(L, x=locator(1), r, toler=NULL) {
}

default.linnet.tolerance <- function(L) {
# L could be a linnet or psp
if(!is.null(toler <- L$toler)) return(toler)
lenfs <- lengths.psp(as.psp(L))
toler <- 0.001 * min(lenfs[lenfs > 0])
toler <- max(sqrt(.Machine$double.xmin),
toler[is.finite(toler)], na.rm=TRUE)
len2 <- lengths.psp(as.psp(L), squared=TRUE)
len2pos <- len2[len2 > 0]
toler <- if(length(len2pos) == 0) 0 else (0.001 * sqrt(min(len2pos)))
toler <- makeLinnetTolerance(toler)
return(toler)
}

makeLinnetTolerance <- function(toler) {
max(sqrt(.Machine$double.xmin),
toler[is.finite(toler)], na.rm=TRUE)
}





4 changes: 2 additions & 2 deletions R/linearpcf.R
@@ -1,7 +1,7 @@
#
# linearpcf.R
#
# $Revision: 1.15 $ $Date: 2016/07/15 12:08:39 $
# $Revision: 1.16 $ $Date: 2016/07/16 03:08:23 $
#
# pair correlation function for point pattern on linear network
#
Expand Down Expand Up @@ -91,7 +91,7 @@ linearpcfengine <- function(X, ..., r=NULL,
Y <- as.ppp(X)
W <- Y$window
# determine r values
rmaxdefault <- 0.98 * circumradius(L)
rmaxdefault <- 0.98 * boundingradius(L)
breaks <- handle.r.b.args(r, NULL, W, rmaxdefault=rmaxdefault)
r <- breaks$r
rmax <- breaks$max
Expand Down
4 changes: 2 additions & 2 deletions R/linearpcfmulti.R
@@ -1,7 +1,7 @@
#
# linearpcfmulti.R
#
# $Revision: 1.7 $ $Date: 2016/07/15 12:08:51 $
# $Revision: 1.8 $ $Date: 2016/07/16 03:08:23 $
#
# pair correlation functions for multitype point pattern on linear network
#
Expand Down Expand Up @@ -198,7 +198,7 @@ linearPCFmultiEngine <- function(X, I, J, ..., r=NULL, reweight=NULL, denom=1,
XP <- as.ppp(X)
W <- as.owin(XP)
# determine r values
rmaxdefault <- 0.98 * circumradius(L)
rmaxdefault <- 0.98 * boundingradius(L)
breaks <- handle.r.b.args(r, NULL, W, rmaxdefault=rmaxdefault)
r <- breaks$r
rmax <- breaks$max
Expand Down

0 comments on commit 5e24bd4

Please sign in to comment.