R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("clim.pact-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('clim.pact') Loading required package: ncdf Loading required package: akima > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "COn0E65N" > > ### * COn0E65N > > flush(stderr()); flush(stdout()) > > ### Name: COn0E65N > ### Title: Convert long-lat to km-km > ### Aliases: COn0E65N lat lon > ### Keywords: manip > > ### ** Examples > > library(clim.pact) > data(oslo.t2m) > print(c(oslo.t2m$lon,oslo.t2m$lat)) [1] 10.71667 59.95000 > #[1] 10.71667 59.95000 > xy<-COn0E65N(oslo.t2m$lon,oslo.t2m$lat) > oslo.t2m$lon<-xy$x > oslo.t2m$lat<-xy$y > print(c(oslo.t2m$lon,oslo.t2m$lat)) [1] 595.4086 -560.3004 > #[1] 595.4086 -560.3004 > lon<-km2lon(oslo.t2m$lon,oslo.t2m$lat,x.centre=0,y.centre=65) > lat<-km2lat(oslo.t2m$lon,oslo.t2m$lat,x.centre=0,y.centre=65) > print(c(lon,lat)) [1] 10.71667 59.95000 > #[1] 10.71667 59.95000 > > > > cleanEx(); ..nameEx <- "DNMI.t2m" > > ### * DNMI.t2m > > flush(stderr()); flush(stdout()) > > ### Name: DNMI.t2m > ### Title: Gridded monthly mean climate data > ### Aliases: DNMI.t2m DNMI.slp DNMI.sst > ### Keywords: datasets > > ### ** Examples > > ## Not run: > ##D library(clim.pact) > ##D t2m <- retrieve.nc("~/data/analysis/DNMI_t2m.nc") > ##D eof <- EOF(t2m) > ##D save(file="clim.pact/data/eof_DNMI_t2m.Rdata",eof) > ##D t2m.eof <- EOF2field(eof) > ##D > ##D # Check if the EOF reconstruction reproduces the original field: > ##D newFig() > ##D plotField(t2m,lat=60,lon=10) > ##D plotField(t2m.eof,lat=60,lon=10,add=TRUE,lty=2,col="red") # Very similar time series > ##D > ##D newFig() > ##D mapField(t2m.eof) > ##D mapField(t2m,add=TRUE,col="red",lty=2,lwd=1) # Very similar spatial pattern/contours > ##D > ##D sst <- retrieve.nc("~/data/analysis/DNMI_sst.nc") > ##D eof <- EOF(sst) > ##D save(file="clim.pact/data/eof_DNMI_sst.Rdata",eof) > ##D > ##D slp <- retrieve.nc("~/data/analysis/DNMI_slp.nc") > ##D eof <- EOF(slp) > ##D save(file="clim.pact/data/eof_DNMI_slp.Rdata",eof) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "DS" > > ### * DS > > flush(stderr()); flush(stdout()) > > ### Name: DS > ### Title: Downscaling of monthly or daily means > ### Aliases: DS > ### Keywords: models multivariate ts spatial > > ### ** Examples > > library(clim.pact) > data("oslo.t2m") > data("eof.mc") > a<-DS(dat=oslo.t2m,preds=eof.mc,plot=FALSE) [1] "The directory output/ does not exists.. Creates it.." Warning in if (instring("-", preds.names[i.pred]) > 0) { : the condition has length > 1 and only the first element will be used Warning in if (instring("_", preds.names[i.pred]) > 0) { : the condition has length > 1 and only the first element will be used [1] "------------Match times---------------- " [1] "Number of coinciding obs: 41 , 41" Min. 1st Qu. Median Mean 3rd Qu. Max. 1890 1917 1945 1945 1972 1999 Min. 1st Qu. Median Mean 3rd Qu. Max. 1958 1968 1978 1978 1988 1998 [1] "Common times:" [1] 1958 1998 [1] -10.5 2.3 [1] "de-trend:" [1] "stepwise regression:" [1] "Model: lm(y ~ 1 + X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8,data=calibrate)" [1] "Stepwise: step(lm.mod,trace=0)" [1] "ANOVA from step-wise regression:" Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found [1] "Downscaled anomalies:" Min. 1st Qu. Median Mean 3rd Qu. Max. -9.215 -1.974 1.907 1.230 4.077 8.745 Call: lm(formula = y ~ 1 + X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8, data = calibrate) Residuals: Min 1Q Median 3Q Max -1.7784 -0.8742 -0.1178 0.7308 3.0385 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.577e-16 2.037e-01 7.74e-16 1.00000 X1 3.580e-01 3.062e-02 11.693 4.33e-13 *** X2 -2.582e-01 4.693e-02 -5.501 4.62e-06 *** X3 1.120e-01 3.643e-02 3.073 0.00430 ** X4 -3.282e-01 6.799e-02 -4.827 3.28e-05 *** X5 3.168e-01 6.470e-02 4.897 2.68e-05 *** X6 4.616e-01 1.482e-01 3.115 0.00386 ** X7 4.704e-01 1.357e-01 3.467 0.00152 ** X8 3.201e-01 1.600e-01 2.001 0.05394 . --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.304 on 32 degrees of freedom Multiple R-Squared: 0.8538, Adjusted R-squared: 0.8172 F-statistic: 23.35 on 8 and 32 DF, p-value: 2.717e-11 [1] "Reconstruct the spatial patterns" (Intercept) X1 X2 X3 X4 1.576791e-16 3.580453e-01 -2.581519e-01 1.119527e-01 -3.281971e-01 X5 X6 X7 X8 3.168286e-01 4.616045e-01 4.704474e-01 3.200595e-01 [1] "Linear trend for GCM (deg C/decade)" [1] "Slope and its uncertainty" [1] 0.70 0.15 [1] "P-value of fit= 0" [1] "P-value of trend-fit for downscaled scenario 0" [1] "Dignosis:" [1] "output/" [1] "mpi+ncep" [1] "60W40E-52N75N" [1] "Oslo" [1] 101 [1] "Jan" [1] "mon" [1] "lm" [1] "File name: output/ds_mpi+ncep_60W40E-52N75N_Oslo_101_Jan_mon_lm.Rdata" > ## Not run: > ##D # Example 1: for computing common EOFs and using these as a basis for DS. > ##D slp.obs <- retrieve.nc("ncep_slp.nc",x.rng=c(-20,40),y.rng=c(50,70)) > ##D # Get gridded observations/analysis from NCEP > ##D slp.gcm <- retrieve.nc("EH4OPYC_B2_slp.nc") # Get results from climate models > ##D slp <- catFields(slp.obs,slp.gcm) # combine the fields. > ##D eof <- EOF(slp,mon=1) > ##D obs <- getnordklim("Stockholm") > ##D ds <- DS(preds=eof,obs) > ##D > ##D > ##D # Example 2: > ##D # A demonstration for the linear regression model: monthly values > ##D library(clim.pact) > ##D > ##D # Read the gridded netCDF data: > ##D > ##D t2m<-retrieve.nc("DNMI_t2m.nc") > ##D > ##D # Manipulate the data: assign one part as calibration and one part as independent data > ##D nt<-length(t2m$tim) > ##D t2m$id.t[1:floor(nt/2)]<-"calibrate" > ##D t2m$id.t[ceiling(nt/2):nt]<-"independent" > ##D > ##D # Compute EOFs > ##D eof<-EOF(t2m,mon=1,neofs=3) > ##D plotEOF(eof) > ##D > ##D # Get the predictand: a local station series > ##D obs<-getnordklim("Goeteborg",ele=101) > ##D > ##D # Apply the downscaling > ##D DS(preds=eof,obs) > ##D plotStation(obs,mon=1,add=TRUE,col="darkgreen",lwd=1,lty=2) > ##D > ##D > ##D # Example 3: A demonstration for the linear regression model: daily values > ##D # These files are not distributed with the clim.pact package, but > ##D # nevertheless demonstrate how the downscaling can be done with a few > ##D # clim.pact functions. > ##D > ##D library(clim.pact) > ##D data(eof.dc) > ##D list<-read.table("data/daily/station.list.good",header=TRUE) > ##D print(list) > ##D > ##D i<-as.numeric(readline("Which number? (1-37)")) > ##D obs1<-read.table(paste("data/daily/",list$file.name[i],sep="")) > ##D > ##D obs<-station.obj.dm(t2m=obs1$V5,precip=obs1$V6,yy=obs1$V4,mm=obs1$V3,dd=obs1$V2, > ##D station=obs1$V1[1],location=as.character(list$location[i]), > ##D lon=list$lon[i],lat=list$lat[i],alt=list$alt[i], > ##D obs.name<-c("t2m","precipitation")) > ##D > ##D plotStation(obs) > ##D DS(preds=eof.dc,obs) > ##D > ##D > ##D Example 4: A demonstration for the analog model: daily values > ##D > ##D library(clim.pact) > ##D library(anm) > ##D source("clim.R") > ##D data(eof.dc) > ##D list<-read.table("data/daily/station.list.good",header=TRUE) > ##D print(list) > ##D > ##D i<-as.numeric(readline("Which number? (1-37)")) > ##D obs1<-read.table(paste("data/daily/",list$file.name[i],sep="")) > ##D > ##D obs<-station.obj.dm(t2m=obs1$V5,precip=obs1$V6,yy=obs1$V4,mm=obs1$V3,dd=obs1$V2, > ##D station=obs1$V1[1],location=as.character(list$location[i]), > ##D lon=list$lon[i],lat=list$lat[i],alt=list$alt[i], > ##D obs.name<-c("t2m","precipitation")) > ##D > ##D plotStation(obs) > ##D > ##D print("Please be patient - this takes a while...") > ##D ds-anm<-DS(preds=eof.dc,obs,method="anm.weight",swsm="none", > ##D predm="predict.anm",param="precip", > ##D lsave=FALSE,ldetrnd=FALSE) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "EOF" > > ### * EOF > > flush(stderr()); flush(stdout()) > > ### Name: EOF > ### Title: Empirical Orthogonal Functions (EOFs). > ### Aliases: eof EOF Empirical orthogonal Functions PCA principal component > ### analysis > ### Keywords: spatial ts multivariate > > ### ** Examples > > # Computes a set of mixed-common EOFs (overnight work..). This takes a while... > ## Not run: > ##D library(clim.pact) > ##D x.1 <- retrieve.nc("/home/kareb/data/ncep/ncep_t2m.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D x.2 <- retrieve.nc("/home/kareb/data/ncep/ncep_slp.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D print(x.1$v.name) > ##D > ##D print("Read GCM predictor data.") > ##D X.1 <- retrieve.nc("data/mpi-gsdio_t2m.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D X.2 <- retrieve.nc("data/mpi-gsdio_slp.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D print(X.1$v.name) > ##D print("Cat fields.") > ##D xX.1 <- cat.fields(x.1,X.1,interval.1=c(1958,1998),interval.2=c(1958,2050)) > ##D xX.2 <- cat.fields(x.2,X.2,interval.1=c(1958,1998),interval.2=c(1958,2050)) > ##D xX <- mix.fields(xX.1,xX.2,mon=1, > ##D interval=c(1900,2050)) > ##D print("EOF") > ##D eof.c <- eof(xX.1,mon=1) > ##D eof.mc <- eof(xX,mon=1) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "EOF2field" > > ### * EOF2field > > flush(stderr()); flush(stdout()) > > ### Name: EOF2field > ### Title: Reconstructs a field from EOF products > ### Aliases: EOF2field > ### Keywords: models multivariate ts spatial > > ### ** Examples > > ## Not run: > ##D load("data/ceof.Rdata") # loads the object 'eof' > ##D field <- EOF2field(eof) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "addland" > > ### * addland > > flush(stderr()); flush(stdout()) > > ### Name: addland > ### Title: Add land contours to map. > ### Aliases: addland > ### Keywords: hplot > > ### ** Examples > > plot(c(-90,90),c(0,80),type="n") > addland() > grid() > > > > cleanEx(); ..nameEx <- "addland.data" > > ### * addland.data > > flush(stderr()); flush(stdout()) > > ### Name: addland > ### Title: Coordinates of coast line. > ### Aliases: continental coast line lat.cont lon.cont addland2 > ### Keywords: datasets > > ### ** Examples > > library(clim.pact) > data(addland) > ls() # [1] "lat.cont" "lon.cont" [1] "lat.cont" "lon.cont" > > > > cleanEx(); ..nameEx <- "adjust.eof" > > ### * adjust.eof > > flush(stderr()); flush(stdout()) > > ### Name: adjust.eof > ### Title: Adjust common EOFs > ### Aliases: adjust.eof > ### Keywords: manip > > ### ** Examples > > data(eof.c) > eof <- adjust.eof(eof.c) [1] 42 1 [1] "ncep_t2m" "mpi-gsdio_t2m" [1] "1" "2" NA "ncep_t2m" "0.01" "0.09" NA "mpi-gsdio_t2m" "-0.01" [10] "0.09" [1] " " [1] "2" "2" NA "ncep_t2m" "-0.03" "0.1" NA "mpi-gsdio_t2m" "0.01" [10] "0.08" [1] " " [1] "3" "2" NA "ncep_t2m" "0.03" "0.12" NA "mpi-gsdio_t2m" "-0.01" [10] "0.06" [1] " " [1] "4" "2" NA "ncep_t2m" "0.07" "0.07" NA "mpi-gsdio_t2m" "-0.03" [10] "0.07" [1] " " [1] "5" "2" NA "ncep_t2m" "-0.07" "0.09" NA "mpi-gsdio_t2m" "0.03" [10] "0.06" [1] " " [1] "6" "2" NA "ncep_t2m" "0" "0.09" NA "mpi-gsdio_t2m" "0" [10] "0.09" [1] " " [1] "7" "2" NA "ncep_t2m" "0.02" "0.1" NA "mpi-gsdio_t2m" "-0.01" [10] "0.08" [1] " " [1] "8" "2" NA "ncep_t2m" "-0.02" "0.12" NA "mpi-gsdio_t2m" "0.01" [10] "0.07" [1] " " [1] "9" "2" NA "ncep_t2m" "-0.05" "0.09" NA "mpi-gsdio_t2m" "0.02" [10] "0.07" [1] " " [1] "10" "2" NA "ncep_t2m" "-0.01" "0.12" NA "mpi-gsdio_t2m" "0" [10] "0.07" [1] " " [1] "11" "2" NA "ncep_t2m" "-0.01" "0.1" NA "mpi-gsdio_t2m" "0.01" [10] "0.08" [1] " " [1] "12" "2" NA "ncep_t2m" "0.01" "0.09" NA "mpi-gsdio_t2m" "-0.01" [10] "0.09" [1] " " [1] "13" "2" NA "ncep_t2m" "0" "0.1" NA "mpi-gsdio_t2m" "0" [10] "0.08" [1] " " [1] "14" "2" NA "ncep_t2m" "-0.02" "0.1" NA "mpi-gsdio_t2m" "0.01" [10] "0.08" [1] " " [1] "15" "2" NA "ncep_t2m" "0" "0.11" NA "mpi-gsdio_t2m" "0" [10] "0.08" [1] " " [1] "16" "2" NA "ncep_t2m" "0" "0.11" NA "mpi-gsdio_t2m" "0" [10] "0.07" [1] " " [1] "17" "2" NA "ncep_t2m" "0" "0.1" NA "mpi-gsdio_t2m" "0" [10] "0.08" [1] " " [1] "18" "2" NA "ncep_t2m" "-0.01" "0.12" NA "mpi-gsdio_t2m" "0" [10] "0.07" [1] " " [1] "19" "2" NA "ncep_t2m" "0" "0.11" NA "mpi-gsdio_t2m" "0" [10] "0.07" [1] " " [1] "20" "2" NA "ncep_t2m" "0" "0.12" NA "mpi-gsdio_t2m" "0" [10] "0.07" [1] " " > plotEOF(eof) > > > > cleanEx(); ..nameEx <- "anomaly.field" > > ### * anomaly.field > > flush(stderr()); flush(stdout()) > > ### Name: anomaly.field > ### Title: Anomalies of a field object. > ### Aliases: anomaly.field > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D slp<-retrieve.nc("ncep_slp.nc") > ##D slp.a<-anomaly.field(slp) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "anomaly.station" > > ### * anomaly.station > > flush(stderr()); flush(stdout()) > > ### Name: anomaly.station > ### Title: Anomaly.station > ### Aliases: anomaly.station > ### Keywords: manip > > ### ** Examples > > library(clim.pact) > data(oslo.t2m) > oslo.t2ma<-anomaly.station(oslo.t2m) > > > > cleanEx(); ..nameEx <- "avail.elem" > > ### * avail.elem > > flush(stderr()); flush(stdout()) > > ### Name: avail.elem > ### Title: Available elements > ### Aliases: avail.elem avail.locs avail.preds avail.eofs avail.ds > ### Keywords: file > > ### ** Examples > > library(clim.pact) > avail.elem()$name [1] "mean T(2m)" "mean maximum T(2m)" [3] "highest maximum T(2m)" "day of Th date Thd" [5] "mean minimum T(2m)" "lowest minimum T(2m)" [7] "day of Tl date Tld" "mean SLP" [9] "monthly accum. precip." "maximum precip." [11] "Number of days with snow cover (> 50% covered) days dsc" "Mean cloud cover % N" [13] "mean snow depth" > # [1] "mean T(2m)" > # [2] "mean maximum T(2m)" > # [3] "highest maximum T(2m)" > # [4] "day of Th date Thd" > # [5] "mean minimum T(2m)" > # [6] "lowest minimum T(2m)" > # [7] "day of Tl date Tld" > # [8] "mean SLP" > # [9] "monthly accum. precip." > #[10] "maximum precip." > #[11] "Number of days with snow cover (> 50 > #[12] "Mean cloud cover > #[13] "mean snow depth" > > # The following assumes that the subdirectory 'data' exists > ## Not run: > ##D avail.locs()$name[avail.locs()$country=="FIN"] > ##D # [1] "HELSINKI" "TURKU" "TAMPERE" "LAPPEENRANTA" > ##D # [5] "JYVASKYLA" "KUOPIO" "KAJAANI" "OULU" > ##D # [9] "KUUSAMO" "SODANKYLA" "Maarianhamina" "Helsinki" > ##D #[13] "Turku" "Huittinen" "Tampere" "Hattula" > ##D #[17] "Heinola" "Virolahti" "Lappeenranta" "Lavia" > ##D #[21] "Virrat" "Orivesi" "Jyvaeskylae" "Vaasa" > ##D #[25] "Ylistaro" "Aehtaeri" "Kuopio" "Maaninka" > ##D #[29] "Joensuu" "Kestilä" "Kajaani" "Oulu" > ##D #[33] "Yli-Ii" "Pudasjärvi" "Kuusamo" "Sodankylae" > ##D > ##D avail.preds() > ##D # [1] "eof.dc.Rdata" > ##D # [2] "eof.dmc.Rdata" > ##D # [3] "eof.mc2.Rdata" > ##D # [4] "eof.nn.dc.Rdata" > ##D # [5] "eof.nn.dmc.Rdata" > ##D # ... > ## End(Not run) > > > > cleanEx(); ..nameEx <- "bergen.dm.data" > > ### * bergen.dm.data > > flush(stderr()); flush(stdout()) > > ### Name: bergen.dm > ### Title: Daily Bergen record. > ### Aliases: bergen.dm > ### Keywords: datasets > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "bergen.t2m.data" > > ### * bergen.t2m.data > > flush(stderr()); flush(stdout()) > > ### Name: bergen.t2m > ### Title: Monthly mean temperature in Bergen. > ### Aliases: bergen.t2m > ### Keywords: datasets > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "caldat" > > ### * caldat > > flush(stderr()); flush(stdout()) > > ### Name: caldat > ### Title: Converts Julian days to month, day, and year > ### Aliases: caldat > ### Keywords: manip > > ### ** Examples > > caldat(1) # month=1, day=2, year=-4713 > caldat(1721424) # 1, 1, 1 > caldat(2440588) # 1, 1, 1970 > caldat(2452887) # 9, 4, 2003 > > > > cleanEx(); ..nameEx <- "catFields" > > ### * catFields > > flush(stderr()); flush(stdout()) > > ### Name: catFields > ### Title: catFields > ### Aliases: catFields > ### Keywords: manip ts > > ### ** Examples > > ## Not run: > ##D library(clim.pact) > ##D x.1 <- retrieve.nc("/home/kareb/data/ncep/ncep_t2m.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D x.2 <- retrieve.nc("/home/kareb/data/ncep/ncep_slp.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D print(x.1$v.name) > ##D > ##D print("Read GCM predictor data.") > ##D X.1 <- retrieve.nc("data/mpi-gsdio_t2m.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D X.2 <- retrieve.nc("data/mpi-gsdio_slp.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D print(X.1$v.name) > ##D print("Cat fields.") > ##D xX.1 <- catFields(x.1,X.1,interval.1=c(1958,1998),interval.2=c(1958,2050)) > ##D xX.2 <- catFields(x.2,X.2,interval.1=c(1958,1998),interval.2=c(1958,2050)) > ##D xX <- mixFields(xX.1,xX.2,mon=1, > ##D interval=c(1900,2050)) > ##D print("EOF") > ##D eof.c <- eof(xX.1,mon=1) > ##D eof.mc <- eof(xX,mon=1) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "cdfcont" > > ### * cdfcont > > flush(stderr()); flush(stdout()) > > ### Name: cdfcont > ### Title: netCDF names and dimensions. > ### Aliases: cdfcont > ### Keywords: file > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "cdfextract" > > ### * cdfextract > > flush(stderr()); flush(stdout()) > > ### Name: cdfextract > ### Title: Extract a subfield from a netCDF file. > ### Aliases: cdfextract > ### Keywords: file > > ### ** Examples > > ## Not run: > ##D slp <- cdfextract("data/nmc_slp.nc","slp",x.rng=c(-80,40),y.rng=c(20,75), > ##D t.rng=c(times[is],times[is]+499),plot=FALSE) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "composite.field" > > ### * composite.field > > flush(stderr()); flush(stdout()) > > ### Name: composite.field > ### Title: Composite maps > ### Aliases: composite.field compositeField > ### Keywords: manip > > ### ** Examples > > ## Not run: > ##D slp <- retrieve.nc("ncep_slp.nc") > ##D data(oslo.t2m) > ##D composite.field(slp,oslo.t2m) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "corEOF" > > ### * corEOF > > flush(stderr()); flush(stdout()) > > ### Name: corEOF > ### Title: Field correlation > ### Aliases: field correlation, PCA corEOF > ### Keywords: manip > > ### ** Examples > > data(oslo.t2m) > data(eof.slp) > corEOF(eof.slp,oslo.t2m) > > > > cleanEx(); ..nameEx <- "corField" > > ### * corField > > flush(stderr()); flush(stdout()) > > ### Name: corField > ### Title: Field correlation > ### Aliases: field correlation corField > ### Keywords: manip > > ### ** Examples > > ## Not run: > ##D slp <- retrieve.nc("ncep_slp.nc") > ##D data(oslo.t2m) > ##D corField(slp,oslo.t2m) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "datestr2num" > > ### * datestr2num > > flush(stderr()); flush(stdout()) > > ### Name: datestr2num > ### Title: datestr2num > ### Aliases: datestr2num > ### Keywords: manip > > ### ** Examples > > datestr2num("01-Jan-1980") [1] 1980 1 1 > datestr2num("1-1-1980") [1] 1980 1 1 > datestr2num("01-01-1980") [1] 1980 1 1 > datestr2num("1980-1-1") [1] 1980 1 1 > datestr2num("1980-Jan-1") [1] 1980 1 1 > > > > cleanEx(); ..nameEx <- "delta" > > ### * delta > > flush(stderr()); flush(stdout()) > > ### Name: delta > ### Title: Delta function > ### Aliases: delta delta function > ### Keywords: manip > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "dist2norm" > > ### * dist2norm > > flush(stderr()); flush(stdout()) > > ### Name: dist2norm > ### Title: Transform a series to a normally distributed series. > ### Aliases: dist2norm norm2dist > ### Keywords: manip > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "distAB" > > ### * distAB > > flush(stderr()); flush(stdout()) > > ### Name: distAB > ### Title: Distance between two points on Earth > ### Aliases: distAB > ### Keywords: math > > ### ** Examples > > distAB(10,60,5,58) # [1] 362802.3 [1] 362802.3 > distAB(0,0,180,0) # [1] 20037078 [1] 20037078 > distAB(0,90,0,-90) # [1] 20037078 [1] 20037078 > > > > cleanEx(); ..nameEx <- "ds2station" > > ### * ds2station > > flush(stderr()); flush(stdout()) > > ### Name: ds2station > ### Title: Convert ds to station object > ### Aliases: ds2station > ### Keywords: manip > > ### ** Examples > > data(eof.c) > data(oslo.t2m) > ds <- DS(preds=eof.c, oslo.t2m,plot=FALSE) [1] "------------Match times---------------- " [1] "Number of coinciding obs: 41 , 41" Min. 1st Qu. Median Mean 3rd Qu. Max. 1890 1917 1945 1945 1972 1999 Min. 1st Qu. Median Mean 3rd Qu. Max. 1958 1968 1978 1978 1988 1998 [1] "Common times:" [1] 1958 1998 [1] -10.5 2.3 [1] "de-trend:" [1] "stepwise regression:" [1] "Model: lm(y ~ 1 + X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8,data=calibrate)" [1] "Stepwise: step(lm.mod,trace=0)" [1] "ANOVA from step-wise regression:" Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found [1] "Downscaled anomalies:" Min. 1st Qu. Median Mean 3rd Qu. Max. -8.1170 -0.8163 1.3830 0.9804 3.3510 7.1010 Call: lm(formula = y ~ 1 + X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8, data = calibrate) Residuals: Min 1Q Median 3Q Max -1.743730 -0.609466 -0.001638 0.441441 1.772895 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -1.149e-16 1.388e-01 -8.28e-16 1.00000 X1 -6.474e-01 6.196e-02 -10.450 7.65e-12 *** X2 1.975e-01 6.704e-02 2.946 0.00596 ** X3 -1.780e-01 5.843e-02 -3.046 0.00461 ** X4 -3.304e-01 1.290e-01 -2.562 0.01533 * X5 7.862e-01 1.414e-01 5.558 3.91e-06 *** X6 -3.885e-01 1.550e-01 -2.507 0.01747 * X7 3.713e-01 2.143e-01 1.732 0.09281 . X8 -5.291e-01 1.628e-01 -3.250 0.00272 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.8888 on 32 degrees of freedom Multiple R-Squared: 0.9321, Adjusted R-squared: 0.9151 F-statistic: 54.89 on 8 and 32 DF, p-value: < 2.2e-16 [1] "Reconstruct the spatial patterns" (Intercept) X1 X2 X3 X4 X5 X6 X7 X8 -1.148844e-16 -6.474137e-01 1.975162e-01 -1.779968e-01 -3.304492e-01 7.861880e-01 -3.885482e-01 3.712968e-01 -5.291496e-01 [1] "Linear trend for GCM (deg C/decade)" [1] "Slope and its uncertainty" [1] 0.63 0.12 [1] "P-value of fit= 0" [1] "P-value of trend-fit for downscaled scenario 0" [1] "Dignosis:" [1] "output/" [1] "mpi+ncep" [1] "60W40E-52N75N" [1] "Oslo" [1] 101 [1] "Jan" [1] "mon" [1] "lm" [1] "File name: output/ds_mpi+ncep_60W40E-52N75N_Oslo_101_Jan_mon_lm.Rdata" > oslo.dm <- ds2station(ds) > plotStation(oslo.dm) Warning in predict.lm(lm.tr.p, newdata = X) : prediction from a rank-deficient fit may be misleading > > > > cleanEx(); ..nameEx <- "eof.c.data" > > ### * eof.c.data > > flush(stderr()); flush(stdout()) > > ### Name: eof.c > ### Title: Monthly common EOF. > ### Aliases: eof.c eof.c_data > ### Keywords: datasets > > ### ** Examples > > library(clim.pact) > data(eof.c) > > > > cleanEx(); ..nameEx <- "eof.dc.data" > > ### * eof.dc.data > > flush(stderr()); flush(stdout()) > > ### Name: eof.dc > ### Title: Daily common EOF. > ### Aliases: eof.dc eof.dc_data > ### Keywords: datasets > > ### ** Examples > > #The EOFs were produced using the following code: > library(clim.pact) > ## Not run: > ##D x.1.dm<-retrieve.nc("/data1/era15/ERA-15_t2m.nc",x.rng=c(5,25),y.rng=c(58,65)) > ##D X.1.dm<-retrieve.nc("/data1/hirham/T2M_198001-199912.nc",x.rng=c(5,25), > ##D y.rng=c(58,65)) > ##D Y.1.dm<-retrieve.nc("/data1/hirham/T2M_203001-204912.nc",x.rng=c(5,25), > ##D y.rng=c(58,65)) > ##D Y.1.dm$yy <- Y.1.dm$yy + 50 > ##D # It is important that demean=FALSE when concatinating the two time slices > ##D # from the model simulations, if a study of climate change is the objective. > ##D xX.1.dm <- catFields(X.1.dm,Y.1.dm,demean=FALSE) > ##D xX.1.dm <- catFields(x.1.dm,xX.1.dm) > ##D eof.dc <- eof(xX.1.dm,mon=1) > ## End(Not run) > # To read the data: > data(eof.dc) > > > > cleanEx(); ..nameEx <- "eof.dmc.data" > > ### * eof.dmc.data > > flush(stderr()); flush(stdout()) > > ### Name: eof.dmc > ### Title: Daily common EOF. > ### Aliases: eof.dmc eof.dmc_data > ### Keywords: datasets > > ### ** Examples > > library(clim.pact) > ## Not run: > ##D x.1.dm<-retrieve.nc("/data1/era15/ERA-15_t2m.nc",x.rng=c(5,25),y.rng=c(58,65)) > ##D X.1.dm<-retrieve.nc("/data1/hirham/T2M_198001-199912.nc",x.rng=c(5,25), > ##D y.rng=c(58,65)) > ##D Y.1.dm<-retrieve.nc("/data1/hirham/T2M_203001-204912.nc",x.rng=c(5,25), > ##D y.rng=c(58,65)) > ##D Y.1.dm$yy <- Y.1.dm$yy + 50 > ##D # It is important that demean=FALSE when concatinating the two time slices > ##D # from the model simulations, if a study of climate change is the objective. > ##D xX.1.dm <- catFields(X.1.dm,Y.1.dm,demean=FALSE) > ##D xX.1.dm <- catFields(x.1.dm,xX.1.dm) > ##D x.2.dm<-retrieve.nc("/data1/era15/ERA-15_slp.nc",x.rng=c(5,25),y.rng=c(58,65)) > ##D X.2.dm<-retrieve.nc("/data1/hirham/PSL_198001-199912.nc",x.rng=c(5,25), > ##D y.rng=c(58,65)) > ##D Y.2.dm<-retrieve.nc("/data1/hirham/PSL_203001-204912.nc",x.rng=c(5,25), > ##D y.rng=c(58,65)) > ##D Y.2.dm$yy <- Y.2.dm$yy + 50 > ##D # It is important that demean=FALSE when concatinating the two time slices > ##D # from the model simulations, if a study of climate change is the objective. > ##D xX.2.dm <- catFields(X.2.dm,Y.2.dm,demean=FALSE) > ##D xX.2.dm <- catFields(x.2.dm,xX.2.dm) > ##D > ##D xX.dm <- mix.fields(xX.1.dm,xX.2.dm,mon=1) > ##D eof.dmc <- eof(xX.dm,mon=1) > ## End(Not run) > # To read the data: > data(eof.dmc) > > > > cleanEx(); ..nameEx <- "eof.mc.data" > > ### * eof.mc.data > > flush(stderr()); flush(stdout()) > > ### Name: eof.mc > ### Title: Monthly mixed-common EOF. > ### Aliases: eof.mc eof.mc_data > ### Keywords: datasets > > ### ** Examples > > library(clim.pact) > data(eof.mc) > > > > cleanEx(); ..nameEx <- "eof.slp.data" > > ### * eof.slp.data > > flush(stderr()); flush(stdout()) > > ### Name: eof.slp > ### Title: EOF of NCEP reanalysis SLP. > ### Aliases: eof.slp > ### Keywords: datasets > > ### ** Examples > > library(clim.pact) > data(eof.slp) > > > > cleanEx(); ..nameEx <- "getdnmi" > > ### * getdnmi > > flush(stderr()); flush(stdout()) > > ### Name: getdnmi > ### Title: Retrieve station record from DNMI database filed. > ### Aliases: getdnmi > ### Keywords: file > > ### ** Examples > > ## Not run: > ##D oslo.t2m.dnmi <- getdnmi("oslo") > ##D ferder.t2m.dnmi <- getdnmi("ferder") > ## End(Not run) > > > > cleanEx(); ..nameEx <- "getgiss" > > ### * getgiss > > flush(stderr()); flush(stdout()) > > ### Name: getgiss > ### Title: Retrieve station record from the GISS data set from URL. > ### Aliases: getgiss > ### Keywords: file > > ### ** Examples > > ## Not run: > ##D obs.oxford <- getgiss(location="Oxford") # Takes longer time > ##D stations <- getgiss() > ##D obs.oxford <- getgiss(location="Oxford",stations=stations) #Quicker > ##D plotStation(obs.oxford) > ##D obs.broome <- getgiss(stnr="501942030004",stations=stations) > ##D obs.120E.40S <- getgiss(lon=120,lat=-40,stations=stations) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "getnacd" > > ### * getnacd > > flush(stderr()); flush(stdout()) > > ### Name: getnacd > ### Title: Retreave station record from the NACD set. > ### Aliases: getnacd nacd.meta meta.nacd > ### Keywords: file > > ### ** Examples > > ## Not run: > ##D helsinki.rr <- getnacd("helsinki",ele=601) > ##D obs.t2m <- getnacd() > ## End(Not run) > > > > cleanEx(); ..nameEx <- "getnordklim" > > ### * getnordklim > > flush(stderr()); flush(stdout()) > > ### Name: getnordklim > ### Title: Retrieve station record from the Nordklima set. > ### Aliases: getnordklim meta > ### Keywords: file > > ### ** Examples > > ## Not run: > ##D helsinki.rr <- getnordklim("helsinki",ele=601) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "grd.box.ts" > > ### * grd.box.ts > > flush(stderr()); flush(stdout()) > > ### Name: grd.box.ts > ### Title: Grid box time series > ### Aliases: grd.box.ts > ### Keywords: ts > > ### ** Examples > > ## Not run: > ##D slp <- retrieve.nc("ncep_slp.nc") > ##D grd.box.ts(slp,0,60,what="ano",mon=1) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "helsinki.t2.data" > > ### * helsinki.t2.data > > flush(stderr()); flush(stdout()) > > ### Name: helsinki.t2m > ### Title: Monthly mean temperature in Helsinki. > ### Aliases: helsinki.t2m > ### Keywords: datasets > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "instring" > > ### * instring > > flush(stderr()); flush(stdout()) > > ### Name: instring > ### Title: instring > ### Aliases: instring > ### Keywords: character > > ### ** Examples > > instring("e","efile.dat") [1] 1 5 > # 1 5 > regexpr("e","efile.dat") [1] 1 attr(,"match.length") [1] 1 > #[1] 1 > #attr(,"match.length") > #[1] 1 > # Case when regexpr() doesn't give the desired result: > regexpr(".","file.name") [1] 1 attr(,"match.length") [1] 1 > #[1] 1 > #attr(,"match.length") > #[1] 1 > instring(".","file.name") [1] 5 > #[1] 5 > > > > cleanEx(); ..nameEx <- "julday" > > ### * julday > > flush(stderr()); flush(stdout()) > > ### Name: julday > ### Title: Converts from month, day, and year to Julian days > ### Aliases: julday > ### Keywords: manip > > ### ** Examples > > julday(1,1,1) # 1721424 > julday(1,1,1970) # 2440588 > julday(9,4,2003) # 2452887 > julday(9,4,2003)-julday(1,1,1970) # 12299 [1] 12299 > julday(9,4,2003)-julday(1,1,2003) # 246 [1] 246 > julday(1,1,2003)-julday(1,1,2002) # 365 [1] 365 > julday(1,1,2001)-julday(1,1,2000) # 366 [1] 366 > > > > cleanEx(); ..nameEx <- "km2lat" > > ### * km2lat > > flush(stderr()); flush(stdout()) > > ### Name: km2lat > ### Title: Convert long-lat to km-km > ### Aliases: km2lat > ### Keywords: manip > > ### ** Examples > > library(clim.pact) > data(oslo.t2m) > print(c(oslo.t2m$lon,oslo.t2m$lat)) [1] 10.71667 59.95000 > #[1] 10.71667 59.95000 > xy<-COn0E65N(oslo.t2m$lon,oslo.t2m$lat) > oslo.t2m$lon<-xy$x > oslo.t2m$lat<-xy$y > print(c(oslo.t2m$lon,oslo.t2m$lat)) [1] 595.4086 -560.3004 > #[1] 595.4086 -560.3004 > lon<-km2lon(oslo.t2m$lon,oslo.t2m$lat,x.centre=0,y.centre=65) > lat<-km2lat(oslo.t2m$lon,oslo.t2m$lat,x.centre=0,y.centre=65) > print(c(lon,lat)) [1] 10.71667 59.95000 > #[1] 10.71667 59.95000 > > > > cleanEx(); ..nameEx <- "km2lon" > > ### * km2lon > > flush(stderr()); flush(stdout()) > > ### Name: km2lon > ### Title: Convert long-lat to km-km > ### Aliases: km2lon > ### Keywords: manip > > ### ** Examples > > library(clim.pact) > data(oslo.t2m) > print(c(oslo.t2m$lon,oslo.t2m$lat)) [1] 10.71667 59.95000 > #[1] 10.71667 59.95000 > xy<-COn0E65N(oslo.t2m$lon,oslo.t2m$lat) > oslo.t2m$lon<-xy$x > oslo.t2m$lat<-xy$y > print(c(oslo.t2m$lon,oslo.t2m$lat)) [1] 595.4086 -560.3004 > #[1] 595.4086 -560.3004 > lon<-km2lon(oslo.t2m$lon,oslo.t2m$lat,x.centre=0,y.centre=65) > lat<-km2lat(oslo.t2m$lon,oslo.t2m$lat,x.centre=0,y.centre=65) > print(c(lon,lat)) [1] 10.71667 59.95000 > #[1] 10.71667 59.95000 > > > > cleanEx(); ..nameEx <- "koebenhavn.t2m.data" > > ### * koebenhavn.t2m.data > > flush(stderr()); flush(stdout()) > > ### Name: koebenhavn.t2m > ### Title: Monthly mean temperature in Copenhagen. > ### Aliases: koebenhavn.t2m > ### Keywords: datasets > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "lagStation" > > ### * lagStation > > flush(stderr()); flush(stdout()) > > ### Name: lagStation > ### Title: Introduce a lag in station values > ### Aliases: lagStation > ### Keywords: manip > > ### ** Examples > > data(oslo.t2m) > oslo.t2m.1 <- lagStation(oslo.t2m,1) > plotStation(oslo.t2m,mon=1,what="t") Warning in predict.lm(lm.tr.p, newdata = X) : prediction from a rank-deficient fit may be misleading > plotStation(oslo.t2m.1,add=TRUE,mon=1,what="t",col="darkblue") Warning in predict.lm(lm.tr.p, newdata = X) : prediction from a rank-deficient fit may be misleading > > > > cleanEx(); ..nameEx <- "lower.case" > > ### * lower.case > > flush(stderr()); flush(stdout()) > > ### Name: lower.case > ### Title: convert to lower case > ### Aliases: lower.case > ### Keywords: character > > ### ** Examples > > print(upper.case(c("qwerty e","asdf rT"))) # "QWERTY" "ASDF" [1] "QWERTY E" "ASDF RT" > print(lower.case(c("QWERTY","ASDF"))) # "qwErty" "asdf" [1] "qwerty" "asdf" > print(strip(c("Hello there!","Oslo"," ","NA "))) # "Hello" "Oslo" " " "NA" [1] "Hello" "Oslo" " " "NA" > > > > cleanEx(); ..nameEx <- "map" > > ### * map > > flush(stderr()); flush(stdout()) > > ### Name: map > ### Title: Produce a map > ### Aliases: map > ### Keywords: hplot > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "map.eof" > > ### * map.eof > > flush(stderr()); flush(stdout()) > > ### Name: map.eof > ### Title: Map eof > ### Aliases: map.eof mapEOF > ### Keywords: hplot > > ### ** Examples > > library(clim.pact) > data(eof.slp) > map.eof(eof.slp) > map.eof(eof.slp,i.eof=2,col="blue",add=TRUE) > > > > cleanEx(); ..nameEx <- "mapField" > > ### * mapField > > flush(stderr()); flush(stdout()) > > ### Name: mapField > ### Title: MapField > ### Aliases: mapField > ### Keywords: hplot > > ### ** Examples > > library(clim.pact) > ## Not run: > ##D skt<-retrieve.nc("skt.mon.mean.nc", > ##D x.rng=c(-90,50),y.rng=c(0,75)) > ##D bitmap("ncep.skt.jpg",type="jpeg") > ##D mapField(skt) > ##D dev.off() > ## End(Not run) > > > > cleanEx(); ..nameEx <- "meanField" > > ### * meanField > > flush(stderr()); flush(stdout()) > > ### Name: meanField > ### Title: Mean field > ### Aliases: meanField > ### Keywords: manip > > ### ** Examples > > ## Not run: > ##D slp <- retrieve.nc("ncep_slp.nc",x.rng=c(5,12),y.rng=c(58,63)) > ##D mslp <- meanField(slp) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "mergeEOF" > > ### * mergeEOF > > flush(stderr()); flush(stdout()) > > ### Name: mergeEOF > ### Title: Merge EOFs > ### Aliases: mergeEOF > ### Keywords: manip > > ### ** Examples > > ## Not run: > ##D data(DNMI.slp) > ##D NCEP.slp<-retrieve.nc("~/data/ncep/slp.mon.mean.nc", > ##D x.rng=c(-90,50),y.rng=c(0,75)) > ##D > ##D #-------------------------------------------------- > ##D # Need to fix some details of the NCEP.slp object (only for > ##D # proper 'housekeeping') > ##D > ##D NCEP.slp$dd[] <- 15 > ##D attr(NCEP.slp$tim,unit') <- "month" > ##D class(NCEP.slp) <- c("field","monthly.field.object") > ##D #--------------------------------------------------- > ##D > ##D eof1 <- EOF(DNMI.slp,mon=1) > ##D eof2 <- EOF(NCEP.slp,mon=1) > ##D eof <- mergeEOF(eof1,eof2) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "mergeStation" > > ### * mergeStation > > flush(stderr()); flush(stdout()) > > ### Name: mergeStation > ### Title: Merge climate station series. > ### Aliases: mergeStation > ### Keywords: manip > > ### ** Examples > > ## Not run: > ##D oslo.1 <- getnacd("OSLO-BLINDERN") > ##D oslo.2 <- getdnmi("oslo") > ##D print(range(oslo.1$yy)) > ##D #[1] 1890 1990 > ##D print(range(oslo.2$yy)) > ##D #[1] 1937 2002 > ##D oslo <- mergeStation(oslo.1,oslo.2) > ##D #[1] "Time intervals:" > ##D #[1] 1890 1990 > ##D #[1] 1937 2002 > ##D #[1] 1937.042 1990.958 > ##D #[1] "RMSE: 0.04" > ##D # > ##D #Call: > ##D #lm(formula = y ~ 1 + x, data = ovrlp) > ##D # > ##D #Residuals: > ##D # Min 1Q Median 3Q Max > ##D #-7.24005 -0.03271 0.01161 0.06006 7.61593 > ##D #Coefficients: > ##D # Estimate Std. Error t value Pr(>|t|) > ##D #(Intercept) 0.029044 0.047482 0.612 0.541 > ##D #x 0.993886 0.004866 204.231 <2e-16 *** > ##D #--- > ##D #Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1 > ##D # > ##D #Residual standard error: 0.9738 on 644 degrees of freedom > ##D #Multiple R-Squared: 0.9848, Adjusted R-squared: 0.9848 > ##D #F-statistic: 4.171e+04 on 1 and 644 DF, p-value: < 2.2e-16 > ##D > ##D print(range(oslo$yy)) > ##D #[1] 1890 2002 > ## End(Not run) > > > > cleanEx(); ..nameEx <- "mixFields" > > ### * mixFields > > flush(stderr()); flush(stdout()) > > ### Name: mixFields > ### Title: mixFields > ### Aliases: mixFields > ### Keywords: models > > ### ** Examples > > ## Not run: > ##D library(clim.pact) > ##D x.1 <- retrieve.nc("/home/kareb/data/ncep/ncep_t2m.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D x.2 <- retrieve.nc("/home/kareb/data/ncep/ncep_slp.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D print(x.1$v.name) > ##D > ##D print("Read GCM predictor data.") > ##D X.1 <- retrieve.nc("data/mpi-gsdio_t2m.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D X.2 <- retrieve.nc("data/mpi-gsdio_slp.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D print(X.1$v.name) > ##D print("Cat fields.") > ##D xX.1 <- catFields(x.1,X.1,interval.1=c(1958,1998),interval.2=c(1958,2050)) > ##D xX.2 <- catFields(x.2,X.2,interval.1=c(1958,1998),interval.2=c(1958,2050)) > ##D xX <- mixFields(xX.1,xX.2,mon=1, > ##D interval=c(1900,2050)) > ##D print("EOF") > ##D eof.c <- eof(xX.1,mon=1) > ##D eof.mc <- eof(xX,mon=1) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "mod" > > ### * mod > > flush(stderr()); flush(stdout()) > > ### Name: mod > ### Title: Modulus of a division. > ### Aliases: mod > ### Keywords: arith > > ### ** Examples > > mod(101,10) # 1 [1] 1 > mod(4,12) # 4 [1] 4 > mod(123,12) # 3 [1] 3 > > > > cleanEx(); ..nameEx <- "newFig" > > ### * newFig > > flush(stderr()); flush(stdout()) > > ### Name: newFig > ### Title: Create a new Window > ### Aliases: newFig > ### Keywords: device > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "num2str" > > ### * num2str > > flush(stderr()); flush(stdout()) > > ### Name: num2str > ### Title: Convert numbers to string and format > ### Aliases: num2str strings characters > ### Keywords: character > > ### ** Examples > > print(num2str(c(1,23.4282,-3.14),dec=3)) [1] "1.000" "23.428" "-3.140" > #[1] "1.000" "23.428" "-3.140" > > > > cleanEx(); ..nameEx <- "objDS" > > ### * objDS > > flush(stderr()); flush(stdout()) > > ### Name: objDS > ### Title: Objective downscaling of monthly means > ### Aliases: climate analysis objDS downscaling > ### Keywords: models multivariate ts spatial > > ### ** Examples > > ## Not run: > ##D library(clim.pact) > ##D oslo<-getnordklim("Oslo-Blindern") > ##D slp.obs <- retrieve.nc("ncep_slp.nc") # Get gridded observations/analysis from NCEP > ##D slp.gcm <- retrieve.nc("EH4OPYC_B2_slp.nc") # Get results from climate models > ##D ds <- objDS(field.obs=slp.obs,field.gcm=slp.gcm,station=oslo) > ##D > ##D t2m <- retrieve.nc("~/data/analysis/DNMI_t2m.nc") > ##D t2m.gcm <- retrieve.nc("~/data/mpi/mpi-gsdio_t2m.nc", > ##D x.rng=range(t2m$lon),y.rng=range(t2m$lat)) > ##D ds <- objDS(field.obs=t2m,field.gcm=t2m.gcm,station=oslo) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "oslo.dm.data" > > ### * oslo.dm.data > > flush(stderr()); flush(stdout()) > > ### Name: oslo.dm > ### Title: Daily Oslo record. > ### Aliases: oslo.dm > ### Keywords: datasets > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "oslo.t2m.data" > > ### * oslo.t2m.data > > flush(stderr()); flush(stdout()) > > ### Name: oslo.t2m > ### Title: Monthly mean temperature in Oslo. > ### Aliases: oslo.t2m > ### Keywords: datasets > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "patternIndex" > > ### * patternIndex > > flush(stderr()); flush(stdout()) > > ### Name: patternIndex > ### Title: Create a Index for a spatial pattern > ### Aliases: patternIndex > ### Keywords: manip > > ### ** Examples > > ## Not run: > ##D sst <- retrieve.nc("DNMI_sst.nc") > ##D data(oslo.t2m) > ##D csst <- composite.field(sst,oslo.t2m) > ##D patternIndex(csst,sst,anomaly=FALSE) > ##D > ##D lsst<-mapField(sst) > ##D patternIndex(lsst,sst) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "plot.station" > > ### * plot.station > > flush(stderr()); flush(stdout()) > > ### Name: plotStation > ### Title: Plots monthly station records. > ### Aliases: plotStation > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D data(tromsoe.t2m) > ##D plotStation(tromsoe.t2m) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "plotDS" > > ### * plotDS > > flush(stderr()); flush(stdout()) > > ### Name: plotDS > ### Title: Plot downscaled results > ### Aliases: plotDS > ### Keywords: hplot > > ### ** Examples > > data(helsinki.t2m) > data(eof.mc) > ds.helsinki<-DS(dat=helsinki.t2m,preds=eof.mc,plot=FALSE) Warning in if (instring("-", preds.names[i.pred]) > 0) { : the condition has length > 1 and only the first element will be used Warning in if (instring("_", preds.names[i.pred]) > 0) { : the condition has length > 1 and only the first element will be used [1] "------------Match times---------------- " [1] "Number of coinciding obs: 41 , 41" Min. 1st Qu. Median Mean 3rd Qu. Max. 1890 1917 1945 1945 1972 1999 Min. 1st Qu. Median Mean 3rd Qu. Max. 1958 1968 1978 1978 1988 1998 [1] "Common times:" [1] 1958 1998 [1] -16.5 0.5 [1] "de-trend:" [1] "stepwise regression:" [1] "Model: lm(y ~ 1 + X1 + X2 + X3 + X4 + X5 + X6 + X7 + X8,data=calibrate)" [1] "Stepwise: step(lm.mod,trace=0)" [1] "ANOVA from step-wise regression:" Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found Warning: remove: variable "XNA" was not found [1] "Downscaled anomalies:" Min. 1st Qu. Median Mean 3rd Qu. Max. -13.92000 -3.83000 0.61600 0.04211 3.72600 9.83300 Call: lm(formula = y ~ X1 + X2 + X3 + X4 + X5 + X7 + X8, data = calibrate) Residuals: Min 1Q Median 3Q Max -2.24341 -0.80229 -0.08778 0.68884 2.12472 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 3.732e-16 1.718e-01 2.17e-15 1.0000 X1 3.679e-01 2.241e-02 16.417 < 2e-16 *** X2 -2.025e-01 3.607e-02 -5.616 2.99e-06 *** X3 1.696e-01 2.980e-02 5.693 2.39e-06 *** X4 -7.219e-01 5.686e-02 -12.696 3.00e-14 *** X5 4.928e-01 5.456e-02 9.033 1.94e-10 *** X7 -2.444e-01 9.484e-02 -2.577 0.0146 * X8 -2.120e-01 1.029e-01 -2.060 0.0473 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.1 on 33 degrees of freedom Multiple R-Squared: 0.9368, Adjusted R-squared: 0.9234 F-statistic: 69.9 on 7 and 33 DF, p-value: < 2.2e-16 [1] "Reconstruct the spatial patterns" (Intercept) X1 X2 X3 X4 X5 X7 X8 3.732283e-16 3.678761e-01 -2.025414e-01 1.696427e-01 -7.219002e-01 4.928118e-01 -2.444282e-01 -2.119595e-01 [1] "Linear trend for GCM (deg C/decade)" [1] "Slope and its uncertainty" [1] 0.95 0.17 [1] "P-value of fit= 0" [1] "P-value of trend-fit for downscaled scenario 0" [1] "Dignosis:" [1] "output/" [1] "mpi+ncep" [1] "60W40E-52N75N" [1] "Helsinki" [1] 101 [1] "Jan" [1] "mon" [1] "lm" [1] "File name: output/ds_mpi+ncep_60W40E-52N75N_Helsinki_101_Jan_mon_lm.Rdata" > plotDS(ds.helsinki,leps=TRUE) Warning: unimplemented pch value '26' > > > > cleanEx(); ..nameEx <- "plotDSobj" > > ### * plotDSobj > > flush(stderr()); flush(stdout()) > > ### Name: plotDSobj > ### Title: Plotting routine for objective downscaling of monthly means > ### Aliases: climate diagnostics plotDSobj > ### Keywords: models multivariate ts spatial > > ### ** Examples > > ## Not run: > ##D library(clim.pact) > ##D source("clim.pact/R/ds.R") > ##D source("clim.pact/R/objDS.R") > ##D source("clim.pact/R/catFields.R") > ##D source("clim.pact/R/eof.R") > ##D oslo<-getnordklim("Oslo-Blindern") > ##D t2m <- retrieve.nc("~/data/analysis/DNMI_t2m.nc") > ##D t2m.gcm <- retrieve.nc("~/data/mpi/mpi-gsdio_t2m.nc", > ##D x.rng=range(t2m$lon),y.rng=range(t2m$lat)) > ##D ds <- objDS(field.obs=t2m,field.gcm=t2m.gcm,station=oslo,lsave=FALSE,plot=FALSE) > ##D plotDSobj(result) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "plotEOF" > > ### * plotEOF > > flush(stderr()); flush(stdout()) > > ### Name: plotEOF > ### Title: Plot EOFs > ### Aliases: plotEOF > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D data(eof.mc) > ##D plotEOF(eof.mc) > ##D x11() > ##D data(eof.dmc) > ##D plotEOF(eof.dmc) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "plotField" > > ### * plotField > > flush(stderr()); flush(stdout()) > > ### Name: plotField > ### Title: plotField > ### Aliases: plotField > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D skt <- retrieve.nc("skt.mon.mean.nc",x.rng=c(-90,50),y.rng=c(0,75)) > ##D > ##D # Maps of monthly mean skin temperatures: > ##D plotField(skt,tim=1,val.rng=c(-20,20)) > ##D dev2bitmap("ncep.skt_194801.jpg",type="jpeg") > ##D > ##D plotField(skt,tim=100,col="blue",col.coast="darkgreen",val.rng=c(-10,10)) > ##D > ##D # For adding extra points/contours: > ##D > ##D # From filled.contour in base > ##D mar.orig <- (par.orig <- par(c("mar","las","mfrow")))$mar > ##D on.exit(par(par.orig)) > ##D > ##D w <- (3 + mar.orig[2]) * par('csi') * 2.54 > ##D layout(matrix(c(2, 1), nc=2), widths=c(1, lcm(w))) > ##D > ##D par(las = 1) > ##D mar <- mar.orig > ##D mar[4] <- 1 > ##D par(mar=mar) > ##D # End of section affecting the window set up. > ##D > ##D points(0,50,pch=21,col="red") > ##D grid() > ##D dev2bitmap("ncep.skt_195604.jpg",type="jpeg") > ##D > ##D # A hovmuller diagram: > ##D plotField(skt,lon=0,val.rng=c(-10,10)) > ##D dev2bitmap("ncep.skt_lontim.jpg",type="jpeg") > ##D > ##D # A single time series: > ##D plotField(skt,lon=-20,lat=50) > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "plumePlot" > > ### * plumePlot > > flush(stderr()); flush(stdout()) > > ### Name: plumePlot > ### Title: Plot downscaled time series as plumes > ### Aliases: plumePlot > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D ds.list<-avail.ds() > ##D plumePlot(ds.list,location="OSLO-BLINDERN",mon=1) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "r2cdf" > > ### * r2cdf > > flush(stderr()); flush(stdout()) > > ### Name: r2cdf > ### Title: Save as netCDF file. > ### Aliases: r2cdf > ### Keywords: file > > ### ** Examples > > ## Not run: > ##D # Save EOFs as netCDF (use ncview or Ferret to view) > ##D data(eof.slp) > ##D r2cdf("test.nc",eof.slp) > ##D # > ##D # > ##D slp <- retrieve.nc("data/DNMI_slp.nc") > ##D mslp <- meanField(slp) > ##D r2cdf("test.nc",mslp) > ##D r2cdf("test.nc",slp) > ##D # > ##D slp <- cdfextract("data/nmc_slp.nc","slp",x.rng=c(-80,40),y.rng=c(20,75), > ##D t.rng=c(times[is],times[is]+499),plot=FALSE) > ##D r2cdf("test.nc",slp) > ##D # > ##D data(oslo.t2m) > ##D map <- composite.field(slp,oslo.t2m) > ##D r2cdf("test.nc",map) > ##D # > ##D Xdum=list(dat=slp$dat[1:10,,],lon=slp$lon,lat=slp$lat,tim=slp$tim[1:10], > ##D lev=NULL,v.name=slp$v.name,attributes=slp$attributes) > ##D class(Xdum)="field" > ##D r2cdf("test.nc",Xdum) > ##D # > ##D # The definition of a 'field' object is: > ##D ny<-length(slp$lat); nx<-length(slp$lon) > ##D slp <- list(dat=slp$dat,lon=slp$lon,lat=slp$lat,tim=slp$tim,lev=slp$lev, > ##D v.name=slp$v.nam,id.x=slp$id.x,id.t=slp$id.t, > ##D yy=slp$yy,mm=slp$mm,dd=slp$dd,n.fld=1, > ##D id.lon=rep(slp$v.name,nx),id.lat=rep(slp$v.name,ny), > ##D attributes=dat.att) > ##D class(slp) <- c("field") > ##D > ## End(Not run) > > > > cleanEx(); ..nameEx <- "retrieve.nc" > > ### * retrieve.nc > > flush(stderr()); flush(stdout()) > > ### Name: retrieve.nc > ### Title: Retrieve data from a netCDF file > ### Aliases: retrieve.nc field.object fixField monthly > ### Keywords: file > > ### ** Examples > > ## Not run: > ##D X.1 <- retrieve.nc("data/mpi-gsdio_t2m.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D X.2 <- retrieve.nc("data/mpi-gsdio_slp.nc", > ##D x.rng=c(-60,40),y.rng=c(50,75)) > ##D > ##D # The definition of a 'field' object is: > ##D ny<-length(slp$lat); nx<-length(slp$lon) > ##D slp <- list(dat=X.2$dat,lon=X.2$lon,lat=X.2$lat,tim=X.2$tim,lev=X.2$lev, > ##D v.name=X.2$v.nam,id.x=X.2$id.x,id.t=X.2$id.t, > ##D yy=X.2$yy,mm=X.2$mm,dd=X.2$dd,n.fld=1, > ##D id.lon=rep(X.2$v.name,nx),id.lat=rep(X.2$v.name,ny), > ##D attributes=dat.att) > ##D class(slp) <- c("field") > ##D > ##D # For reading the IPCC FoAR netCDF files that uses a 365-day year (no leap years) and starts on time count year 0: > ##D gcm <- retrieve.nc(fname,v.nam="tas",x.rng=c(-50,50),y.rng=c(30,75),forceBC=FALSE) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "reverse" > > ### * reverse > > flush(stderr()); flush(stdout()) > > ### Name: reverse > ### Title: Reverse > ### Aliases: reverse reverse.sort > ### Keywords: manip > > ### ** Examples > > reverse(c(1,3,5,7,2,4,6,8)) # 8 6 4 2 7 5 3 1 [1] 8 6 4 2 7 5 3 1 > reverse.sort(c(1,3,5,7,2,4,6,8)) # 8 7 6 5 4 3 2 1 [1] 8 7 6 5 4 3 2 1 > > > > cleanEx(); ..nameEx <- "rotate" > > ### * rotate > > flush(stderr()); flush(stdout()) > > ### Name: rotate > ### Title: Rotate spherical coordinates > ### Aliases: rotate > ### Keywords: manip > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "satellite" > > ### * satellite > > flush(stderr()); flush(stdout()) > > ### Name: satellite > ### Title: Satellite view / polar stereographic > ### Aliases: polar stereographic satellite > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D x <- retrieve.nc("T2M_p.nc") > ##D a <- mapField(x) > ##D satellite(a) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "station.obj" > > ### * station.obj > > flush(stderr()); flush(stdout()) > > ### Name: station.obj > ### Title: Make monthly climate station series object. > ### Aliases: station.obj ele monthly.station.record > ### Keywords: data > > ### ** Examples > > ## Not run: > ##D a <- read.table("data/bjornholt.dat", > ##D col.names=c("station","year","month","rr", > ##D "tam","sam","sdm","uum","pom","tax","tan")) > ##D obs <- station.obj(x=a$rr,yy=a$year,mm=a$month, > ##D obs.name="Precipitation",unit="mm",ele=601, > ##D lat=60.03,lon=10.41,alt=360, > ##D station=a$station[1],location="Bjornholt", > ##D country="Norway",ref="met.no Climate data base") > ##D plot(obs,mon=11) > ## End(Not run) > > > > cleanEx(); ..nameEx <- "station.obj.dm" > > ### * station.obj.dm > > flush(stderr()); flush(stdout()) > > ### Name: station.obj.dm > ### Title: Make daily climate station series object. > ### Aliases: station.obj.dm daily.station.record > ### Keywords: data > > ### ** Examples > > ## Not run: > ##D blindern.raw <-read.table("~/data/stations/blindern_rr_day.dat",header=TRUE) > ##D blindern.raw$rr[blindern.raw$rr < 0] <- NA > ##D yy <- floor(blindern.raw$yyyymmdd/10000) > ##D mm <- floor(blindern.raw$yyyymmdd/100) - 10000*yy > ##D dd <- blindern.raw$yyyymmdd - 100*mm - 10000*yy > ##D blindern <- station.obj.dm(t2m=rep(NA,length(blindern.raw$rr)), > ##D precip=blindern.raw$rr, > ##D dd=dd,mm=mm,yy=yy, > ##D obs.name=c("T(2m)","recip"), > ##D unit=c("deg C","mm/day"),ele=NULL, > ##D station=18700,lat=59.95,lon=10.71,alt=94, > ##D location="Oslo-Blindern",wmo.no=NULL, > ##D start=NULL,yy0=1937,country="Norway", > ##D ref="www.met.no") > ## End(Not run) > > > > cleanEx(); ..nameEx <- "stationmap" > > ### * stationmap > > flush(stderr()); flush(stdout()) > > ### Name: stationmap > ### Title: Plot climate station map. > ### Aliases: stationmap > ### Keywords: hplot > > ### ** Examples > > ## Not run: > ##D stationmap() > ## End(Not run) > > > > cleanEx(); ..nameEx <- "stockholm.t2m.data" > > ### * stockholm.t2m.data > > flush(stderr()); flush(stdout()) > > ### Name: stockholm.t2m > ### Title: Monthly mean temperature in Stockholm. > ### Aliases: stockholm.t2m > ### Keywords: datasets > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "strip" > > ### * strip > > flush(stderr()); flush(stdout()) > > ### Name: strip > ### Title: String operation functions > ### Aliases: strip > ### Keywords: character > > ### ** Examples > > print(upper.case(c("qwerty e","asdf rT"))) # "QWERTY" "ASDF" [1] "QWERTY E" "ASDF RT" > print(lower.case(c("QWERTY","ASDF"))) # "qwErty" "asdf" [1] "qwerty" "asdf" > print(strip(c("Hello there!","Oslo"," ","NA "))) # "Hello" "Oslo" " " "NA" [1] "Hello" "Oslo" " " "NA" > > > > cleanEx(); ..nameEx <- "tromsoe.t2m.data" > > ### * tromsoe.t2m.data > > flush(stderr()); flush(stdout()) > > ### Name: tromsoe.t2m > ### Title: Monthly mean temperature in Tromsoe. > ### Aliases: tromsoe.t2m > ### Keywords: datasets > > ### ** Examples > > > > > cleanEx(); ..nameEx <- "upper.case" > > ### * upper.case > > flush(stderr()); flush(stdout()) > > ### Name: upper.case > ### Title: convert to UPPER CASE > ### Aliases: upper.case > ### Keywords: character > > ### ** Examples > > print(upper.case(c("qwerty e","asdf rT"))) # "QWERTY" "ASDF" [1] "QWERTY E" "ASDF RT" > print(lower.case(c("QWERTY","ASDF"))) # "qwErty" "asdf" [1] "qwerty" "asdf" > print(strip(c("Hello there!","Oslo"," ","NA "))) # "Hello" "Oslo" " " "NA" [1] "Hello" "Oslo" " " "NA" > > > > cleanEx(); ..nameEx <- "what.data" > > ### * what.data > > flush(stderr()); flush(stdout()) > > ### Name: what.data > ### Title: Data information > ### Aliases: what.data > ### Keywords: data > > ### ** Examples > > what.data() [1] "NACD: www.dmi.dk/f+u/publikation/tekrap/2001/Tr01-11.pdf" [1] "Nordklim: http://www.smhi.se/hfa_coord/nordklim/" [1] "NCEP reanalysis: http://www.cdc.noaa.gov/" > > > > ### *