[Robast-commits] r911 - in branches/robast-1.0/pkg/RobAStRDA: . R inst/AddMaterial/interpolation

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Sep 4 22:37:01 CEST 2016


Author: ruckdeschel
Date: 2016-09-04 22:37:01 +0200 (Sun, 04 Sep 2016)
New Revision: 911

Added:
   branches/robast-1.0/pkg/RobAStRDA/inst/AddMaterial/interpolation/GenerateSNInterpolators.R
Modified:
   branches/robast-1.0/pkg/RobAStRDA/DESCRIPTION
   branches/robast-1.0/pkg/RobAStRDA/NAMESPACE
   branches/robast-1.0/pkg/RobAStRDA/R/sysdata.rda
   branches/robast-1.0/pkg/RobAStRDA/inst/AddMaterial/interpolation/interpolationscripts.R
Log:
Interpolating stuff in branch 1.0

Modified: branches/robast-1.0/pkg/RobAStRDA/DESCRIPTION
===================================================================
--- branches/robast-1.0/pkg/RobAStRDA/DESCRIPTION	2016-09-04 20:35:51 UTC (rev 910)
+++ branches/robast-1.0/pkg/RobAStRDA/DESCRIPTION	2016-09-04 20:37:01 UTC (rev 911)
@@ -4,7 +4,7 @@
 Title: Interpolation Grids for Packages of the 'RobASt' - Family of Packages
 Description: Includes 'sysdata.rda' file for packages of the 'RobASt' - family of packages; is
         currently used by package 'RobExtremes' only.
