# NOT RUN {
### Example 1: transform patterns from time into the section
##define (piecewise linear) deposition rate
my.xdep=seq(0,12,length.out=100)
my.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))(my.xdep)
#Plot deposition rate
plot(my.xdep,my.ydep,type='l',main='Deposition Rate',xlab='Time', ylab='Sediment per Time Unit',
ylim=c(0,max(my.ydep)))
##define (piecewise linear) temporal pattern, here fossil occurrences
patternname='Fossil Occurrences'
my.temp.pat.x= seq(from=min(my.xdep),to=max(my.xdep),length.out=100)
my.temp.pat.y=splinefunH(x=c(0,4,12),y=c(0.5,2,0.5),m=c(0,0,0))(my.temp.pat.x)
plot(my.temp.pat.x,my.temp.pat.y,type='l',main=paste(patternname,'in time'),
xlab='Time',ylab=patternname,ylim=c(0,max(my.temp.pat.y)))
##transform temporal pattern into stratigraphic pattern
strat.pat=patterntransform(xdep=my.xdep,ydep=my.ydep,xpat=my.temp.pat.x,ypat=my.temp.pat.y,
direction = 'time to height' , depositionmodel = 'piecewise linear deposition rate' ,
patternmode = 'piecewise linear')
strat.pat$report
my.strat.pat.x=strat.pat$height
my.strat.pat.y=strat.pat$val
plot(my.strat.pat.x,my.strat.pat.y,type='l',xlab='Stratigraphic Height',
ylab=patternname, main=paste(patternname,' in the section'))
## Variation: modify deposition rate to include erosion
my.xdep2=my.xdep
my.ydep2=splinefunH(x=c(0,2,4,6,8,10,12),y=c(1,5,6,-2,5,1,6),m=c(0,1.5,-0.5,-0.5,0,0.5,0))(my.xdep2)
#Plot deposition rate
plot(my.xdep2,my.ydep2,type='l',main='Deposition Rate',xlab='Time',ylab='Sediment per Time Unit')
lines(range(my.xdep2),c(0,0))
strat.pat2=patterntransform(xdep=my.xdep2,ydep=my.ydep2,xpat=my.temp.pat.x,ypat=my.temp.pat.y,
direction = 'time to height' , depositionmodel = 'piecewise linear deposition rate' ,
patternmode = 'piecewise linear')
strat.pat2$report
my.strat.pat.x2=strat.pat2$height
my.strat.pat.y2=strat.pat2$val
plot(my.strat.pat.x2,my.strat.pat.y2,type='l',xlab='Stratigraphic Height',
ylab=patternname,main=paste(patternname,' in the section'),ylim=c(0,1))
#the spike is because the deposition rate is very small when it transitions from
#negative to positive, generating a punctual extreme condensation
### Example 2: Transform patterns from the section into time
patternname='Fossil Occurrences'
#piecewise linear deposition rate
my.xdep=seq(0,12,length.out=100)
my.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))(my.xdep)
## Same pattern, this time interpreted as stratigraphic pattern
my.strat.pat.x= seq(from=min(my.xdep),to=max(my.xdep),length.out=100)
my.strat.pat.y=splinefunH(x=c(0,4,12),y=c(0.5,2,0.5),m=c(0,0,0))(my.strat.pat.x)
plot(my.strat.pat.x,my.strat.pat.y,type='l',main=paste(patternname,'in the section'),
xlab='Stratigraphic Height',ylab=patternname,ylim=c(0,max(my.strat.pat.y)))
##interpret deposition rate as inverse deposition rate with the unit "time per sediment"
usedunit='time per sediment'
plot(my.xdep,my.ydep,type='l',main=paste('Deposition Rate as',usedunit),
xlab='Stratigraphic Height',ylab=usedunit,ylim=c(0,max(my.ydep)))
#transform pattern
temp.pat1=patterntransform(xdep=my.xdep,ydep=my.ydep,xpat=my.strat.pat.x,ypat=my.strat.pat.y,
direction = 'height to time' , depositionmodel = 'piecewise linear deposition rate' ,
patternmode = 'piecewise linear', unit=usedunit)
temp.pat1$report
#plot result
plot(temp.pat1$time,temp.pat1$val,type='l',xlab='Time',
ylab=patternname,main=paste(patternname, 'in time'),ylim=c(0,max(temp.pat1$val)))
##take the deposition rate as ordinary deposition rate with unit "sediment per time"
usedunit='sediment per time'
plot(my.xdep,my.ydep,type='l',main=paste('Deposition Rate as',usedunit),
xlab='Stratigraphic Height',ylab=usedunit,ylim=c(0,max(my.ydep)))
#transform pattern
temp.pat2=patterntransform(xdep=my.xdep,ydep=my.ydep,xpat=my.strat.pat.x,ypat=my.strat.pat.y,
direction = 'height to time' ,depositionmodel = 'piecewise linear deposition rate' ,
patternmode = 'piecewise linear', unit=usedunit)
temp.pat2$report
#plot result
plot(temp.pat2$time,temp.pat2$val,type='l',xlab='Time',
ylab=patternname,main=paste(patternname, 'in time'),ylim=c(0,max(temp.pat2$val)))
#Note the big difference in the resulting patterns in time depending on the unit used.
# }
Run the code above in your browser using DataLab