Hi Forum!
Yes, another question on interpolation.
I have this 5D data that I need linearly interpolated (spline and quadratic are good, but I need to avoid any overshoot). If anyone os curios the data is something like this:
https://github.com/marianoarnaiz/SWF/blob/main/Felsic.txt
Now, columns 1 and 2 are OK, but 3:5 are peculiar they must add to 100%. Column 6 is what needs to be interpolated (actually 6:8 will all be interpolated in different variables).
I tried using Interpolations like this:
DATA_FELSIC=readdlm(“Felsic.txt”,Float64,comments=true,comment_char=‘#’); #This is the IASP91 with LAB
DATA_FELSIC[:,2]=DATA_FELSIC[:,2]*1e-9;
Temperature=DATA_FELSIC[:,1]; #in K
Pressure=DATA_FELSIC[:,2]; #in Gpa
Qz=DATA_FELSIC[:,3]; #in %
A=DATA_FELSIC[:,4]; #in %
P=DATA_FELSIC[:,5];#in %
Vp=DATA_FELSIC[:,6]; #in km/s
Vs=DATA_FELSIC[:,7]; #in km/s
Rho=DATA_FELSIC[:,8]; #in g/cm3t=sort(unique(Temperature));
pr=sort(unique(Pressure));
q=sort(unique(Qz));
a=sort(unique(A));
pl=sort(unique(P));Felsic_Rho_M=zeros(size(t,1),size(pr,1),size(q,1),size(a,1),size(pl,1));
for ti=1:size(t,1)
for pri=1:size(pr,1)
for qi=1:size(q,1)
for ai=1:size(a,1)
for pli=1:size(pl,1)
if q[qi]+a[ai]+pl[pli]==100
indx=findall( (DATA_FELSIC[:,1].==t[ti]) .& (DATA_FELSIC[:,2].==pr[pri]) .& (DATA_FELSIC[:,3].==q[qi]) .& (DATA_FELSIC[:,4].==a[ai]) .& (DATA_FELSIC[:,5].==pl[pli]));
Felsic_Rho_M[ti,pri,qi,ai,pli]=Rho[indx[1]];end end end end end
end
Felsic_Rho = interpolate((t,pr,q,a,pl), Felsic_Rho_M, Gridded(Linear()));
But to fill Matrix I have used zeros and this makes my interpolation have all minimum values outside the knots.
Any way around this? Thanks!