New function It2charge() in common.R - amperometry2df() updated accordingly.

master
Taha Ahmed 13 years ago
parent 1dc00af759
commit f8ad854bd7

@ -296,6 +296,12 @@ amperometry2df <- function(datafilename, wearea = 1) {
# Calculate current density
currentdensity <- ff$current / wearea
ff <- cbind(ff, currentdensity = currentdensity)
# Calculate charge densities and differentials
charge.df <- It2charge(ff$currentdensity, ff$time)
ff <- cbind(ff, timediff = charge.df$timediff,
chargedensity = charge$charge,
sumchargedensity = charge$sumcharge,
dQdt = charge$dQdt)
#
### Collect attributes of this experiment
# These attributes are specific for each kind of experiment,

@ -3,6 +3,7 @@
# Taha Ahmed, Jan 2011
# CONTENTS
# >>>> It2charge
# >>>> ProvideSampleId
# >>>> ConvertRefPot
# >>>> Celsius2Kelvin
@ -13,6 +14,31 @@
##################################################
################### It2charge ####################
##################################################
It2charge <- function (current, time) {
## Calculates charge etc. for amperometric data
## current may be a current or a current density
## (up to the calling function to keep track of which it is)
# Calculate the difference of the time vector
timediff <- c(time[1], diff(time))
# timediff times the current gives the charge,
# since the time vector can be considered as
# the cumulative time, while we need to multiply
# the current with the time elapsed since the last
# current measurement (the timediff).
charge <- current * timediff
differential <- cumsum(charge) / time
# Prepare the return dataframe
ff <- data.frame(time = time, timediff = timediff,
current = current, charge = charge,
sumcharge = cumsum(charge), dQdt = differential)
return(ff)
}
##################################################
################ ProvideSampleId #################
##################################################

Loading…
Cancel
Save