[GRASS-user] 4D radial basis function interpolation / extrapolation possible?

Dear Grass'ers,

I am new to Grass and wondered if Grass provides a radial basis
function method to interpolate / extrapolate 4D data. Basically, I
need to get (interpolate / extrapolate) a velocity field in a
three-dimensional volume given several sampling data in the space. If
written in a function format, it looks like

result_new = f(x, y, z, result, xnew, ynew, znew);

where, x, y, z, and result are known.
(xnew, ynew, znew) represent a point in space and result_new returns the result.

Can someone please advice? If Grass cannot handle this, can someone
please point other libraries to me that might be able to do so.
Matlab's griddata3 only does linear interpolation that doesn't help.

          Thank you very much!

               With best regards,
                      --Jian
     Dept. of Computer Science
     Brown University

Dear Grass'ers,

Please don't mind the previous email I sent. Figured out an algorithm
to do 4D interpolation! Sorry for the traffic! And thanks all the
same!

     Best regards,
        --Jian

On 10/7/07, Jian Chen <jianchen0@gmail.com> wrote:

Dear Grass'ers,

I am new to Grass and wondered if Grass provides a radial basis
function method to interpolate / extrapolate 4D data. Basically, I
need to get (interpolate / extrapolate) a velocity field in a
three-dimensional volume given several sampling data in the space. If
written in a function format, it looks like

result_new = f(x, y, z, result, xnew, ynew, znew);

where, x, y, z, and result are known.
(xnew, ynew, znew) represent a point in space and result_new returns the result.

Can someone please advice? If Grass cannot handle this, can someone
please point other libraries to me that might be able to do so.
Matlab's griddata3 only does linear interpolation that doesn't help.

          Thank you very much!

               With best regards,
                      --Jian
     Dept. of Computer Science
     Brown University

Jian Chen wrote:

I am new to Grass and wondered if Grass provides a radial basis
function method to interpolate / extrapolate 4D data. Basically, I
need to get (interpolate / extrapolate) a velocity field in a
three-dimensional volume given several sampling data in the space. If
written in a function format, it looks like

result_new = f(x, y, z, result, xnew, ynew, znew);

where, x, y, z, and result are known.
(xnew, ynew, znew) represent a point in space and result_new returns
the result.

Can someone please advice? If Grass cannot handle this, can someone
please point other libraries to me that might be able to do so.
Matlab's griddata3 only does linear interpolation that doesn't help.

just an idea, probably applies just as well to matlab's griddata3 too.
(n.b. I am not sure if this is mathematically appropriate...)

First in matlab use the cart2sph function to convert velocity xyz vector
components into magnitude, azimuth angle, and elevation angle.

Then write a text file with:
x,y,z,magnitude,azimuth,elevation

Next load in your data into GRASS as 3D vector points with v.in.ascii.
Magnitude, azimuth, and elevation will be numerical attribute columns.
Next set 2D region settings with g.region.
Next interpolate each component with v.vol.rst into 3 different raster-3D
cubes.

Finally use a r3.mapcalc expression to create u,v,w components from
magnitude,az,elev.
  (2D trig hints for that can be found in the d.rast.arrow help page)

r3.out.ascii or r3.to.rast+r.out.mat back to matlab.

?
Hamish

Dear Hamish,

Thank you very much for your reply! Your approach might work!
I was able to create the vector field by writing my own radial basis
function (RBF) method. I did this because RBF is sensitive to the
parameters chosen and it often requires trial and error (or learning
if the prog is smart enough).

  Thanks all the same!!

        Best regards,
              --Jian

On 10/8/07, Hamish <hamish_nospam@yahoo.com> wrote:

Jian Chen wrote:
> I am new to Grass and wondered if Grass provides a radial basis
> function method to interpolate / extrapolate 4D data. Basically, I
> need to get (interpolate / extrapolate) a velocity field in a
> three-dimensional volume given several sampling data in the space. If
> written in a function format, it looks like
>
> result_new = f(x, y, z, result, xnew, ynew, znew);
>
> where, x, y, z, and result are known.
> (xnew, ynew, znew) represent a point in space and result_new returns
> the result.
>
> Can someone please advice? If Grass cannot handle this, can someone
> please point other libraries to me that might be able to do so.
> Matlab's griddata3 only does linear interpolation that doesn't help.

just an idea, probably applies just as well to matlab's griddata3 too.
(n.b. I am not sure if this is mathematically appropriate...)

First in matlab use the cart2sph function to convert velocity xyz vector
components into magnitude, azimuth angle, and elevation angle.

Then write a text file with:
x,y,z,magnitude,azimuth,elevation

Next load in your data into GRASS as 3D vector points with v.in.ascii.
Magnitude, azimuth, and elevation will be numerical attribute columns.
Next set 2D region settings with g.region.
Next interpolate each component with v.vol.rst into 3 different raster-3D
cubes.

Finally use a r3.mapcalc expression to create u,v,w components from
magnitude,az,elev.
  (2D trig hints for that can be found in the d.rast.arrow help page)

r3.out.ascii or r3.to.rast+r.out.mat back to matlab.

?
Hamish

> Jian Chen wrote:
> > I am new to Grass and wondered if Grass provides a radial basis
> > function method to interpolate / extrapolate 4D data. Basically, I
> > need to get (interpolate / extrapolate) a velocity field in a
> > three-dimensional volume given several sampling data in the space. If
> > written in a function format, it looks like
> >
> > result_new = f(x, y, z, result, xnew, ynew, znew);
> >
> > where, x, y, z, and result are known.
> > (xnew, ynew, znew) represent a point in space and result_new returns
> > the result.
> >
> > Can someone please advice? If Grass cannot handle this, can someone
> > please point other libraries to me that might be able to do so.
> > Matlab's griddata3 only does linear interpolation that doesn't help.
>

Hamish wrote:

> just an idea, probably applies just as well to matlab's griddata3 too.
> (n.b. I am not sure if this is mathematically appropriate...)
>
> First in matlab use the cart2sph function to convert velocity xyz vector
> components into magnitude, azimuth angle, and elevation angle.
>
> Then write a text file with:
> x,y,z,magnitude,azimuth,elevation
>
> Next load in your data into GRASS as 3D vector points with v.in.ascii.
> Magnitude, azimuth, and elevation will be numerical attribute columns.
> Next set 2D region settings with g.region.
> Next interpolate each component with v.vol.rst into 3 different raster-3D
> cubes.
>
> Finally use a r3.mapcalc expression to create u,v,w components from
> magnitude,az,elev.
> (2D trig hints for that can be found in the d.rast.arrow help page)
>
> r3.out.ascii or r3.to.rast+r.out.mat back to matlab.

Jian Chen wrote:

Thank you very much for your reply! Your approach might work!
I was able to create the vector field by writing my own radial basis
function (RBF) method. I did this because RBF is sensitive to the
parameters chosen and it often requires trial and error (or learning
if the prog is smart enough).

For the archive, note that I had the above all backwards. You have to transform
spherical coords into xyz/uvw components to do the interpolation, then convert
the result back to radius,azimuth,elevation. Otherwise you have problems with
the averaging of 359 and 1 degree = 180.

(d^n)*log(d) for the RBF? or IDW 1/(d^n)? If you didn't spend a few minutes
looking at the v.vol.rst and v.surf.rst regularized spline interpolation
modules, they're worth a look.

Hamish

      ____________________________________________________________________________________
Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us. http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7