2D Interpolation¶
Overview¶
The 2D interpolation module provides some methods to load 2D tables of data and computing values by interpolating. It only works for data provided in a rectangular grid.
- interp2d.new(x, y, z[, options])¶
Creates a new
Interp2D
object based on the provided data.x
andy
must be vectors containing the x and y values of the cartesian grid where the data lies.z
must be a matrix containing the data to be interpolated. To be acceptable the vectors and matrixx
,y
andz
must have respectively dimensions N, M and N x M.The optional argument
options
can provide the fieldtype
to be a string between “linear” and “cubic” to choose the kind of interpolation. It can also provide the fieldextrapolate
to a boolean that indicate if extrapolation outside of the domain is allowed. Theextrapolate
option is set totrue
by default.
- interp2d.new_from_csv(filename[, options])¶
Create a new
Interp2D
object based on a csv file. The data should be arranged in the following way:0 x1 x2 x3 ... xn y1 z11 z21 z31 ... zn1 y2 z12 z22 z32 ... zn2 y3 z13 z23 z33 ... zn3 ... ... ... ... ... ... ym z1m z2n z3n ... znn
The first cell in the table can be set to any value or left empty as it is not used.
The
options
optional arguments is the same than for theinterp2d.new()
function.
- interp2d.read_csv(filename)¶
Read a csv file formatted like for the function
new_from_csv()
and returns the vectors and matrixx
,y
andz
.