Re: How to speed up KRIG2D by 30x [message #86125 is a reply to message #86116] |
Wed, 09 October 2013 10:32   |
chris_torrence@NOSPAM
Messages: 528 Registered: March 2007
|
Senior Member |
|
|
Hi Mike,
This is fantastic. I'm working on adding in your change. However, I just found a different problem. If you look at the "Krig_Sphere" function within krig2d.pro, the code doesn't match the docs. The documentation states that for spherical covariance:
C(d) = C1 - 1.5 C1 (d/A) + 0.5 C1 (d/A)^3 if d < A
= C0 + C1 if d = 0
= 0 if d > A
Note that I threw in a factor of C1 on the first line (the docs are wrong).
Here is the code:
FUNCTION Krig_sphere, d, t
r = d/t[0]
v = t[1] + t[2] * (r * (1.5 - 0.5 * r *r) > 0)
z = where(d eq 0, count)
if count ne 0 then v[z] = 0
return, (t[1] + t[2]) - v
end
We are not clipping to 0 for d > A. In fact, for d > A, the function actually starts to go back up and levels off at the constant C1. You can see this with the following plot:
p = plot(krig_sphere(findgen(40), [10, 0.5, 1]))
I think the code should be something more like:
FUNCTION Krig_sphere, d, t
r = d/t[0]
v = t[2] * (1 - r * (1.5 - 0.5*r*r))
v[WHERE(d eq 0, /NULL)] = t[1] + t[2]
v[WHERE(d gt t[0], /NULL)] = 0
return, v
end
Thoughts?
-Chris
IDL Product Lead
ExelisVIS
|
|
|