problems with DCA hyperbolic function

Hi there:

I am using sportfire 6.5 but wanted to install the DCA hyperbolic function provided for free. I followed the video and a traning video in how to create a data function and I managed to do it since in this version I can not import the *.sfd directly I openenend the script and take the relevant parts and copy and paste and 'commented' the ones not required.

I definied my columns input and outputs and click run but I always get the same

Could not execute function call.

TIBCO Enterprise Runtime for R returned an error: 'Error in eval(expr = , envir = , enclos = ) : object "gt" not found'.

   at Spotfire.Dxp.Data.DataFunctions.Executors.LocalFunctionClient.OnExecuting(FunctionClient funcClient)

   at Spotfire.Dxp.Data.DataFunctions.Executors.AbstractFunctionClient.<RunFunction>d__0.MoveNext()

   at Spotfire.Dxp.Data.DataFunctions.Executors.SPlusFunctionExecutor.<ExecuteFunction>d__3.MoveNext()

   at Spotfire.Dxp.Data.DataFunctions.DataFunctionExecutorService.<ExecuteFunction>d__6.MoveNext()

 

The script as provided and the one I can copy and paste below.

#Programing Language: TERR V4.1

#Required Packages: None

#Description:This Data Function calculates a Hyperbolic DCA using your production data.# [TERR] Basic DCA

 

# Peter Shaw

# "Fri Jul 08 14:44:24 2016"

 

# Inputs

#   col.Date        # [Analysis Data].[${well.date}]

#   col.Production  # [Analysis Data].[${well.production}]

 

# Outputs

#   Hyp.qi

#   Hyp.b 

#   Hyp.Di

 

#TIBCO Component Exchange License

#Copyright (c) 2016 TIBCO Software Inc. All Rights Reserved.

#Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

#1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

#2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

#3. Neither the name of TIBCO Software Inc.  nor the names of any contributors may  be used to endorse or promote products derived from this software without specific prior written permission.

#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT OWNER AND CONTRIBUTORS  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE

 

#TimeStamp=paste(date(),Sys.timezone())

#tdir = 'C:/Demo' # place to store diagnostics if it exists (otherwise do nothing)

#if(file.exists(tdir) &amp file.info(tdir)$isdir) suppressWarnings(try(save(list=ls(), file=paste(tdir,'/BasicDCA.in.RData',sep=''), RFormat=T )))

 

# remove(list=ls()); load(file='C:/Demo/BasicDCA.in.RData'); print(TimeStamp)

 

#------------------------------------------------------------------------------

Hyp.q.forward.fun = function( time, Hyp.qi, Hyp.b, Hyp.Di ){ # time in days

  # Peter Shaw

  # e.g. SPE 98042 (4)

  Hyp.q.theo = Hyp.qi*(1 + Hyp.b*Hyp.Di*time)^(-1/Hyp.b)

  return(Hyp.q.theo)

}

#------------------------------------------------------------------------------

residfun = function(x,x.days,y.prod){

  Hyp.qi = x[1]

  Hyp.b  = x[2]

  Hyp.Di = x[3]

  q.theo = (365.25/12)*Hyp.q.forward.fun(

    time=x.days,

    Hyp.qi=Hyp.qi,

    Hyp.b=Hyp.b,

    Hyp.Di=Hyp.Di)

  #plot(x.days,y.prod); lines(x.days,q.theo)

  residual = sqrt(sum((q.theo-y.prod)^2))

  return(residual)

}

#------------------------------------------------------------------------------

min.data = 3

 

result = data.frame(

  time.days =  numeric(0),

  time.months = numeric(0),

  production = numeric(0),

  theo = numeric(0)

)

Hyp.qi       =as.numeric(NA)

Hyp.b        =as.numeric(NA)

Hyp.Di.daily =as.numeric(NA)

Hyp.Di.annual=as.numeric(NA)

 

ok = length(col.Production)&gt;0

if(ok) ok = length(col.Date) == length(col.Production)

 

if(ok){

  u.order = order(col.Date)

 

  col.Date       = col.Date[u.order]

  col.Production = col.Production[u.order]

 

  t.days = as.numeric(difftime(col.Date,min(col.Date),units="days"))

  t.months = round(t.days*12/365.25)

 

  u0 = which.max(col.Production)

  u = u0:length(col.Production)

 

  x.months = t.months[u]

  x.days = t.days[u]

  y.prod = col.Production[u]

 

  x0 = c(y.prod[1]*12/365.25,1.00,0.005)

 

  optim.result = optim(

    par = x0,

    fn=residfun,

    x.days=x.days, y.prod=y.prod

  )

 

  Hyp.qi = optim.result$par[1]*(365.25/12) # Monthly

  Hyp.b  = optim.result$par[2]

  Hyp.Di.daily  = optim.result$par[3]

  Hyp.Di.annual = optim.result$par[3]*365.25 # Annualized

 

  result = data.frame(

    time.days   = x.days,

    time.months = x.months,

    production = y.prod

  )

}

#</Script>

#  <Language>TERR</Language>

#  <Input>

#    <Name>col.Date</Name>

#    <Type>Column</Type>

#    <DisplayName>col.Date</DisplayName>

#    <Description />

#    <AllowedDataType>Date</AllowedDataType>

#  </Input>

#  <Input>

#    <Name>col.Production</Name>

#    <Type>Column</Type>

#    <DisplayName>col.Production</DisplayName>

#    <Description />

#    <AllowedDataType>Integer</AllowedDataType>

#    <AllowedDataType>Double</AllowedDataType>

#    <AllowedDataType>Float</AllowedDataType>

#  </Input>

#  <Output>

#    <Name>Hyp.qi</Name>

#    <Type>Value</Type>

#    <DisplayName>Hyp.qi</DisplayName>

#    <Description />

#  </Output>

#  <Output>

#    <Name>Hyp.b</Name>

#    <Type>Value</Type>

#    <DisplayName>Hyp.b</DisplayName>

#    <Description />

#  </Output>

#  <Output>

#    <Name>Hyp.Di.daily</Name>

#    <Type>Value</Type>

#    <DisplayName>Hyp.Di.daily</DisplayName>

#    <Description />

#  </Output>

#  <Output>

#    <Name>Hyp.Di.annual</Name>

#    <Type>Value</Type>

#    <DisplayName>Hyp.Di.annual</DisplayName>

#    <Description />

#  </Output>

#  <Output>

#    <Name>result</Name>

#    <Type>Table</Type>

#    <DisplayName>result</DisplayName>

#    <Description />

#  </Output>

#  <Description />

#  <AllowCaching>false</AllowCaching>

#</ScriptFunctionDefinition>

 

 

 

 

Attachments

AttachmentSize
Binary Data dca-example.dxp50.52 KB
File dca-example.xlsx164.38 KB

(2) Answers

Login