make_option(c("-a", "--all"), type="character", action="store_true",
default=FALSE,
help="take all sites available in data_wsl",
metavar="character"),
make_option(c("-v", "--verbose"), action="store_true", default=FALSE,
help="increase verbosity",
metavar="character")
)
opt_parser <- OptionParser(option_list=option_list)
opt <- parse_args(opt_parser)
if(opt$verbose) {message(" \nWelcome to processing with from raw to level 0\nUse 'Rscript level0dendro.R --help' for options\n ")}
# Sys.sleep(1)
!opt$since
opt$verbose
opt$time=="14d" & !opt$since & opt$verbose
if(opt$time=="14d" & !opt$since & opt$verbose) {message("Using the default time span of 14 days.")}
?switch
opt$time
sapply(c("d","w","m"), function(x) grep(x, opt$time))
?grep
?match
match("14d", ("d","w","m"))
match("14d", c("d","w","m"))
pmatch("14d", c("d","w","m"))
pmatch( c("d","w","m"), "14d")
charmatch(c("d","w","m"), "14d")
charmatch("14d", c("d","w","m"))
charmatch("d", c("d","w","m"))
charmatch("ad", c("d","w","m"))
pmatch("d", c("d","w","m"))
pmatch("dx", c("d","w","m"))
pmatch("dx", c("d","w","m"),dup = FALSE)
pmatch("dx", c("d","w","m"),dup = TRUE)
charmatch(c("", "ab", "ab"), c("abc", "ab"))
?grep
grep(c("d","w","m"), "dx")
agrep("w", "dx")
sapply(c("d","w","m"), grep, "15d")
which(sapply(c("d","w","m"), grep, "15d"))
which(sapply(c("d","w","m"), grep, "15d")) == 1)
which(sapply(c("d","w","m"), grep, "15d") == 1)
which(sapply(c("d","w","m"), grep, "15w") == 1)
str(which(sapply(c("d","w","m"), grep, "15w") == 1))
names((which(sapply(c("d","w","m"), grep, "15w") == 1)))
names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
names((which(sapply(c("d","w","m"), grep, "asf") == 1)))
names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
length(timestep)
timestep <- names((which(sapply(c("d","w","m"), grep, "sf") == 1)))
length(timestep)
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
timestep
timestep <- names((which(sapply(c("d","w","m"), grep, "w134" == 1)))
timestep <- names((which(sapply(c("d","w","m"), grep, "w134") == 1)))
timestep
timestep <- names((which(sapply(c("d","w","m"), grep, "w13d4") == 1)))
timestep
?switch
as.numeric(gsub("d","",opt$time))
as.numeric(gsub("w","",opt$time))/7
imestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) / 7,
"m" = as.numeric(gsub("m","",opt$time)) / 30
)
}
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) / 7,
"m" = as.numeric(gsub("m","",opt$time)) / 30
)
}
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) / 7,
"m" = as.numeric(gsub("m","",opt$time)) / 30
)
}
time
timestep <- names((which(sapply(c("d","w","m"), grep, "34d") == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) / 7,
"m" = as.numeric(gsub("m","",opt$time)) / 30
)
}
time
timestep <- names((which(sapply(c("d","w","m"), grep, "34w") == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) / 7,
"m" = as.numeric(gsub("m","",opt$time)) / 30
)
}
timestep
as.numeric(gsub("w","",opt$time)) / 7,
opt$time <- "2w"
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) / 7,
"m" = as.numeric(gsub("m","",opt$time)) / 30
)
}
time
opt$time <- "w2"
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) / 7,
"m" = as.numeric(gsub("m","",opt$time)) / 30
)
}
time
365.5/12
opt$time <- "1m"
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) / 7,
"m" = as.numeric(gsub("m","",opt$time)) / 30
)
}
time
opt$time <- "1m"
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) * 7,
"m" = as.numeric(gsub("m","",opt$time)) * 365.5/12
)
}
time
opt$time <- "1m"
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) * 7,
"m" = as.numeric(gsub("m","",opt$time)) * 365.5 / 12
)
}
time
opt$time <- "14d"
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) * 7,
"m" = as.numeric(gsub("m","",opt$time)) * 365.5 / 12
)
}
time
format(Sys.time()-time*24*60*60,"%F %T")
opt$time<-"d"
timestep <- names((which(sapply(c("d","w","m"), grep, opt$time) == 1)))
if (length(timestep) != 1) {
stop("there was something wrong with the way you provided the time.")
} else {
time <- switch(timestep,
"d" = as.numeric(gsub("d","",opt$time)),
"w" = as.numeric(gsub("w","",opt$time)) * 7,
"m" = as.numeric(gsub("m","",opt$time)) * 365.5 / 12
)
}
time
ifelse(is.na(time), 90*24*60*60, time*24*60*60)
format(Sys.time() - as.difftime(ifelse(is.na(time), 90, time), units="days"), "%F %T")
Sys.time() - as.difftime(ifelse(is.na(time), 90, time), units="days")
format(Sys.time() - as.difftime(ifelse(is.na(time), 90, time), units="days"), "%F %T")
format(Sys.time()-time*24*60*60,"%F %T")
time
time<-14
format(Sys.time()-time*24*60*60,"%F %T")
format(Sys.time() - as.difftime(ifelse(is.na(time), 90, time), units="days"), "%F %T")
?stop
opt$time
opt$time <- "14d"
format(as.POSIXct("1970-01-01 00:00:01", tz="UTC"), "%F %T")
opt$all
option_list <- list(
make_option(c("-t", "--time"), type="character", default="14d",
help="time in d=days, w=weeks, or m=months",
metavar="character"),
make_option(c("-c", "--since"), action="store_true", #? type="character"
default=FALSE,
help="since the beginning of time",
metavar="character"),
make_option(c("-r", "--resolution"), type="double", default=10,
help="resolution in minutes, with 10 as default",
metavar="character"),
make_option(c("-s", "--sensor"), type="character", default=NULL,
help="sensor name without L0 or L1 at the end",
metavar="character"),
make_option(c("-T", "--site"), type="character", default=NULL,
help="site name to process all of the site",
metavar="character"),
make_option(c("-a", "--all"), action="store_true",# , type="character"
default=FALSE,
help="take all sites available in data_wsl",
metavar="character"),
make_option(c("-v", "--verbose"), action="store_true", default=FALSE,
help="increase verbosity",
metavar="character")
)
opt$all
opt$since
### set-up the option parser
### ***************************************************************************************************
option_list <- list(
make_option(c("-t", "--time"), type="character", default="14d",
help="time in d=days, w=weeks, or m=months",
metavar="character"),
make_option(c("-c", "--since"), action="store_true", #? type="character"
default=FALSE,
help="since the beginning of time",
metavar="character"),
make_option(c("-r", "--resolution"), type="double", default=10,
help="resolution in minutes, with 10 as default",
metavar="character"),
make_option(c("-s", "--sensor"), type="character", default=NULL,
help="sensor name without L0 or L1 at the end",
metavar="character"),
make_option(c("-T", "--site"), type="character", default=NULL,
help="site name to process all of the site",
metavar="character"),
make_option(c("-a", "--all"), action="store_true",# , type="character"
default=FALSE,
help="take all sites available in data_wsl",
metavar="character"),
make_option(c("-v", "--verbose"), action="store_true", default=FALSE,
help="increase verbosity",
metavar="character")
)
opt$since
opt$all
opt$verbose
require(shiny)
rm(list=ls())
program.version <- "v5.0 (15.02.2016)"
################################################################################
### input parameter ############################################################
################################################################################
### evaluation period
evalperiod <- c("19.09.2014", "21.09.2014")                                        ### c(startdate, enddate) with the format "%d.%m.%Y"
eval_timezone <- "UTC"
### DOAS model
DOAS.model <- "S2"                                                                 ### S1 to S5
### total path length
path.length <- 74.4 + 1.4                                                           ### (full) measurement path length [m] (about 1.4 m path happens inside the miniDOAS box)
### file directories
directory <- "/Users/Sinti/ownCloud/Arbeit/Programming/R/Projects/DOAS/miniDOAS_Revaluation_basic_version"                        ### default directory: separator = "/" or "\\" instead of "\"; calculation results will be saved in ".../MiniDOAS/3 Results"
reference.dir <- "20140901_Witzwil/miniDOAS-ref_cal_spec-Eval201509241057_Vukan"     ### sub-directory of reference files (give path below ".../1 Reference Spectra/" level); folder directory of average reference lamp-, dark-, and calibration spectra (optionally fixed pattern);these have to be created using "miniDOAS average spectra sijDATE.r" (created with dummy header!)
eval.dir <- "/Users/Sinti/ownCloud/Arbeit/Programming/R/Projects/DOAS/miniDOAS_Revaluation_basic_version/miniDOAS_Revaluation"  ### function collection: should contain the file "miniDOAS functions.r" etc
### average raw spectra (either for real, or for plotting only)
avg.period <- 30                                                                   ### minutes
average.rawdat <- FALSE                                                             ### whether to average raw spectra before calculation (TRUE) or to process all raw spectra individually (FALSE)
################################################################################
### setup ######################################################################
################################################################################
### directories
### ******************************************************************************
cat("directories")
save.dir <- paste0(directory,"/2_Results")                                		### directory where to save all results (in a separate new folder)
reference.dir <- paste0(directory,"/1_Reference_Spectra/",reference.dir)  		### folder directory of average reference lamp-, dark-, and calibration spectra (optionally fixed pattern); these have to be created using "miniDOAS average spectra sijDATE.r" (created with dummy header!)
rawdata.dir <- paste0(directory,"/0_Measurement_Data")
setwd(directory)
### parameters, packages & functions
### ******************************************************************************
avg.refspecs <- FALSE
source(paste0(eval.dir,"/miniDOAS_packages.R"))
source(paste0(eval.dir,"/miniDOAS_functions.R"))
source(paste0(eval.dir,"/miniDOAS_rawdata_structure.R"))
### main evaluation strategy
filter.type <- "rfbaseline.smooth"  											   ### currently "rfbaseline.smooth" = weird local polynomial fitting stuff - experimental, or "loess" (=local polynomial fitting), "doubleAVG" (= twice a 2-sided moving average, forth and back), "doubleMED" = like doubleAVG but with running median, or "doublehammingAVG" (= twice a hamming moving average, forth and back), or "recursive" (= recursive low pass filtering), or "polynomial" (= polynomial function of "filter.strength"' order is fitted by least square minimisation); will be applied to all: calibration differential spectrum and measurement differential spectrum
fit.type <- "arima"                                                                ### "arima" | "lm"
max.order <- list(p=2, d=0, q=2)                                                   ### maximum orders for the arima model - fitting is iterated over all order combinations and best model is selected by AICc; if max.order == NULL & fit.type == "arima", default orders (see functions) will be used without model selection; will be ignored for lm
straylight.offset <- TRUE
corr.shift <- TRUE                                                                 ### whether to consider a shift in ccd pixels at all
tau.shift <- 1                                                                     ### number of +-pixel for shifting spectra against each other to minimise residuals in the fitting procedure; tau.shift can be NA, then no shifting is considered; tau.shift cannot be larger than half of filter.strength
tau.divisor <- 1                                                                   ### whether to derive the average fixed residual pattern spectrum
### fixed pattern correction
corr.fixed.pattern <- FALSE                                                        ### whether to consider an averaged fixed (not-random) noise pattern spectrum (evaluated as moving averaged residual spectrum)
fixed.pattern.length <- 3*24												       ### hours
### plotting evaluation details
plot.results <- TRUE                                                               ### avg.period = overall averaging period [min] for plotting (or averaging, if average.rawdat == TRUE) of spectra ensemble (can be NA, then no plot is produced)
calref.cols <- c("blue", "green", "orange", "cyan")
### determine measurement data file(s)
cat("\ndetermine measurement data files")
if (avg.refspecs) {
evalperiod <- list(time.dark, time.ref, time.ref.dark, time.NH3.cal, time.SO2.cal, time.NO.cal, time.N2.cal, time.N2.dark.cal)
evalperiod <- lapply(evalperiod, function(x) ymd(format(x, "%Y-%m-%d"), tz=eval_timezone))
} else {
evalperiod <- list(strptime(evalperiod, "%d.%m.%Y", tz=eval_timezone))
}
evalperiod
dir.meas <- ask.data(evalperiod[[1]])
dir.meas
avg.refspecs
folders <- strptime(list.files(path=rawdata.dir, full.names=FALSE, pattern=".csv"), "%Y%m%d", tz=eval_timezone)
folders
folders <- folders[!duplicated(folders)]
folders <- format(folders[which(folders >=  evalperiod[1] & folders <=  evalperiod[2])], format="%Y%m%d")
folders
evalperiod
folders <- strptime(list.files(path=rawdata.dir, full.names=FALSE, pattern=".csv"), "%Y%m%d", tz=eval_timezone)
folders <- folders[!duplicated(folders)]
folders <- format(folders[which(folders >=  evalperiod[1] & folders <=  evalperiod[2])], format="%Y%m%d")
evalperiod[1]
evalperiod[2]
rm(list=ls())
program.version <- "v5.0 (15.02.2016)"
################################################################################
### input parameter ############################################################
################################################################################
### evaluation period
evalperiod <- c("19.09.2014", "21.09.2014")                                        ### c(startdate, enddate) with the format "%d.%m.%Y"
eval_timezone <- "UTC"
### DOAS model
DOAS.model <- "S2"                                                                 ### S1 to S5
### total path length
path.length <- 74.4 + 1.4                                                           ### (full) measurement path length [m] (about 1.4 m path happens inside the miniDOAS box)
### file directories
directory <- "/Users/Sinti/ownCloud/Arbeit/Programming/R/Projects/DOAS/miniDOAS_Revaluation_basic_version"                        ### default directory: separator = "/" or "\\" instead of "\"; calculation results will be saved in ".../MiniDOAS/3 Results"
reference.dir <- "20140901_Witzwil/miniDOAS-ref_cal_spec-Eval201509241057_Vukan"     ### sub-directory of reference files (give path below ".../1 Reference Spectra/" level); folder directory of average reference lamp-, dark-, and calibration spectra (optionally fixed pattern);these have to be created using "miniDOAS average spectra sijDATE.r" (created with dummy header!)
eval.dir <- "/Users/Sinti/ownCloud/Arbeit/Programming/R/Projects/DOAS/miniDOAS_Revaluation_basic_version/miniDOAS_Revaluation"  ### function collection: should contain the file "miniDOAS functions.r" etc
### average raw spectra (either for real, or for plotting only)
avg.period <- 30                                                                   ### minutes
average.rawdat <- FALSE                                                             ### whether to average raw spectra before calculation (TRUE) or to process all raw spectra individually (FALSE)
################################################################################
### setup ######################################################################
################################################################################
### directories
### ******************************************************************************
cat("directories")
save.dir <- paste0(directory,"/2_Results")                                		### directory where to save all results (in a separate new folder)
reference.dir <- paste0(directory,"/1_Reference_Spectra/",reference.dir)  		### folder directory of average reference lamp-, dark-, and calibration spectra (optionally fixed pattern); these have to be created using "miniDOAS average spectra sijDATE.r" (created with dummy header!)
rawdata.dir <- paste0(directory,"/0_Measurement_Data")
setwd(directory)
### parameters, packages & functions
### ******************************************************************************
avg.refspecs <- FALSE
source(paste0(eval.dir,"/miniDOAS_packages.R"))
source(paste0(eval.dir,"/miniDOAS_functions.R"))
source(paste0(eval.dir,"/miniDOAS_rawdata_structure.R"))
### additional evaluation parameters and options (these are recommended settings)
### ******************************************************************************
### main evaluation strategy
filter.type <- "rfbaseline.smooth"  											   ### currently "rfbaseline.smooth" = weird local polynomial fitting stuff - experimental, or "loess" (=local polynomial fitting), "doubleAVG" (= twice a 2-sided moving average, forth and back), "doubleMED" = like doubleAVG but with running median, or "doublehammingAVG" (= twice a hamming moving average, forth and back), or "recursive" (= recursive low pass filtering), or "polynomial" (= polynomial function of "filter.strength"' order is fitted by least square minimisation); will be applied to all: calibration differential spectrum and measurement differential spectrum
fit.type <- "arima"                                                                ### "arima" | "lm"
max.order <- list(p=2, d=0, q=2)                                                   ### maximum orders for the arima model - fitting is iterated over all order combinations and best model is selected by AICc; if max.order == NULL & fit.type == "arima", default orders (see functions) will be used without model selection; will be ignored for lm
straylight.offset <- TRUE
corr.shift <- TRUE                                                                 ### whether to consider a shift in ccd pixels at all
tau.shift <- 1                                                                     ### number of +-pixel for shifting spectra against each other to minimise residuals in the fitting procedure; tau.shift can be NA, then no shifting is considered; tau.shift cannot be larger than half of filter.strength
tau.divisor <- 1                                                                   ### whether to derive the average fixed residual pattern spectrum
### fixed pattern correction
corr.fixed.pattern <- FALSE                                                        ### whether to consider an averaged fixed (not-random) noise pattern spectrum (evaluated as moving averaged residual spectrum)
fixed.pattern.length <- 3*24												       ### hours
### plotting evaluation details
plot.results <- TRUE                                                               ### avg.period = overall averaging period [min] for plotting (or averaging, if average.rawdat == TRUE) of spectra ensemble (can be NA, then no plot is produced)
calref.cols <- c("blue", "green", "orange", "cyan")
### determine measurement data file(s)
cat("\ndetermine measurement data files")
dir.meas <- ask.data(evalperiod[[1]])
evalperiod[[1]]
rm(list=ls())
program.version <- "v5.0 (15.02.2016)"
################################################################################
### input parameter ############################################################
################################################################################
### evaluation period
evalperiod <- c("19.09.2014", "21.09.2014")                                        ### c(startdate, enddate) with the format "%d.%m.%Y"
eval_timezone <- "UTC"
### DOAS model
DOAS.model <- "S2"                                                                 ### S1 to S5
### total path length
path.length <- 74.4 + 1.4                                                           ### (full) measurement path length [m] (about 1.4 m path happens inside the miniDOAS box)
### file directories
directory <- "/Users/Sinti/ownCloud/Arbeit/Programming/R/Projects/DOAS/miniDOAS_Revaluation_basic_version"                        ### default directory: separator = "/" or "\\" instead of "\"; calculation results will be saved in ".../MiniDOAS/3 Results"
reference.dir <- "20140901_Witzwil/miniDOAS-ref_cal_spec-Eval201509241057_Vukan"     ### sub-directory of reference files (give path below ".../1 Reference Spectra/" level); folder directory of average reference lamp-, dark-, and calibration spectra (optionally fixed pattern);these have to be created using "miniDOAS average spectra sijDATE.r" (created with dummy header!)
eval.dir <- "/Users/Sinti/ownCloud/Arbeit/Programming/R/Projects/DOAS/miniDOAS_Revaluation_basic_version/miniDOAS_Revaluation"  ### function collection: should contain the file "miniDOAS functions.r" etc
### average raw spectra (either for real, or for plotting only)
avg.period <- 30                                                                   ### minutes
average.rawdat <- FALSE                                                             ### whether to average raw spectra before calculation (TRUE) or to process all raw spectra individually (FALSE)
################################################################################
### setup ######################################################################
################################################################################
### directories
### ******************************************************************************
cat("directories")
save.dir <- paste0(directory,"/2_Results")                                		### directory where to save all results (in a separate new folder)
reference.dir <- paste0(directory,"/1_Reference_Spectra/",reference.dir)  		### folder directory of average reference lamp-, dark-, and calibration spectra (optionally fixed pattern); these have to be created using "miniDOAS average spectra sijDATE.r" (created with dummy header!)
rawdata.dir <- paste0(directory,"/0_Measurement_Data")
setwd(directory)
### parameters, packages & functions
### ******************************************************************************
avg.refspecs <- FALSE
source(paste0(eval.dir,"/miniDOAS_packages.R"))
source(paste0(eval.dir,"/miniDOAS_functions.R"))
source(paste0(eval.dir,"/miniDOAS_rawdata_structure.R"))
### additional evaluation parameters and options (these are recommended settings)
### ******************************************************************************
### main evaluation strategy
filter.type <- "rfbaseline.smooth"  											   ### currently "rfbaseline.smooth" = weird local polynomial fitting stuff - experimental, or "loess" (=local polynomial fitting), "doubleAVG" (= twice a 2-sided moving average, forth and back), "doubleMED" = like doubleAVG but with running median, or "doublehammingAVG" (= twice a hamming moving average, forth and back), or "recursive" (= recursive low pass filtering), or "polynomial" (= polynomial function of "filter.strength"' order is fitted by least square minimisation); will be applied to all: calibration differential spectrum and measurement differential spectrum
fit.type <- "arima"                                                                ### "arima" | "lm"
max.order <- list(p=2, d=0, q=2)                                                   ### maximum orders for the arima model - fitting is iterated over all order combinations and best model is selected by AICc; if max.order == NULL & fit.type == "arima", default orders (see functions) will be used without model selection; will be ignored for lm
straylight.offset <- TRUE
corr.shift <- TRUE                                                                 ### whether to consider a shift in ccd pixels at all
tau.shift <- 1                                                                     ### number of +-pixel for shifting spectra against each other to minimise residuals in the fitting procedure; tau.shift can be NA, then no shifting is considered; tau.shift cannot be larger than half of filter.strength
tau.divisor <- 1                                                                   ### whether to derive the average fixed residual pattern spectrum
### fixed pattern correction
corr.fixed.pattern <- FALSE                                                        ### whether to consider an averaged fixed (not-random) noise pattern spectrum (evaluated as moving averaged residual spectrum)
fixed.pattern.length <- 3*24												       ### hours
### plotting evaluation details
plot.results <- TRUE                                                               ### avg.period = overall averaging period [min] for plotting (or averaging, if average.rawdat == TRUE) of spectra ensemble (can be NA, then no plot is produced)
calref.cols <- c("blue", "green", "orange", "cyan")
evalperiod
evalperiod <- list(strptime(evalperiod, "%d.%m.%Y", tz=eval_timezone))
evalperiod
evalperiod[[1]]
dir.meas <- ask.data(evalperiod[[1]])
dir.meas
evalperiod <- evalperiod[[1]]
length(evalperiod) > 1
folders <- strptime(list.files(path=rawdata.dir, full.names=FALSE, pattern=".csv"), "%Y%m%d", tz=eval_timezone)
folders <- folders[!duplicated(folders)]
folders <- format(folders[which(folders >=  evalperiod[1] & folders <=  evalperiod[2])], format="%Y%m%d")
folders
folders <- strptime(list.files(path=rawdata.dir, full.names=FALSE, pattern=".csv"), "%Y%m%d", tz=eval_timezone)
folders <- folders[!duplicated(folders)]
folders
folders[which(folders >=  evalperiod[1] & folders <=  evalperiod[2])]
folders
folders >=  evalperiod[1]
folders <=  evalperiod[2]
evalperiod
rm(list=ls())
program.version <- "v5.0 (15.02.2016)"
################################################################################
### input parameter ############################################################
################################################################################
### evaluation period
evalperiod <- c("19.09.2014", "21.09.2014")                                        ### c(startdate, enddate) with the format "%d.%m.%Y"
eval_timezone <- "UTC"
### DOAS model
DOAS.model <- "S2"                                                                 ### S1 to S5
### total path length
path.length <- 74.4 + 1.4                                                           ### (full) measurement path length [m] (about 1.4 m path happens inside the miniDOAS box)
### file directories
directory <- "/Users/Sinti/ownCloud/Arbeit/Programming/R/Projects/DOAS/miniDOAS_Revaluation_basic_version"                        ### default directory: separator = "/" or "\\" instead of "\"; calculation results will be saved in ".../MiniDOAS/3 Results"
reference.dir <- "20140901_Witzwil/miniDOAS-ref_cal_spec-Eval201509241057_Vukan"     ### sub-directory of reference files (give path below ".../1 Reference Spectra/" level); folder directory of average reference lamp-, dark-, and calibration spectra (optionally fixed pattern);these have to be created using "miniDOAS average spectra sijDATE.r" (created with dummy header!)
eval.dir <- "/Users/Sinti/ownCloud/Arbeit/Programming/R/Projects/DOAS/miniDOAS_Revaluation_basic_version/miniDOAS_Revaluation"  ### function collection: should contain the file "miniDOAS functions.r" etc
### average raw spectra (either for real, or for plotting only)
avg.period <- 30                                                                   ### minutes
average.rawdat <- FALSE                                                             ### whether to average raw spectra before calculation (TRUE) or to process all raw spectra individually (FALSE)
################################################################################
### setup ######################################################################
################################################################################
### directories
### ******************************************************************************
cat("directories")
save.dir <- paste0(directory,"/2_Results")                                		### directory where to save all results (in a separate new folder)
reference.dir <- paste0(directory,"/1_Reference_Spectra/",reference.dir)  		### folder directory of average reference lamp-, dark-, and calibration spectra (optionally fixed pattern); these have to be created using "miniDOAS average spectra sijDATE.r" (created with dummy header!)
rawdata.dir <- paste0(directory,"/0_Measurement_Data")
setwd(directory)
### parameters, packages & functions
### ******************************************************************************
avg.refspecs <- FALSE
source(paste0(eval.dir,"/miniDOAS_packages.R"))
source(paste0(eval.dir,"/miniDOAS_functions.R"))
source(paste0(eval.dir,"/miniDOAS_rawdata_structure.R"))
source(paste0(eval.dir,"/miniDOAS_evaluation_param.R"))
source(paste0(eval.dir,"/miniDOAS_spectrometer_param.R"))
source(paste0(eval.dir,"/miniDOAS_packages.R"))
source(paste0(eval.dir,"/miniDOAS_functions.R"))
source(paste0(eval.dir,"/miniDOAS_rawdata_structure.R"))
source(paste0(eval.dir,"/miniDOAS_evaluation_param.R"))
