# NOT RUN {
##define deposition rate
xdep=seq(0,12,length.out=100)
ydep=splinefunH(x=c(0,2,4,6,8,10,12),y=c(1,5,6,1,0.5,1,6),m=c(0,1.5,-0.5,-0.5,0,0.5,0))(xdep)
#Plot deposition rate
plot(xdep,ydep,type='l',main='Deposition Rate',xlab='Time',ylab='Deposition Rate')
##at what stratigraphic height can an object be found that was deposited in the
#sediment after 9 time units?
timetostratpointcont(9,xdep,ydep)
##create age model
#points that will be transformed into stratigraphic height
time=seq(min(xdep),max(xdep),length.out=100)
reslist=timetostratpointcont(time,xdep,ydep)
#plot age model
plot(reslist$height,reslist$age,type='l',ylab='Time',xlab='Stratigraphic Height',main='Age model')
#age model with Removal of sediment
#define deposition rate with negative deposition rate, e.g. removal of sediment
xdep=seq(0,12,length.out=100)
ydep=splinefunH(x=c(0,2,4,6,8,10,12),y=c(1,5,6,0,-2,1,6),m=c(0,1.5,-0.5,-0.5,0,0.5,0))(xdep)
#Plot deposition rate
plot(xdep,ydep,main='Deposition Rate',xlab='Time',ylab='Deposition Rate')
#sediment removal is done automatically. e.g. create age model as before:
reslist=timetostratpointcont(time,xdep,ydep)
#plot age model
plot(reslist$height,reslist$age,type='l',ylab='Time',xlab='Stratigraphic Height',main='Age model')
#transform isotope ratio curves
ydep=splinefunH(x=c(0,2,4,6,8,10,12),y=c(1,5,6,1,0.5,1,6),m=c(0,1.5,-0.5,-0.5,0,0.5,0))(xdep)
##create fake ratios and sample locations
sampletime=sort(runif(20,min=min(xdep),max=max(xdep))) #times where the samples were taken
isotoperatio=sin(sampletime)*rnorm(length(sampletime)) #isotope ratios
plot(sampletime,isotoperatio,type='l',xlab='Time',ylab='Isotope Ratio')
#transform only (!) sample times, NOT values
reslist=timetostratpointcont(sampletime,xdep,ydep)
#this is the resulting isotope ratio curve in stratigraphic height
plot(reslist$height,isotoperatio,type='l',xlab='Stratigraphic Height',ylab='Isotope Ratio')
# }
Run the code above in your browser using DataLab