Skip to content

Commit

Permalink
Ironing out some namespace stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
abarbour committed Nov 7, 2014
1 parent c6dbf07 commit 2f1f77d
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 32 deletions.
23 changes: 11 additions & 12 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
Package: deform
Type: Package
Title: Crustal deformation tools in R
Version: 0.0-2
Date: 2014-11-04
Title: Crustal deformation modeling tools in R
Version: 0.0-4
Date: 2014-11-07
Author: Andrew J. Barbour; some of these tools were
adapted from Matlab code by Brendan Crowell (UW),
adapted from Matlab codes by Brendan Crowell (UW),
and Francois Beauducel (IPGP).
Maintainer: A.J.Barbour <[email protected]>
Description: Crustal deformation tools.
License: GPL3
Description: Crustal deformation modeling tools.
License: GPL
Imports:
Rcpp (>= 0.11.2)
Depends:
RCurl,
rgdal,
sp,
maptools,
plyr,
reshape2,
abind
maptools
Suggests:
maps
RColorBrewer,
TeachingDemos,
maps,
plyr
LinkingTo: Rcpp
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@ export(timevarying_fluidmass)
export(timevarying_porepressure)
export(timevarying_surface_displacement)
exportPattern("^[[:alpha:]]+")
importFrom(RCurl,getURL)
importFrom(RCurl,url.exists)
importFrom(Rcpp,evalCpp)
importFrom(abind,abind)
importFrom(plyr,mutate)
useDynLib(deform)
33 changes: 19 additions & 14 deletions NOBUILD/Sandbox/segall.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library(deform)
library(kook)
library(plyr)
library(TeachingDemos)
library(deform)

.x. <- sort(unique(c(-7:-3, seq(-3.90,3.90,by=0.15), 3:7)))
su <- surface_displacement(.x.*1e3, C.=1e13, z_src=0.7e3)
Expand Down Expand Up @@ -58,31 +59,32 @@ F3 <- function(){
matplot(.x.km., zz2*1e3, type="l", col="black", main="Subsidence, mm, Segall 1985, Fig 8B", sub=Sys.time())
}

try(F3())

F3t <- function(){
#matplot(.time./yr, t(zz2t), type="l")
matplot(.x.km., zz2t, type="l", col="black")
matplot(.x.km., zz2t*1e6, type="l", col="black", main="Tilt")
}

#try(F3())
#try(F3t())

try(F3t())

zz3 <- timevarying_fluidmass(.x.km.*1e3, .time., .Vdot., .L., .t., .c., phi.=.phi.)

F4 <- function(){
#matplot(.time./yr, t(zz3)*1e2, type="l")
matplot(.x.km., zz3*1e2, type="l", col="black")
matplot(.x.km., zz3*1e2, type="l", col="black", main="t.v. Fluid mass change")
}

#try(F4())
try(F4())

zzp <- timevarying_porepressure(.x.km.*1e3, .z.km.*1e3, .time., .Vdot., .B., .L., .D., .c., .t., .mu., Pt.Sources.x=.TwoSources.x.)
redo <- FALSE
if (!exists("zzp") | redo) zzp <- timevarying_porepressure(.x.km.*1e3, .z.km.*1e3, .time., .Vdot., .B., .L., .D., .c., .t., .mu., Pt.Sources.x=.TwoSources.x.)

F5 <- function(do.log=FALSE){
#matplot(.time./yr, t(zz3)*1e2, type="l")
X<- zzp[,,length(.time.)]
if (do.log) X <- log10(abs(X))
matplot(x=.x.km., X, col=NA)
matplot(x=.x.km., X, col=NA, main="t.v. Pore pressure")
aaply(zzp, 3, .fun = function(X) {
if (do.log) X <- log10(abs(X))
matplot(x=.x.km., X, type="l", add=TRUE)
Expand All @@ -95,14 +97,17 @@ try(F5())


F5c <- function(){
#matplot(.time./yr, t(zz3)*1e2, type="l")
#contour(x=.x.km., y=.z.km., zzp[,,length(.time.)], col=NA)
layout(matrix(seq_len(dim(zzp)[3]), nrow=1))
aaply(zzp, 3, .fun = function(X) {
image(x=.x.km., y=.z.km., X, ylim=c(12,0), col = brewerRamp())
contour(x=.x.km., y=.z.km., X, ylim=c(12,0), add = TRUE)
image(x=.x.km., y=.z.km., X, ylim=c(6,0), col = brewerRamp())
contour(x=.x.km., y=.z.km., X, ylim=c(6,0), add = TRUE)
abline(v=.TwoSources.x./1e3, col="grey", lwd=2)
abline(h=(.D.+c(-1*.t.,.t.)/2)/1e3, col="grey", lwd=2)
return("x")
})

invisible()
layout(matrix(1))
}

#try(F5c())
try(F5c())
6 changes: 6 additions & 0 deletions R/deform-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
#'
#' @name deform
#' @docType package
#'
#' @useDynLib deform
#'
#' @exportPattern "^[[:alpha:]]+"
#'
#' @importFrom Rcpp evalCpp
#' @importFrom abind abind
#' @importFrom plyr mutate
#' @importFrom RCurl url.exists getURL
#'
#' @seealso \code{\link{segall85}} for deformation associated with fluid extraction
NULL
8 changes: 4 additions & 4 deletions R/deform-utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ erf <- function(x){
#' @rdname erf
#' @export
erfc <- function(x){
2 * pnorm(x * sqrt(2), lower = FALSE)
2 * pnorm(x * sqrt(2), lower.tail = FALSE)
}

#' @rdname erf
#' @export
ierf <- function (x){
qnorm((1 + x)/2)/sqrt(2)
qnorm((1 + x) / 2) / sqrt(2)
}

#' @rdname erf
#' @export
ierfc <- function (x){
qnorm(x/2, lower = FALSE)/sqrt(2)
qnorm(x/2, lower.tail = FALSE) / sqrt(2)
}

ierfc2 <- function(x){
exp(-1*x^2)/sqrt(pi) - x*erfc(x)
exp(-1 * x^2) / sqrt(pi) - x * erfc(x)
}
4 changes: 2 additions & 2 deletions R/epsg.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ getEPSG <- function(ref.id=4326, verbose=TRUE, agency=NULL){
#http://spatialreference.org/ref/epsg/4326/proj4/
ref.url <- sprintf("%s/%s/proj4/", agency.root(agency), ref.id)
if (verbose) message(ref.url)
stopifnot(RCurl::url.exists(ref.url))
prj <- RCurl::getURL(ref.url)
stopifnot(url.exists(ref.url))
prj <- getURL(ref.url)
return(prj)
}

Expand Down

0 comments on commit 2f1f77d

Please sign in to comment.