Hello Tamas,
Thank you for your response.
Here a minimal self-contained example that replicates the error msg (here are the input files):
using Distributions,DelimitedFiles,Interpolations
function backtr(y,table,zmin,zmax,tail)
#----------------------------------------------------
# Back-transformation from Gaussian to original scale
#----------------------------------------------------
p = size(table,1);
m,n = size(y);
z = zeros(m,n);
# Do not perform back-transformation if the conversion table is empty
#--------------------------------------------------------------------
if isempty(table)
z = y;
return z;
end
# Values in the lower tail (exponential extrapolation)
#-----------------------------------------------------
z1 = table[1,1];
y1 = table[1,2];
I1 = (LinearIndices(y))[findall( x->(x < y1), y)];
if !isempty(I1)
b0 = (z1-zmin)*exp.(-tail[1]*y1);
z[I1] = zmin .+ b0*exp.(tail[1]*y[I1]);
end
# Values in the upper tail (exponential extrapolation)
#-----------------------------------------------------
zp = table[p,1];
yp = table[p,2];
I2 = (LinearIndices(y))[findall( x->(x > yp), y)];# find(y>yp);
if !isempty(I2)
bp = (zp-zmax)*exp(tail[2]*yp);
z[I2] = zmax .+ bp*exp.(-tail[2]*y[I2]);
end
# Within-class values
#--------------------
I = sort(union(I1,I2));
I3 = [ii for ii=1:(m*n)];
deleteat!(I3,I);
if !isempty(I3)
# println("typeof(table)=",typeof(table));
# open("t.txt", "w") do ff
# writedlm(ff,table);
# end
# table=readdlm("t.txt");
intf = interpolate( (table[:,2],) , table[:,1] , Gridded(Linear()));
z[I3] = Float64[intf(zz,1) for zz in y[I3] ]; # Table lookup
end
return z
end
simu=readdlm("simu.txt");
tableZY=readdlm("tableZY.txt");
zmin,zmax=readdlm("zmin-zmax.txt");
tail=readdlm("tail.txt");
simu = backtr(simu,tableZY,zmin,zmax,tail);
Thanks in advance. Let me know if you need something else.
I3, intf, y = backtr(simu,tableZY,zmin,zmax,tail);
which should allow you to study your error as
intf(first(y[I3]), 1)
where I think it comes from having an incorrect number of arguments, as you are interpolating a one-dimensional function. But you could report the minimal case as an issue with Interpolations, which could perhaps give a more informative error (but I don’t know the details). The one-argument verison
Yes, I can set the z constants without reading a file, but
simu=readdlm("simu.txt");
takes me thousands of lines of codes to get, and
tableZY=readdlm("tableZY.txt");
actually depends on an input that I read and has the same size, so adding more code is pointless. Do you think I should open an issue on Interpolations with a somewhat minimal self-contained example?
Otherwise I think this problem is solved.
Thanks!