0

I have an interpolation problem. It should not be too complicated, but I can't find any valid solution.

I am working on a 2D wing section, I know the pressure (a scalar) on each point of coordinates (x_inf,y_inf) of the wing and I want to interpolate this pressure on an other discretization of the wing ((x_profil,y_profil) coordinates). Here is a picture of the profile I have ((x_inf,y_inf), green) and the grid I want to interpolate on ((x_profil,y_profil), red). Points for interpolation. The data x_inf, y_inf, p_inf are numpy arrays of the same size (they are extracted from a specific file). x_profil, y_profil are also numpy arrays of the same size (but different from _inf data).

I first tried interp2d function, but the result is an array of size the square of the size of the points on which I interpolate.

pressure=interp2d(x_inf,y_inf,p_inf)
p_profil=pressure(x_profil,y_profil)

I also tried to interpolate only over the x axis with interp1d but this doesn't work either. Setting the kind of interpolation to "nearest" or "zero" works, but there are "holes" in the interpolation, as you can see in this figure : presure interpolation, where the green points are the input data and the red the interpolated.

pressure=interp1d(x_inf,p_inf,kind='zero',bounds_error=False)
p_profil=pressure(x_profil)

I am using python 2.7.10, scipy 0.16.1 and numpy 1.9.2 running on windows 7 with Enthought Canopy.

Does anyone have an idea of how I could solve my problem ?

Thank's a lot in advance !

U.Dhome
  • 1
  • 1
  • Are you measuring air pressure around the wing or the force on the wing caused by pressure? One requires a 2D array of pressure values, and one requires a 1D array. – Andrew Williamson Jan 19 '16 at 21:32
  • I am measuring air pressure around the wing, not the force. It could also be another scalar value such as density or temperature. – U.Dhome Jan 19 '16 at 22:11
  • So it's not limited to the profile of the wing, but it could be a foot above or below as well? – Andrew Williamson Jan 19 '16 at 22:12
  • You will probably need to define another parameter, T, so you can have a function which takes any T and returns coordinates and pressure – Andrew Williamson Jan 19 '16 at 22:14
  • In this case I need the value on the skin. I am comparing data from simulation and from experiments in a wind tunnel. – U.Dhome Jan 19 '16 at 22:14

1 Answers1

1

It sounds like what's happening is the interp2d function thinks you're pasing it a regular grid. From the numpy Docs:

> Arrays defining the data point coordinates. If the points lie on a regular grid, x can specify the column coordinates and y the row coordinates, for example:

x, y : array_like x = [0,1,2]; y = [0,3]; z = [[1,2,3], [4,5,6]] Otherwise, x and y must specify the full coordinates for each point, for example:

x = [0,1,2,0,1,2]; y = [0,0,0,3,3,3]; z = [1,2,3,4,5,6] If x and y are multi-dimensional, they are flattened before use.

z : array_like The values of the function to interpolate at the data points. If z is a multi-dimensional array, it is flattened before use. The length of a flattened z array is either len(x)*len(y) if x and y specify the column and row coordinates or len(z) == len(x) == len(y) if x and y specify coordinates for each point.

It sounds like you need to force x and y to be explicit to the full coordinates

Owen Hempel
  • 434
  • 2
  • 8
  • How can this "force x and y to be explicit to the full coordinates" be done? it seems there is no input argument to enforce this.... – shelper Aug 02 '19 at 18:16