bilinear

View page source

Bilinear Spline Interpolation

Prototype

# at_cascade.bilinear
def bilinear(
   table,
   x_name,
   y_name,
   z_list
) :
   assert type(table) == list
   assert type(x_name) == str
   assert type(y_name) == str
   assert type(z_list) == list
   # ...
   assert type(x_grid) == list
   assert type(y_grid) == list
   assert type(spline_dict) == dict
   return (x_grid, y_grid, spline_dict)

x_name

is the name in table for the x variable in the interpolation.

y_name

is the name in table for the y variable in the interpolation.

z_list

Each element of z_list is a str specifying the name in table for a z variable in the interpolation.

table

Each element of table is a dict. The values x_name , y_name and each element of z_list must be a key in each of the dictionaries. Furthermore, the corresponding dictionary values must be str or float . This table must be non-empty.

Rectangular Grid

For each x in x_grid and y in y_grid there must be one, and only one, row in table with that x and y value. If this is not the case, bilinear will return with spline_dict equal to None .

x_grid

Is the a sorted list of values that appear in the x_name column of table . Duplicates are not included in this list.

y_grid

Is the a sorted list of values that appear in the y_name column of table . Duplicates are not included in this list.

spline_dict

Is a dict of spline functions with keys equal to each z_name in z_list . The function call

   z = spline_dict[z_name](x, y)

sets z to the value of the spline for z_name .

  1. The values x and y are float or int .

  2. The value z is a float .

  3. The function is extended as constant with respect to x (y) for values of x (y) outside the limits of x_grid (y_grid).

Example

example_bilinear