3

This may be a tall order, but here's what I need to be able to do...I will be given some scattered data in three dimensions (x,y,z). The end goal is to be able to have f(x,y) functions for each point on the surface. For example, given a coordinate (x,y) contained within the convex hull of the data, I would like the program to spit out f(x,y) = ax^3 + bx^2 + cx + dy^3 + ey^2 +fy + g, a bicubic function that fits the interpolated data at that point. This lead me to explore bicubic B-splines and splines in general.

I have been using SmoothBivariateSpline in the spicy.interpolate library to get the interpolated data, but I do not know where to go from here. I would like to throw out the end step all together and go straight to the intermediate step where the spline interpolation fits functions to each interval. So...I would write a program that, given a coordinate, finds out which interval it is contained in and returns a function, f(x,y), which describes the surface in that interval. Is this possible?

Cheers!

Ben Donovan
  • 199
  • 1
  • 7

1 Answers1

0

My first point is that you actually have scattered data (z) on two dimensions (x and y), if I understand you correctly.

I would write a program that, given a coordinate, finds out which interval it is contained in and returns a function, f(x,y), which describes the surface in that interval. Is this possible?

Yes, of course!

You could simply do the maths yourself (the bivariate spline might not be the most beautiful interpolation with respect to formula, but it's still somewhat manageable), or you could just get a list of coefficients, by calling get_coeffs() on the SmoothBivarianteSpline you've created. That will give you a surface-describing set of coefficients. I think the easiest way to understand the meaning of those is pointing you at the source code, so here you go; important ar tx, ty and c.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • Okay, that helps a bit. Still, I am confused about the coefficients and what they mean. Say if I had the coefficients and the knots, could I reconstruct the entire surface? Also, given these coefficients and knots, could I find the functions I am looking for? – Ben Donovan Jun 16 '15 at 17:28
  • 1
    The coefficients fully describe the polynomial that makes up the surface. That polynomial is the function you're looking for. – Marcus Müller Jun 17 '15 at 08:33
  • How would I go about doing that? I have looked at several academic papers and internet resources, but cannot seem to find how to determine the function of the surface at each point. Finding the value for Z at different points is fairly simple, it's finding the actual function that describes the surface at that point and its surrounding points that I struggle with. – Ben Donovan Jun 17 '15 at 19:45
  • You will need to look at the documentation of the library that scipy uses internally to do these fits. It's really just coefficients to a polynomial. – Marcus Müller Jun 18 '15 at 06:55