-Depends: R (>= 2.14.0)
+Depends: R (>= 3.3.0)
 Imports: stats
 Authors at R: c(person("Matthias", "Kohl", role=c("aut", "cph")), person("Bernhard", "Spangl",
         role="ctb", comment="contributed smoothed grid values of the Lagrange multipliers"),

Modified: branches/robast-1.0/pkg/RobAStRDA/NAMESPACE
===================================================================
--- branches/robast-1.0/pkg/RobAStRDA/NAMESPACE	2016-09-04 20:35:51 UTC (rev 910)
+++ branches/robast-1.0/pkg/RobAStRDA/NAMESPACE	2016-09-04 20:37:01 UTC (rev 911)
@@ -1 +1,3 @@
 importFrom("stats", "splinefun", "approxfun")
+importFrom("stats", "predict", "smooth.spline")
+importFrom("utils", "head", "read.csv", "read.table")

Modified: branches/robast-1.0/pkg/RobAStRDA/R/sysdata.rda
===================================================================
(Binary files differ)

Added: branches/robast-1.0/pkg/RobAStRDA/inst/AddMaterial/interpolation/GenerateSNInterpolators.R
===================================================================
--- branches/robast-1.0/pkg/RobAStRDA/inst/AddMaterial/interpolation/GenerateSNInterpolators.R	                        (rev 0)
+++ branches/robast-1.0/pkg/RobAStRDA/inst/AddMaterial/interpolation/GenerateSNInterpolators.R	2016-09-04 20:37:01 UTC (rev 911)
@@ -0,0 +1,116 @@
+### session to supply Sn Grids on Sep 04 2016
+
+require(RobAStRDA)
+require(RobExtremes)
+
+s = getFromNamespace(".RMXE", ns = "RobAStRDA")
+nE = new.env()
+oldwd <- getwd()
+.basepath <- "C:/rtest/RobASt/branches/robast-1.0/pkg"
+.myFolderFrom <- file.path(.basepath,"RobExtremesBuffer/neu")
+myRDA0 <- file.path(.basepath,"RobExtremesBuffer/sysdata.rda")
+myRDA <- file.path(.basepath,"RobAStRDA/R/sysdata.rda")
+
+load(myRDA,nE)
+ls(nE,all=T)
+ga=get(".Generalized",nE)
+names(ga)
+
+nEalt = new.env()
+load("C:/rtest/robast/branches/robast-0.9/pkg/RobAStRDA/R/sysdata.rda",nEalt)
+ls(nEalt, all=TRUE)
+
+SN=get(".Sn",nEalt)
+names(SN)
+SN[[1]]
+SN[[1]][[1]]
+names(SN)
+
+listGrid <- list()
+listGrid[[1]] <- SN[[1]][[1]]
+listGrid[[2]] <- SN[[2]][[1]]
+listGrid[[3]] <- SN[[3]][[1]]
+listGrid[[4]] <- SN[[4]][[1]]
+names(listGrid) <- names(SN)
+
+xiseq <- seq(-0.5,-0.00001,length.out=150)
+
+
+SnV <- numeric(150)
+for(i in 1:150){
+  Fam <- GPareto(shape=xiseq[i])
+  print(i)
+  SnV[i] <- Sn(Fam)
+}
+
+newGrid <- rbind(cbind(xiseq,SnV),listGrid[[2]])
+newGrid <- cbind(newGrid,predict(smooth.spline(newGrid[,1], newGrid[,2]),newGrid[,1])$y)
+
+matplot(newGrid[,1], newGrid[,c(2,3)],type="l", log="y")
+
+SnV2 <- SnV
+for(i in 1:150){
+  Fam <- GEV(shape=xiseq[i])
+  print(i)
+  SnV2[i] <- Sn(Fam)
+}
+
+newGrid2 <- rbind(cbind(xiseq,SnV2),listGrid[[3]])
+newGrid2 <- cbind(newGrid2,predict(smooth.spline(newGrid2[,1], newGrid2[,2]),newGrid2[,1])$y)
+
+matplot(newGrid2[,1], newGrid2[,c(2,3)],type="l", log="y")
+
+newGrid0 <- listGrid[[1]]
+newGrid0 <- cbind(newGrid0,predict(smooth.spline(newGrid0[,1], newGrid0[,2]),newGrid0[,1])$y)
+matplot(newGrid0[,1], newGrid0[,c(2,3)],type="l", log="y")
+
+
+newGrid3 <- listGrid[[4]]
+newGrid3 <- cbind(newGrid3,predict(smooth.spline(newGrid3[,1], newGrid3[,2]),newGrid3[,1])$y)
+matplot(newGrid3[,1], newGrid3[,c(2,3)],type="l", log="y")
+
+save(newGrid0, newGrid, newGrid2, newGrid3, listGrid, file="SnGridAll.rda")
+
+tu <- function(Grid) {gr <- RobAStRDA:::.generateInterpolators(Grid[,c(1,3)])
+					  gr0 <- list()
+					  gr0[["grid"]] <- Grid[,c(1,2)]
+					  gr0[["gridS"]] <- Grid[,c(1,3)]
+					  gr0[["fun.N"]] <- gr$fct
+					  return(gr0)}
+
+
+GammaF <- tu(newGrid0)
+GPDF <- tu(newGrid)
+GEVF <- tu(newGrid2)
+WeibullF <- tu(newGrid3)
+
+.basepath <- "C:/rtest/RobASt/branches/robast-1.0/pkg"
+myRDA <- file.path(.basepath,"RobAStRDA/R/sysdata.rda")
+nE = new.env()
+load(myRDA,nE)
+ls(nE,all=T)
+
+nams <- ls(nE,all=TRUE)
+zw <- get(nams[1],nE)
+zw[["Sn"]] <- GammaF
+assign(nams[1],zw,envir=nE)
+zw <- get(nams[2],nE)
+zw[["Sn"]] <- GPDF
+assign(nams[2],zw,envir=nE)
+zw <- get(nams[3],nE)
+zw[["Sn"]] <- GEVF
+assign(nams[3],zw,envir=nE)
+zw <- get(nams[4],nE)
+zw[["Sn"]] <- GEVF
+assign(nams[4],zw,envir=nE)
+zw <- get(nams[5],nE)
+zw[["Sn"]] <- WeibullF
+assign(nams[5],zw,envir=nE)
+
+zw <- get(nams[2],nE)
+assign(".GPareto",zw,envir=nE)
+rm(".Generalized",envir=nE)
+(namesNew <- ls(nE,all=T))
+
+save(list=namesNew, envir=nE, file=myRDA)
+tools::resaveRdaFiles(myRDA)

Modified: branches/robast-1.0/pkg/RobAStRDA/inst/AddMaterial/interpolation/interpolationscripts.R
===================================================================
--- branches/robast-1.0/pkg/RobAStRDA/inst/AddMaterial/interpolation/interpolationscripts.R	2016-09-04 20:35:51 UTC (rev 910)
+++ branches/robast-1.0/pkg/RobAStRDA/inst/AddMaterial/interpolation/interpolationscripts.R	2016-09-04 20:37:01 UTC (rev 911)
@@ -14,7 +14,7 @@
 
 oldwd <- getwd()
 .basepath <- "C:/rtest/RobASt/branches/robast-1.0/pkg"
-.myFolderFrom <- file.path(.basepath,"RobExtremesBuffer")
+.myFolderFrom <- file.path(.basepath,"RobExtremesBuffer/neu")
 myRDA0 <- file.path(.basepath,"RobExtremesBuffer/sysdata.rda")
 #myRDA <- file.path(.basepath,"RobExtremesBuffer/sysdata.rda")
 #myRDA0 <- file.path(.basepath,"RobAStRDA/R/sysdata0.rda")



More information about the Robast-commits mailing list