comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » New Fast Kriging Semivariogram Spherical Model Incorrect?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
New Fast Kriging Semivariogram Spherical Model Incorrect? [message #86172] Wed, 16 October 2013 07:10 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

I have been writing a new cgKrig2D function for my own use that provides
orders of magnitude faster kriging for general use than the (extremely!)
slow Krig2D function that is supplied with all currently released
versions of IDL. In doing so, I have come to believe that the Spherical
modeling function in both the old version of Krig2D and in the new
version Chris released here last week is incorrect.

I base my conclusion on the mathematical models described here:


http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html #//009z00000
076000000.htm

The original version of the spherical mathematical model used this code:

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

Chris believed this to be wrong, and offered this code in the new,
faster, version:

r = d/t[0] < 1
v = t[2]*(1 - r*(1.5 - 0.5*r*r))
v[WHERE(r eq 0, /NULL)] = t[1] + t[2]
return, v

This also appears to be incorrect to me. I think the correct version is
something like this:

r = d/t[0]
v = t[2]*(1 - r*(1.5 - 0.5*r*r)) + t[1]
v[WHERE(d eq 0, /NULL)] = 0
v[WHERE(d gt t[0], /NULL)] = t[1] + t[2]
return, v

What think you experts?

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: New Fast Kriging Semivariogram Spherical Model Incorrect? [message #86176 is a reply to message #86172] Wed, 16 October 2013 07:54 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> I have been writing a new cgKrig2D function for my own use that
provides
> orders of magnitude faster kriging for general use than the (extremely!)
> slow Krig2D function that is supplied with all currently released
> versions of IDL. In doing so, I have come to believe that the Spherical
> modeling function in both the old version of Krig2D and in the new
> version Chris released here last week is incorrect.

Now I think the Exponential modeling function is incorrect, too, based
on this reference (and the one I provided previously):

http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/ cs490-
94to95/clang/kriging.html

It is listed as:

r = t[2] * exp((-3./t[0]) * d)
r[WHERE(d eq 0, /NULL)] = t[1] + t[2]
return, r

According to my references, this should be:

r = t[2] * exp((-3./t[0]) * d)
r[WHERE(d eq 0 /NULL)] = 0
return, r

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: New Fast Kriging Semivariogram Spherical Model Incorrect? [message #86183 is a reply to message #86176] Wed, 16 October 2013 21:00 Go to previous messageGo to next message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Wednesday, October 16, 2013 8:54:43 AM UTC-6, David Fanning wrote:
> David Fanning writes:
>
>
>
>> I have been writing a new cgKrig2D function for my own use that
>
> provides
>
>> orders of magnitude faster kriging for general use than the (extremely!)
>
>> slow Krig2D function that is supplied with all currently released
>
>> versions of IDL. In doing so, I have come to believe that the Spherical
>
>> modeling function in both the old version of Krig2D and in the new
>
>> version Chris released here last week is incorrect.
>
>
>
> Now I think the Exponential modeling function is incorrect, too, based
>
> on this reference (and the one I provided previously):
>
>
>
> http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/ cs490-
>
> 94to95/clang/kriging.html
>
>
>
> It is listed as:
>
>
>
> r = t[2] * exp((-3./t[0]) * d)
>
> r[WHERE(d eq 0, /NULL)] = t[1] + t[2]
>
> return, r
>
>
>
> According to my references, this should be:
>
>
>
> r = t[2] * exp((-3./t[0]) * d)
>
> r[WHERE(d eq 0 /NULL)] = 0
>
> return, r
>
>
>
> Cheers,
>
>
>
> David
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Hi David,

I think that our two methods actually agree. I believe that your code is calculating the "variogram" instead of the "covariance". So:
Mine = C0 + C1 - Yours

By the way, in the spherical case, you have that extra line with WHERE(d gt t[0]). I don't think you need this if you use the "r = d/t[0] < 1". The < 1 will clamp the values so the equation works out. It might be faster to do the <1, but I can't remember whether I tested the speed with the 2 different ways.

Anyway, on a slightly different note, it would be *great* if you didn't create your own cgKrig2D. I worry that we are fragmenting the IDL user base and creating confusion. If there is something wrong with the latest version of Krig2D, we should figure out the right solution and fix the code that ships with IDL. If people want the faster code, it has already been posted here, and will be made available in the official release in just a couple of months or less.

Thanks in advance for considering my proposal.

Cheers,
Chris
VIS
Re: New Fast Kriging Semivariogram Spherical Model Incorrect? [message #86184 is a reply to message #86183] Wed, 16 October 2013 21:20 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Chris Torrence writes:

> Anyway, on a slightly different note, it would be *great* if you didn't create your own cgKrig2D. I worry that we are fragmenting the IDL user base and creating confusion. If there is something wrong with the latest version of Krig2D, we should figure out the right solution and fix the code that ships with IDL. If people want the faster code, it has already been posted here, and will be made available in the official release in just a couple of months or less.

Yes, I understand this and I'm sympathetic. I don't like to duplicate
code either. And I haven't actually released this. I'm just trying to
make it work with some mapping software I've been working on. Since the
other code is in the Coyote Library, I have the age old problem of what
to do with code I need to make it work. Relying on code that will come
out in IDL 8.3 is not that attractive to me, since I think the vast
majority of the people who use the Coyote Library don't have the latest
version of the software. That's basically why I went to the trouble of
writing my own. Plus, I wanted to learn how it works. Nothing like
writing your own algorithms to teach you how little you know about
something, I guess. ;-)

No, I am happy to use your software. I just want to be sure it works.
You probably haven't gotten around to it yet, but I can seem to get the
new software working with gridded input. I really don't know what that
is about!

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: New Fast Kriging Semivariogram Spherical Model Incorrect? [message #86186 is a reply to message #86184] Wed, 16 October 2013 21:24 Go to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Wednesday, October 16, 2013 10:20:13 PM UTC-6, David Fanning wrote:
> Chris Torrence writes:
>
>
>
>> Anyway, on a slightly different note, it would be *great* if you didn't create your own cgKrig2D. I worry that we are fragmenting the IDL user base and creating confusion. If there is something wrong with the latest version of Krig2D, we should figure out the right solution and fix the code that ships with IDL. If people want the faster code, it has already been posted here, and will be made available in the official release in just a couple of months or less.
>
>
>
> Yes, I understand this and I'm sympathetic. I don't like to duplicate
>
> code either. And I haven't actually released this. I'm just trying to
>
> make it work with some mapping software I've been working on. Since the
>
> other code is in the Coyote Library, I have the age old problem of what
>
> to do with code I need to make it work. Relying on code that will come
>
> out in IDL 8.3 is not that attractive to me, since I think the vast
>
> majority of the people who use the Coyote Library don't have the latest
>
> version of the software. That's basically why I went to the trouble of
>
> writing my own. Plus, I wanted to learn how it works. Nothing like
>
> writing your own algorithms to teach you how little you know about
>
> something, I guess. ;-)
>
>
>
> No, I am happy to use your software. I just want to be sure it works.
>
> You probably haven't gotten around to it yet, but I can seem to get the
>
> new software working with gridded input. I really don't know what that
>
> is about!
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")

Sounds great David. Thanks for understanding. Also, see my other post regarding the bug in my code. :-)
-Chris
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: reversing axes ranges with IDL 8 graphics
Next Topic: Store differents size of .fits into one single array

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:42:35 PDT 2025

Total time taken to generate the page: 0.00352 seconds