Skip to content

lowering tolerance for what is considered uniform spacing

Elizabeth Armstrong requested to merge fixuniform into master

We ran into an issue of the following "high res" data not being interpolated correctly (which was a scaled version of an enthalpy defect). Lowering the uniform spacing tolerance addressed the issue.

""" import numpy as np from pytabprops import LagrangeInterpolant1D, StateTable import matplotlib.pyplot as plt

x = np.array([1. , 2.02321341, 3.04642683, 4.06964024]) x2 = np.array([1.000000000000000e+00, 2.023213414585707e+00, 3.046426829171402e+00, 4.069640243757108e+00]) y = np.array([950.29194127, 945.06973705, 939.99250336, 935.04420355]) - 934. y += 4.*(x-1)**2

kind = 1 interp = LagrangeInterpolant1D(kind, x, y, True) interp2 = LagrangeInterpolant1D(kind, x2, y, True)

tbl = StateTable() tbl.add_entry("val", interp, ['x']) tbl.add_entry("val2", interp2, ['x']) interpolant = lambda x: tbl.query("val", x) interpolant2 = lambda x: tbl.query("val2", x)

query = np.linspace(x[0],x[-1],100) plt.plot(x,y,'k*') plt.plot(query, interpolant(query), label='low res') plt.plot(query, interpolant2(query), label='high res') plt.grid() plt.legend() plt.show()

print('low res',np.max(np.abs(y-interpolant(x)))) print('high res',np.max(np.abs(y-interpolant2(x2)))) """

Merge request reports