IDL code:
; Define a procedure to return γ(h) and the partial derivatives according Equation(7)
pro Semi_Var,X,A,F,pder
F=A[0]+A[1](1.5(X/A[2])-0.5*(X/A[2])^3)
if n_params() ge 4 then begin
pder=fltarr(n_elements(X),3)
pder[,0]=1
pder[,1]=(1.5*(X/A[2])-0.5*(X/(A[2]^3)
pder[,2]=1.5A[1]*(X3/(A[2]4)-(X/A[2])^2))
endif
end
; Compute the fit to the function
; Input the independent h and dependent variables r calculated according Equation (6)
; Define a vector of weights.
weights = 1.0/r
; Provide an initial guess of the function’s parameters.
A = [1.0, 5.0, 30.0]
; Compute the parameters.
yfit = CURVEFIT(h, r, weights, A, SIGMA, FUNCTION_NAME=‘Semi_Var’)
C0=A[0] & C=A[1] & a=A[2]
Fitting results:
Location: 29.8065N,121.7873E
Landsat Data: LT05_L1TP_20091021 (Red Band)
1.0 Km: C0=3.70000, C=8.44564, a=739.253
1.5 Km: C0=3.26735, C=5.64539, a=870.949
2.0 Km: C0=3.33918, C=4.27791, a= 985.988