Fixed the problem with multiple-potential steps in mps2df().

master
Taha Ahmed 14 years ago
parent e6eb2b9544
commit ab65adee9d

44
CHI.R

@ -38,6 +38,8 @@ mps2df <- function(datafilename, wearea = 1) {
## $ didt : num ## $ didt : num
## $ charge : num ## $ charge : num
## $ chargedensity : num ## $ chargedensity : num
## $ PotentialSteps : num
## $ TimeSteps : num
## $ Cycle : num ## $ Cycle : num
## $ SampleInterval : num ## $ SampleInterval : num
## $ QuietTime : num ## $ QuietTime : num
@ -55,7 +57,7 @@ mps2df <- function(datafilename, wearea = 1) {
# #
sampleid <- ProvideSampleId(datafilename) sampleid <- ProvideSampleId(datafilename)
# #
rgxp.number <- "^\\-?\\d\\.\\d+[e,]" rgxp.number <- "^\\-?\\d+\\.\\d+[e,]"
# regexp that matches a decimal number at the beginning of the line. # regexp that matches a decimal number at the beginning of the line.
# Matches numbers with or without a negative sign (hyphen), # Matches numbers with or without a negative sign (hyphen),
# followed by one digit before the decimal, a decimal point, # followed by one digit before the decimal, a decimal point,
@ -110,16 +112,38 @@ mps2df <- function(datafilename, wearea = 1) {
chargedensity = chargedensity) chargedensity = chargedensity)
# #
### Collect attributes of this experiment ### Collect attributes of this experiment
# Potential steps #### THIS NEEDS FIXING # Potential steps
PotentialSteps <- ""
positions.PotentialSteps <- regexpr("^E\\d+\\s\\(V\\)", chifile) positions.PotentialSteps <- regexpr("^E\\d+\\s\\(V\\)", chifile)
#PotentialSteps <- as.numeric(strsplit(chifile[which(positions.PotentialSteps == 1)], "\\s=\\s")[[1]][2]) PotentialSteps <- paste("\\num{", strsplit(chifile[which(positions.PotentialSteps == 1)],
#ff$PotentialSteps <- PotentialSteps "\\s=\\s")[[1]][2], "}", sep = "")
# Time steps #### THIS NEEDS FIXING if (length(which(positions.PotentialSteps == 1)) > 1) {
positions.Time <- regexpr("^T\\d+\\s\\(s\\)", chifile) for (i in 2:length(which(positions.PotentialSteps == 1))) {
# Cycle PotentialSteps <-
position.Cycle <- regexpr("^Cycle", chifile) paste(PotentialSteps,
Cycle <- as.numeric(strsplit(chifile[which(position.Cycle == 1)], "\\s=\\s")[[1]][2]) paste("\\num{", strsplit(chifile[which(positions.PotentialSteps == 1)],
ff$Cycle <- Cycle "\\s=\\s")[[i]][2], "}", sep = ""), sep = ", ")
}
}
ff$PotentialSteps <- PotentialSteps
# Time steps
TimeSteps <- ""
positions.TimeSteps <- regexpr("^T\\d+\\s\\(s\\)", chifile)
TimeSteps <- paste("\\num{", strsplit(chifile[which(positions.TimeSteps == 1)],
"\\s=\\s")[[1]][2], "}", sep = "")
if (length(which(positions.TimeSteps == 1)) > 1) {
for (i in 2:length(which(positions.TimeSteps == 1))) {
TimeSteps <-
paste(TimeSteps,
paste("\\num{", strsplit(chifile[which(positions.TimeSteps == 1)],
"\\s=\\s")[[i]][2], "}", sep = ""), sep = ", ")
}
}
ff$TimeSteps <- TimeSteps
# Cycles
position.Cycles <- regexpr("^Cycle", chifile)
Cycles <- as.numeric(strsplit(chifile[which(position.Cycles == 1)], "\\s=\\s")[[1]][2])
ff$Cycles <- Cycles
# Sample interval (s) # Sample interval (s)
position.SampleInterval <- regexpr("^Sample\\sInterval\\s\\(s\\)", chifile) position.SampleInterval <- regexpr("^Sample\\sInterval\\s\\(s\\)", chifile)
SampleInterval <- as.numeric(strsplit(chifile[which(position.SampleInterval == 1)], "\\s=\\s")[[1]][2]) SampleInterval <- as.numeric(strsplit(chifile[which(position.SampleInterval == 1)], "\\s=\\s")[[1]][2])

Loading…
Cancel
Save