Two Variogram Components in Kriging
How would i formulate an expression to get two variogram components in one statement. I'm using GridData3 with simple kriging. In my variogram. I want a linear model as well as a nugget effect. Apparently if you do not specify a variogram component, you get the linear model by default. But I have this statement ahead of the Griddata3 statement...
KrigComp = Srf.NewVarioComponent(VarioType:=Surfer.SrfVarioType.srfVarNugget, Param1:=1, Param2:=1)
Srf.GridData3(DataFile:=EM.EMDir & EM.GpsemFile, xCol:=1, yCol:=2, zCol:=zColNum, DupMethod:=Surfer.SrfDupMethod.srfDupFirst, Algorithm:=Surfer.SrfGridAlgorithm.srfKriging, ShowReport:=False, SearchEnable:=True, SearchNumSectors:=8, SearchMinData:=5, SearchDataPerSect:=3, SearchMaxEmpty:=8, SearchRad1:=EM.Radii, SearchRad2:=EM.Radii, KrigType:=Surfer.SrfKrigType.srfKrigPoint, KrigDriftType:=Surfer.SrfDriftType.srfDriftNone, KrigVariogram:=KrigComp, OutGrid:=OutQFile)
This works fine, but now KrigVariogram is set to KrigComp (ie a nugget effect). Is it possible to have a compound statement to also get a linear model? I use VB.net, but if you can express it in Scripter, I can adapt it to VB.

Hi Dave,
Create the variogram first and then use the variogram with Kriging. For example:
Sub Main
Dim SurferApp As Object
Set SurferApp = CreateObject("Surfer.Application")
SurferApp.Visible = True
Dim Plot As Object
Set Plot = SurferApp.Documents.Add
MyDataFile = SurferApp.Path+"\Samples\demogrid.dat"
'Create a variogram
Set MyVariogram = Plot.Shapes.AddVariogram(MyDataFile)
'Create 3 variogram components
Dim VarioComponents(1 To 3) As Object
Set VarioComponents(1) = SurferApp.NewVarioComponent(srfVarExponential, Param1:=3, Param2:=4.5)
Set VarioComponents(2) = SurferApp.NewVarioComponent(VarioType:=srfVarLogarithmic,Param1:=2, Param2:=2.5, AnisotropyRatio:=0.5, AnisotropyAngle:=52)
Set VarioComponents(3) = SurferApp.NewVarioComponent(VarioType:=srfVarPower,Param1:=2.1, Param2:=3.2, Power:=1.9, AnisotropyRatio:=0.8, AnisotropyAngle:=125)
'Change the parameters for variogram component 2 (Logarithmic) to Nugget Effect
VarioComponents(2).Set(VarioType:=srfVarNugget, Param1:=0.2, Param2:=2.3)
'Set the AutoFit parameter limits for component 1 (Exponential):
'Scale of variogram component 1
VarioComponents(1).SetFitLimits(Param:=srfVarParam1, LowerLimit:=0.5, UpperLimit:=50)
'Length of variogram component 1
VarioComponents(1).SetFitLimits(Param:=srfVarParam2, LowerLimit:=0.25, UpperLimit:=250)
' Anisotropy Ratio of variogram component 1
VarioComponents(1).SetFitLimits(Param:=srfVarParamRatio, LowerLimit:=1, UpperLimit:=10)
'Anisotropy Angle of variogram component 1
VarioComponents(1).SetFitLimits(Param:=srfVarParamAngle, LowerLimit:=180, UpperLimit:=180)
'Use the components in the variogram
outgrid = "C:\temp\Forum_Variogram.grd"
MyVariogram.Model=VarioComponents
SurferApp.GridData3 (Datafile:=MyDataFile, KrigVariogram:=VarioComponents, Outgrid:=outgrid)
Plot.Shapes.AddContourMap(GridFileName:=outgrid)
End SubThanks,
Kari

Hi Dave,
It's not the same as in the user interface. There isn't a way to add a component  you create new ones. So you do have to explicitly state which components you want, including the linear model. For example, this will only use the Nugget Effect, not Nugget+Linear.
Sub Main
Dim SurferApp As Object
Set SurferApp = CreateObject("Surfer.Application")
SurferApp.Visible = True
Dim Plot As Object
Set Plot = SurferApp.Documents.Add
Dim VarioComponent As Object
Set VarioComponent = SurferApp.NewVarioComponent(VarioType:=srfVarNugget, Param1:=3.1, Param2:=4.7)
SurferApp.GridData(DataFile:=SurferApp.Path+"\samples\Demogrid.dat", Algorithm:=srfKriging, ShowReport:=False, KrigVariogram:=VarioComponent, OutGrid:="c:\temp\Demogrid_V.grd")
Set Map = Plot.Shapes.AddContourMap(GridFileName:="c:\temp\Demogrid_V.grd")
End SubThanks,
Kari

OK, thanks Kari. But I'm still wondering about this. When you go and manually create a kriging variogram, under Advanced Options, the Linear model is already in there and you just Add the nugget effect. In Scripter, is this also the way it works, that the linear model is there by default and you simply add whatever other components you want, OR, do you have to explicitly state which components you want in the variogram, including the linear model? 
I think I might bail on my variogram algorithm from kriging in favor of natural neighbor. It appears to be a bit more simple to program and appears to give about the same results as kriging. VB.net has changed something and now I can't get the KrigVariogram component to work, though it did until recently. Natural neighbor seems to work just fine with fewer moving parts.
Please sign in to leave a comment.
Comments
5 comments