[Dplr-commits] r972 - in pkg/dplR: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 11 12:57:35 CET 2015


Author: mvkorpel
Date: 2015-03-11 12:57:35 +0100 (Wed, 11 Mar 2015)
New Revision: 972

Modified:
   pkg/dplR/DESCRIPTION
   pkg/dplR/R/morlet.R
   pkg/dplR/R/redfit.R
Log:
M-x untabify (replace tabs with spaces)


Modified: pkg/dplR/DESCRIPTION
===================================================================
--- pkg/dplR/DESCRIPTION	2015-03-10 10:18:07 UTC (rev 971)
+++ pkg/dplR/DESCRIPTION	2015-03-11 11:57:35 UTC (rev 972)
@@ -3,7 +3,7 @@
 Type: Package
 Title: Dendrochronology Program Library in R
 Version: 1.6.3
-Date: 2015-03-10
+Date: 2015-03-11
 Authors at R: c(person("Andy", "Bunn", role = c("aut", "cph",
         "cre", "trl"), email = "andy.bunn at wwu.edu"), person("Mikko",
         "Korpela", role = c("aut", "trl")), person("Franco", "Biondi",

Modified: pkg/dplR/R/morlet.R
===================================================================
--- pkg/dplR/R/morlet.R	2015-03-10 10:18:07 UTC (rev 971)
+++ pkg/dplR/R/morlet.R	2015-03-11 11:57:35 UTC (rev 972)
@@ -1,23 +1,23 @@
 morlet <- function(y1, x1=seq_along(y1), p2=NULL, dj=0.25, siglvl=0.95){
 
     morlet.func <- function(k0=6, Scale, k) {
-	n <- length(k)
-	expnt <- -(Scale * k - k0) ^ 2 / 2 * as.numeric(k > 0)
-	Dt <- 2 * pi / (n * k[2])
-	norm <- sqrt(2 * pi * Scale / Dt) * (pi ^ (-0.25)) #  total energy=N   [Eqn(7)]
+        n <- length(k)
+        expnt <- -(Scale * k - k0) ^ 2 / 2 * as.numeric(k > 0)
+        Dt <- 2 * pi / (n * k[2])
+        norm <- sqrt(2 * pi * Scale / Dt) * (pi ^ (-0.25)) #  total energy=N   [Eqn(7)]
 
-	morlet <- norm * exp(ifelse(expnt > -100, expnt, 100))
-	morlet <- morlet * (as.numeric(expnt > -100))  # Avoid underflow errors
-	morlet <- morlet * (as.numeric(k > 0))  # Heaviside step function (Morlet is complex)
-	fourier_factor <-
+        morlet <- norm * exp(ifelse(expnt > -100, expnt, 100))
+        morlet <- morlet * (as.numeric(expnt > -100))  # Avoid underflow errors
+        morlet <- morlet * (as.numeric(k > 0))  # Heaviside step function (Morlet is complex)
+        fourier_factor <-
             (4 * pi) / (k0 + sqrt(2 + k0 ^ 2)) # Scale-->Fourier [Sec.3h]
-	period <- Scale * fourier_factor
-	coi <- fourier_factor / sqrt(2)   # Cone-of-influence [Sec.3g]
-	## dofmin = 2   # Degrees of freedom with no smoothing
-	## Cdelta = -1
-	## if(k0 == 6) Cdelta = 0.776 # Reconstruction factor
-	## psi0 = pi^(-0.25)
-	list(psi_fft = morlet, period = period, coi = coi)
+        period <- Scale * fourier_factor
+        coi <- fourier_factor / sqrt(2)   # Cone-of-influence [Sec.3g]
+        ## dofmin = 2   # Degrees of freedom with no smoothing
+        ## Cdelta = -1
+        ## if(k0 == 6) Cdelta = 0.776 # Reconstruction factor
+        ## psi0 = pi^(-0.25)
+        list(psi_fft = morlet, period = period, coi = coi)
     }
 
     ## Construct optional inputs, these could be passed in as args
@@ -84,9 +84,9 @@
         psi_fft <- morlet.out$psi_fft
         coi <- morlet.out$coi # One value per scale
         wave[, a1] <- fft(yfft * psi_fft, inverse=TRUE)
-  	if(do_daughter) daughter[, a1] <- fft(psi_fft, inverse=TRUE)
+        if(do_daughter) daughter[, a1] <- fft(psi_fft, inverse=TRUE)
         period[a1] <- morlet.out$period   # Save period
-  	fft_theor[a1] <- sum((abs(psi_fft) ^ 2) * fft_theor_k) / n
+        fft_theor[a1] <- sum((abs(psi_fft) ^ 2) * fft_theor_k) / n
     }
     time.scalar <- c(seq_len(floor(n1 + 1) / 2),
                      seq.int(from=floor(n1 / 2), to=1, by=-1)) * Dt

Modified: pkg/dplR/R/redfit.R
===================================================================
--- pkg/dplR/R/redfit.R	2015-03-10 10:18:07 UTC (rev 971)
+++ pkg/dplR/R/redfit.R	2015-03-11 11:57:35 UTC (rev 972)
@@ -1547,17 +1547,17 @@
     rhovec <- numeric(n50)
     twkM <- matrix(1, nseg2, 2)
     for (i in as.numeric(seq_len(n50))) {
-	## copy data of (i+1)'th segment into workspace
-	iseg <- .Call(dplR.seg50, i, nseg2, segskip2, np)
+        ## copy data of (i+1)'th segment into workspace
+        iseg <- .Call(dplR.seg50, i, nseg2, segskip2, np)
         twk <- t[iseg]
         twkM[, 2] <- twk
         xwk <- x[iseg]
-	## detrend data
+        ## detrend data
         xwk <- do.call(lmfitfun, list(twkM, xwk))[["residuals"]]
-	## estimate and sum rho for each segment
-	rho <- redfitTauest(twk, xwk)
-	## bias correction for rho (Kendall & Stuart, 1967; Vol. 3))
-	rhovec[i] <- (rho * (nseg2 - 1) + 1) / (nseg2 - 4)
+        ## estimate and sum rho for each segment
+        rho <- redfitTauest(twk, xwk)
+        ## bias correction for rho (Kendall & Stuart, 1967; Vol. 3))
+        rhovec[i] <- (rho * (nseg2 - 1) + 1) / (nseg2 - 4)
     }
     ## average rho
     mean(rhovec)
@@ -1598,11 +1598,11 @@
     xscalMNP <- xscal[-np]
     rho <- sum(xscalMNP * xscal[-1]) / sum(xscalMNP * xscalMNP)
     if (rho <= 0) {
-	rho <- 0.05
-	warning("rho estimation: <= 0")
+        rho <- 0.05
+        warning("rho estimation: <= 0")
     } else if (rho > 1) {
-	rho <- 0.95
-	warning("rho estimation: > 1")
+        rho <- 0.95
+        warning("rho estimation: > 1")
     }
     scalt <- -log(rho) / dt
     tscal <- t * scalt
@@ -1612,14 +1612,14 @@
     mult <- minRes[["nmu"]]
     warnings <- FALSE
     if (mult) {
-	warning("estimation problem: LS function has > 1 minima")
+        warning("estimation problem: LS function has > 1 minima")
         warnings <- TRUE
     }
     if (amin <= 0) {
-	warning("estimation problem: a_min =< 0")
+        warning("estimation problem: a_min =< 0")
         warnings <- TRUE
     } else if (amin >= 1) {
-	warning("estimation problem: a_min >= 1")
+        warning("estimation problem: a_min >= 1")
         warnings <- TRUE
     }
     if (!warnings) {



More information about the Dplr-commits mailing list