I am writing a program using python 2.7 and am having difficulting pinpointing the best way to interpolate/fit some rectangular data.
I have a bunch of known data points of the format z=f(x,y) where x and y are evenly spaced on a grid. My x points range from 0 to 100 in increments of 0.1. My y points range from 0 to 100 in increments of 2.
My issue in interpolating or fitting this data is the large spacing between my y data coordinates. I am looking for the best way to fit this data so that I can evaluate the height Z for any (X,Y) coordinate pair. I want the resulting surface to be as smooth as possible. The conventional methods using griddata, or rectbivariatespline do no produce smooth surfaces - seemingly because the space between my y points is much greater than the space between my x points.
One option I considered was to use polyfit (or something similar) to fit a polynomial to each slice (the Y vs Z curve at each X) then to interpolate these slices together to produce a smoother surface. This seems like kind of a roundabout way of doing things. Is that my best option?
example of fitting a slice to a polynomial:
If fit to a polynomial, each of my slices (Y vs Z at a fixed X) is roughly gaussian or bimodal. They are fairly simple distributions.
My goal is to be able to produce a smooth, closely fit surface for display in 3D or on a pcolor style chart. I need to avoid swings past Zmax and Zmin. I know this is an issue when using splines.
my goal:
Thank you for any help you can provide. I will watch this thread carefully and respond quickly if you need any elaboration.
EDIT:
From what I have read, it seems like what I am looking for is a shape preserving interpolation method in python for 2d data. I need something along the lines of pchip for matlab, but for a surface. I have looking through all the documentation and can't find anything shape preserving that will give me a smooth surface.