[SciPy-User] weighted griddata

Charles R Harris charlesr.harris@gmail....
Fri Sep 17 00:10:10 CDT 2010


On Thu, Sep 16, 2010 at 10:41 PM, Adam Ryan <adamdryan@gmail.com> wrote:

> Thanks to all for the input.  I'm a Python programmer trying to
> understand the math I need.  My comments in line...
>
> > So you have data
> >
> >        (x[i], y[i], t[i])
> >
> > and you'd like to fit a 2-D surface to it? I guess you used griddata to
> > find the graph of the function y = f(x, t)?
>
> Right, but griddata alone just fills in the grid, it doesn't return a
> function, and as you rightly point out, only fills in and doesn't
> smooth the original data.
>
> > You may need to fiddle with the smoothing parameter `s=...` for
> > SmoothBivariateSpline.
>
> I was using interpolate.SmoothBivariateSpline previously and had good
> results when it worked, but I struggled with the smoothing parameter
> for so long I had to put it down.  I could not figure out how to
> consistently calculate/estimate/predict a smoothing factor (from the
> data) that was not too low (and never return) or too high (and give
> blocky results).
>
> Is there a way to calculate an optimal smoothing factor from a data set?
>
> > Or, you can maybe fit a 1-D spline (UnivariateSpline) at each `t`
> > separately, and use the smoothed results in griddata. The 1D spline
> > routines are robust.
>
> Tried that too, but that didn't really do the trick, since the actual
> position of a point is more a function of the neighbors in time then
> along shore, due to obstacles, etc.
>
> > No, I tell a lie, the Clough-Tocher 2D spline could easily be used for
> > weighed data smoothing. The only change needed would be to adjust the
> > gradient estimation routine ...
>
> Yea, that's what I was thinking, ha ha, I just don't know how.  Pointers?
>
> > I think the rbf routines might be appropriate.
>
> I've used the rbf routines to ortho-rectify our barrel-distorted
> images (where the data comes from),


How well did it work? I've been thinking of trying rbf for some
inkblot-distorted images -- nothing so simple as barrel-distortion here.

> but here the positional data is
> not based around a center point.  Or maybe I don't understand the rbf
> stuff fully.  How would I use weights with the rbf stuff?
>
> > If you use the sqrt of the squares it is a Sobolev space due to the fact
> > that the first derivative can be omitted. but there are lots of
> variations
> > on this theme. Another is least squares with, say, lambda times the
> square
> > of the second difference added to the normal squared deviation. That
> tends
> > to keep the wiggles down but is very sensitive to lambda. There might
> even
> > be an official name for that method, it goes back a long ways.
>
> For clarification, all the points of a line have the same t value, but
> each point has a weight of 0 to 1.  Would LSQBivariateSpline be any
> better than SmoothBivariateSpline?  Again, the smoothing factor drove
> me nuts.
>
>
Probably. You need to pick the knot points, which sort like picking the
smoothing factor but more robust. It's a least squares fit with
curves/surfaces that are less "stiff" than polynomials. I don't understand
the points of a line bit, you can probably fit the surface directly. Anne's
suggestion of looking into kriging is also worth following up.


Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100916/fc31c544/attachment.html 


More information about the SciPy-User mailing list