You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since the previous-value interpolation feature was merged, I wanted to use it as a lookup function inside another function.
But the community helped me discover that there was an issue with precision/rounding. Consider this simple table, read in from a CSV file called Inputarray_Odm2prod_2h_3d.csv:
The following code constructs said lookup function and calls it:
using DelimitedFiles
using Interpolations
f_tScal = 24 # Use hours instead of days
# %% Read input from CSV file
inputArray = readdlm("Inputarray_Odm2prod_2h_3d.csv", ',', Float64)
inputArray[:,1] /= (86400/f_tScal) # Scale input from per day to per second (or whatever)
# does nearest-neighbor interpolation! Only 2D
itp_q_in1(t) = extrapolate(interpolate((inputArray[:,1],), inputArray[:,2], Gridded(Constant{Previous}())), 0.0)(t)
trange = inputArray[1:8,1]
# Showing precision issue by adding a very small number to each element of the t vector
[itp_q_in1(trange), itp_q_in1(trange.+1e-8)]
As you can see, except for the first element, all values are different. Actually, the second output line would be the correct one I expect, but I only get it by adding this small number to the trange vector.
Is this the expected behavior? Is there some glitch in my code? Or is it just a bug?
The text was updated successfully, but these errors were encountered:
Using Gridded for this is definitely not ideal because we end up having to scale the input and run into floating point issues. Let me investigate this further.
Since the previous-value interpolation feature was merged, I wanted to use it as a lookup function inside another function.
But the community helped me discover that there was an issue with precision/rounding. Consider this simple table, read in from a CSV file called
Inputarray_Odm2prod_2h_3d.csv
:The following code constructs said lookup function and calls it:
gives
As you can see, except for the first element, all values are different. Actually, the second output line would be the correct one I expect, but I only get it by adding this small number to the
trange
vector.Is this the expected behavior? Is there some glitch in my code? Or is it just a bug?
The text was updated successfully, but these errors were encountered: