Post · 2 min read· pp. 804–805

aerosandbox.modeling.interpolation

Classes

InterpolatedModelA model that is interpolated to structured (i.e., gridded) N-dimensional data. Maps from R^N -> R^1.

Module Contents

class aerosandbox.modeling.interpolation.InterpolatedModel(x_data_coordinates, y_data_structured, method='bspline', fill_value=np.nan) : Bases: aerosandbox.modeling.surrogate_model.SurrogateModel

code
A model that is interpolated to structured (i.e., gridded) N-dimensional data. Maps from R^N -> R^1.

You can evaluate this model at a given point by calling it just like a function, e.g.:

```default

y = my_interpolated_model(x)

code

    The input to the model (x in the example above) is of the type:
    :   - in the general N-dimensional case, a dictionary where: keys are variable names and values are float/array
        - in the case of a 1-dimensional input (R^1 -> R^1), it can optionally just be a float/array.

    If you’re not sure what the input type of my\_interpolated\_model should be, just do:

    ```default
>>> print(my_interpolated_model) # Displays the valid input type to the model
code
The output of the model (y in the example above) is always a float or array.

See the docstring \_\_init\_\_ method of InterpolatedModel for more details of how to instantiate and use InterpolatedModel.

One might have expected a interpolated model to be a literal Python function rather than a Python class - the
benefit of having InterpolatedModel as a class rather than a function is that you can easily save (pickle) classes
including data (e.g. parameters, x\_data, y\_data), but you can’t do that with functions. And, because the
InterpolatedModel class has a \_\_call\_\_ method, you can basically still just think of it like a function.

Parameters:
:   - **x\_data\_coordinates** (*Union**[**aerosandbox.numpy.ndarray**,* *Dict**[**str**,* *aerosandbox.numpy.ndarray**]**]*) –
    - **y\_data\_structured** (*aerosandbox.numpy.ndarray*) –
    - **method** (*str*) –

x\_data\_coordinates

x\_data\_coordinates\_values

y\_data\_structured

method *= 'bspline'*

fill\_value

x\_data

y\_data

\_\_call\_\_(*x*)
:   Evaluates the surrogate model at some given input x.

    The input x is of the type:
    :   - in the general N-dimensional case, a dictionary where keys are variable names and values are float/array.
        - in the case of a 1-dimensional input (R^1 -> R^2), a float/array.