深度上的压力和温度导数

时间:2018-08-29 23:56:36

标签: r spline derivative

我目前正在尝试为公司拥有的井的压力温度调查创建导数曲线。但是,我编写了代码来帮助我完成此过程,但后来意识到实现过程中出现了一些问题。该代码在下面引用。但是,当我在单独的程序中计算正常压力和温度曲线的导数时,我发现与数据形成了鲜明的对比。与图1关联,图像中的深度不是真实的深度,但是数据明显不同。

左是在单独程序中计算的导数,右是由R计算的

    #向上曲线     #read EXCEL     h <-as.data.frame(read_excel(“ PLT.xlsx”,sheet =“ UP”))

#setting boundaries for curves
xs<-seq(round(min(h[["Depth MD"]]),0),round(max(h[["Depth MD"]]),0),by=0.5)
final<-data.frame(depth=xs,Press=1:length(xs),Temp=1:length(xs))
final[,"Press"]<-spline(h[["Depth MD"]],h[,"Pressure"],xout=xs)$y
final[,"Temp"]<-spline(h[["Depth MD"]],h[,"Temp"],xout=xs)$y

#Derivative Pressure
spfun<-splinefun(final$depth,final$Press)
final[["PDeriv"]]<-spfun(final$Press,deriv = 1)


#Derivative Temperature
spfun2<-splinefun(final$depth,final$Temp)
final[["TDeriv"]]<-spfun2(final$Temp,deriv=1)

#Plotting Values temp and Press
#Temp<-ggplot(final,aes(Temp))+geom_point(aes(y=depth),col="red")+
#    scale_y_reverse()+#limits=c(6000,5000)
#    scale_x_continuous()+theme_bw()#limits=c(90,110)
#Press<-ggplot(final,aes(Press))+geom_point(aes(y=depth),col="blue")+
#    scale_y_reverse()+theme_bw()
#grid.arrange(Temp,Press,ncol=2)

#Plotting Values Derivatives
#PDeriv<-ggplot(final,aes(PDeriv))+geom_point(aes(y=depth),col="purple")+
#  scale_y_reverse()+theme_bw()
#TDeriv<-ggplot(final,aes(TDeriv))+geom_point(aes(y=depth),col="purple")+
#  scale_y_reverse()+theme_bw()
#grid.arrange(TDeriv,PDeriv,ncol=2)


#what file would you like to write?
write.csv(final,file="PT_full_curves_UP.csv",row.names = F)

我正在使用的Excel电子表格包含两张纸,一张用于“上”通行证,另一张用于“下”通行证。但是代码是相同的,我只包含了一个。

所以我的问题是我是否弄乱了R中的派生函数在做什么?还是我引用的不是我想的。另外,我只在寻找压力/深度和温度/深度的一阶导数。

0 个答案:

没有答案