## set path to be searched for Ttools:
frame_files <- lapply(sys.frames(), function(x) x$ofile)
frame_files <- Filter(Negate(is.null), frame_files)
path <- dirname(frame_files[[length(frame_files)]])
if (is.na(path)) {
print("select the file with the Ttools toolbox!")
path <- file.choose()
path <- unlist(strsplit(path,"Ttool"))[1]
}
path
frame_files <- lapply(sys.frames(), function(x) x$ofile)
frame_files
function(x) x$ofile
getwd()
setwd("/Users/andi/BC_peramfrost_data")
getwd()
source('~/BC_peramfrost_data/R_source/start_BC_Temp.R', echo=TRUE)
getwd()
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/start_BC_Temp.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_RMAT.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/start_BC_Temp.R', echo=TRUE)
load("~/Dropbox/BC_temp_measurements/BC_permafrost_data/.RData")
load("~/Dropbox/BC_temp_measurements/BC_permafrost_data/.RData")
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/start_BC_Temp.R', echo=TRUE)
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
degday <- deg.day(DMT_GUN)
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/Ttools.R')
degday <- deg.day(DMT_GUN)
degday$fdd
source('~/.active-rstudio-document')
degday <- deg.day(DMT_GUN)
degday$fdd
summary(DMT_GUN)
plot(DMT_GUN$wx_Tair)
dev.off()
dev.off()
dev.off()
dev.off()
dev.off()
dev.off()
dev.off()
dev.off()
plot(DMT_GUN$t,DMT_GUN$wx_Tair)
source('~/.active-rstudio-document')
str(d)
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/Ttools.R')
DMT <- DMT_GUN
d <- DMT
tdd <- deg.day(d)$tdd
fdd <- deg.day(d)$fdd
tdd
DMT <- DMT[,1:4]
DMT
tdd <- deg.day(d)$tdd
fdd <- deg.day(d)$fdd
tdd
tdd <- deg.day(DMT)$tdd
fdd <- deg.day(DMT)$fdd
tdd
fdd
barplot(fdd$wx_Tair)
site <- "NON"
loc <- "N"
## set plot mode: "png","pdf" or "scr" (for screen)
pl <- "png"
## define smoothing window (days)
win <- 15
## make bar for winter and summer N-fact
Nfactbar <- T
## define plot window ( use full years!!!)
tbeg <- "2009-01-01"
tend <- "2012-12-31"
## set limits in degC for plots
ylim1 <- c(-30,20)
ylim2 <- c(-20,30)
##======================================================================================
##   preparation
##======================================================================================
## load workspace with all data and tools
if (!exists("STAWS")) load("RData/STATws.RData")
## load toolbox Ttools
source("R_source/Ttools.R")
## get list of sites:
sites <- levels(factor(slist$site))
lsl <- length(sites) ## length of short list
## getting list with profil definitions for field site
proflist <- read.csv("meta/SO_TO_proflist.csv", as.is=TRUE)
if (dim(proflist)[2]==1) proflist <- read.csv("meta/SO_TO_proflist.csv", as.is=TRUE, sep=";")
proflist <- proflist[proflist$site==site,]
##get variable names and surface tiype and lapse rate corr:
if (exists("vnam")) rm("vnam")
for (i in 1:(dim(proflist)[1])){
lloc <- unlist(strsplit(proflist$ground[i],split="_",fixed=T))[1]
if (!is.na(lloc)) if (lloc == loc) vnam <- proflist[i,2:4]
if (!is.na(lloc)) if (lloc == loc) typ <- proflist$surftype[i]
if (!is.na(lloc)) if (lloc == loc) lps <- proflist$lapsrc[i]
}
## col for Ts (ussually = 2; if dT then use 3)
if (typ=="r") Ts <- 3 else Ts <- 2
##======================================================================================
##======================================================================================
## get data:
d <- get("DMT_"&site)
d <- ts.df.runmean(d,win=win,qlim=0.99)
d <- ts.cut(d,posix(tbeg),posix(tend))
t <- d[,1]
Tair <- d[,as.character(vnam[1])] + lps
Ts <- d[,as.character(vnam[Ts])]
N <- Ts/Tair
## calculate seasonal N-factors
DMT <- data.frame(t=t, Tair=Tair, Ts=Ts)
tdd <- deg.day(DMT)$tdd
fdd <- deg.day(DMT)$fdd
tdd
fdd
plot(Ts)
plot(t,Ts)
Nfr[1] <- NA
Nfr[length(Nfr)] <- NA
Nfr
Nth <- tdd$Ts / tdd$Tair
Nfr <- fdd$Ts / fdd$Tair
Nfr[1] <- NA
Nfr[length(Nfr)] <- NA
Nfr
lines(t,Tair)
par(new=T)
barplot(Nth,col="blue",width=0.4)
plot(t,Ts)
lines(t,Tair)
par(new=T)
barplot(Nth,col="blue",width=0.1)
barplot(Nth,col="grey",space=0.5)
barplot(Nth,col="grey",space=1.5)
plot(t,Ts)
par(new=T)
barplot(Nth,col="grey",space=1.5)
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
Nfr
Nth
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/.active-rstudio-document')
Nth
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_HUD_SO&Nfact_cc.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_MID_SO&Nfact.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_MID_SO&Nfact.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
DMT[,1]
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_PIN_SO&Nfact_cx.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
Nfr
Nth
tdd
fdd
DMT
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
Nfr
## get data:
d <- get("DMT_"&site)
d <- ts.df.runmean(d,win=win,qlim=0.95)
d <- ts.cut(d,posix(tbeg),posix(tend))
t <- d[,1]
Tair <- d[,as.character(vnam[1])] + lps
Ts <- d[,as.character(vnam[Ts])]
N <- Ts/Tair
## calculate seasonal N-factors
DMT <- data.frame(t=t, Tair=Tair, Ts=Ts)
summary(DMT)
plot(DMT$t,DMT$Tair)
DMT <- DMT[!is.na(DMT$Tair)&!is.na(DMT$Ts),]
plot(DMT$t,DMT$Tair)
tdd
fdd
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
SO <- get("SOTO_"&site)
SO
loc
get("SOTO_"&site)[loc]
get("SOTO_"&site)
get("SOTO_"&site)[loc][1]
get("SOTO_"&site)[loc,1]
get("SOTO_"&site)[1,loc]
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
SO <- get("SOTO_"&site)[1,loc]
SO <- round(SO,1)
SO
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
str(d)
source('~/.active-rstudio-document')
vnam
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
SO
get("SOTO_"&site)[1,loc]
get("SOTO_"&site)
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
SO
SO <- get("SOTO_"&site)[loc,as.character(vnam[Ts])]
SO
get("SOTO_"&site)
SO <- get("SOTO_"&site)[,as.character(vnam[Ts])]
SO <- get("SOTO_"&site)[var==as.character(vnam[Ts])]
as.character(vnam[Ts])
vnam
SO <- get("SOTO_"&site)
SO$var==as.character(vnam[Ts])
SO$var
SO <- get("SOTO_"&site)
SO
SO$var==as.character(vnam[Ts])
if (typ=="r") Ts <- 3 else Ts <- 2
##======================================================================================
##======================================================================================
## get data:
d <- get("DMT_"&site)
SO <- get("SOTO_"&site)[,as.character(vnam[Ts])]
as.character(vnam[Ts])
get("SOTO_"&site)[as.character(vnam[Ts])]
get("SOTO_"&site)
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
Ts
as.character(vnam[Ts])
site
SO <- get("SOTO_"&site)[loc]
SO
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
SO <- get("SOTO_"&site)[loc]
SO
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/.active-rstudio-document')
source('~/Dropbox/BC_temp_measurements/BC_permafrost_data/R_source/plot_deltaT_Nfact.R')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
str(d)
source('~/.active-rstudio-document')
SO
vnam
loc
lloc
site
vnam
summary(d)
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
source('~/.active-rstudio-document')
