2D Engineering Interpolation Jun 2025

Let’s get started.
Even though it’s 2025, not everything has been reduced to a formula or a model.

The inspiration for this post came from my structural engineering work, specifically using the ASCE wind codes.

For laypersons, ASCE is the American Society of Civil Engineers. ASCE publishes ASCE 7 which establishes the minimum loads (like dead, live, snow, wind, seismic, flood, etc) that structures must be designed to withstand, thereby ensuring safety and reliability.

ASCE 7-22 Figure 29.3-1
ASCE 7-22 Figure 29.3-1 (entire page)
ASCE 7-22 Figure 29.3-1 (Just the table)
ASCE 7-22 Figure 29.3-1 (just the table)
ASCE 7-22 Excel Representation
ASCE 7-22 Figure 29.3-1 (Excel representation)
ORDERING

In the ASCE table, notice that the left side lookup values are in descending order whereas the top side lookup values are in ascending order. In reference data, we commonly see every sort of arrangement in tables.

A canonical representation for the table would be ascending order for both lookups; however, it would be an unnecessary burden to require the user to presort the table; better to put that sorting in the proposed function.

RANGES

Notice also, in this example, that the left side lookup starts with a range ≤0.16.

Similarly, the top side starts with a range ≤0.05 and ends with a range ≥45. A structural engineer would understand the implications of these ranges: both lookup lower bounds are zero, the top side lookup upper bound is theoretically infinity. When a range is specified in a lookup, no interpolation is needed; the answer is constant across the range.

The Function
Overview

In this post, only linear interpolation is being addressed.

The function was written using straight Python. And I easily made an Excel function using PyXLL. PyXLL allows me to efficiently develop and prove a new design table.

One might imagine this as a trivial calculation, and for a human, it is. To cast the calculation into a general purpose function is not so trivial.

Published tables are written for humans. Though the data is explicitly written, the lookups are generally not. On the left, right, top, and the bottom sides often there is an implied limit: maybe a fixed value, maybe not. Maybe only nonzero values, maybe only nonnegative values, maybe only positive values, maybe only values from zero to one. The tables are published in context. Knowing, and presenting this context, leads to the calculation of ‘legitimate’ interpolations.

I’ve worked to build that context into my proposed function.

tab_interp(row_lookup, column_lookup, entire_table)

row_lookup: (float)
col_lookup: (float)
entire_table: (range)
Handling Ranges
To handle ranges, I found it best to append an extra row or column to the table; the lookup value in the ‘append’ is simply the explicit ‘far limit’ of the range.
Handling Infinity
In a given table, ranges might be (loosely) specified with no ‘far’ limit. This implies that the ‘far limit’ is positive or negative infinity. The user provides a text entry of inf or minf to represent positive and negative infinity.
Handling Nonnumeric Entries
In a given table, the function must be able to handle blank entries and text cells. These nonnumeric entries can be translated internally to NaN (not a number).
Handling Tables Out of Order
The function reorders the table into a canonical form — ascending by row and by column. Of course, this does not affect the referenced Excel cells. Notice, in one example below, the rows and columns are deliberately scrambled, yet the function performs a correct interpolation.

A sequence of self-explanatory screenshots follow</em

typical table highlighted
Typical Table Highlighted
no interpolation row
No Interpolation — Row Lookup is Off Range
no interpolation col
No Interpolation — Col Lookup is Off Range
typical table with blank
Typical Table with Blank
typical table with infinity
Typical Table with Infinity
typical table out of order
Typical Table — Out of Order !!
VIDEOS

Here is short video illustrating chart generation using the interpolation function. In this Excel sheet, there is no lookup table. The lookup table is neatly inside of a PyXLL function. The PyXLL function is available in any worksheet — no macros — no cell references.

The Excel function call (note: no table reference):

=ASCE_wind_interpolate($B$14,E5)
And here is a video snippet. I demonstrate how easy it is to ‘transport’ an Excel range to Python. In this example, I capture the entire design table into a Jupyter notebook using a PyXLL magic function. I can build and debug a table in Excel, then make it part of a straight Python/PyXLL function; therefore, eliminating the need for an onscreen table.

The Jupyter cell simply reads:

my_array = %xl_get --cell d4:r12 --type numpy_array
my_array
Thanks to Tony Roberts

Do you like great support from a company? I do.

Leave a Reply

Your email address will not be published. Required fields are marked *