0
$\begingroup$

I have four column data with first 3 column denoting x,y,z and fourth column energy. x variable is actually angle. Now I want to interpolate over all three indepdent variable (x,y.z) with corresponding energy value. I have done mathematica script which i attach below

SetDirectory["/home/george/Ramon/data/h2obr2/ci/gama/alldeg"];
a = ReadList["s.dat", {Real, Real, Real, Real}];
S = Length[a];
b1 = Table[Part[a[[i]], 4], {i, S}];
c = Table[Take[a[[i]], 3], {i, S}];
d1 = Table[{c[[i]], b1[[i]]}, {i, S}];
f1 = Interpolation[d1]

This gives an error :

Interpolation::indim: The coordinates do not lie on a structured tensor product grid. >>

What could be the correct way of interpolation over 3 variables?

I have modified the data as you said. Modified reduced data set (total 155 points) also gave me the above mentioned error message. If you look at the data carefully, for 0deg second column data range from 4:5.5(0.25) and this is not so for other angles. If I delete data corresponding to 5.25 then above code works. fine. If I keep the data corresponding to 5.25 then code fails. Is there any way to force mathematica interpolate keeping 5.25 data.

Here I provide the data as taken from mathematica

Here is my data:

{{{0., 4., 1.3}, -103.005}, {{0., 4., 1.32}, -103.002}, {{0., 4., 1.34}, -102.999}, {{0., 4., 1.35}, -102.997}, {{0., 4., 1.36}, -102.995}, {{0., 4.25, 1.3}, -103.005}, {{0., 4.25, 1.32}, -103.002}, {{0., 4.25, 1.34}, -102.999}, {{0., 4.25, 1.35}, -102.997}, {{0., 4.25, 1.36}, -102.996}, {{0., 4.5, 1.3}, -103.004}, {{0., 4.5, 1.32}, -103.001}, {{0., 4.5, 1.34}, -102.998}, {{0., 4.5, 1.35}, -102.997}, {{0., 4.5, 1.36}, -102.995}, {{0., 4.75, 1.3}, -103.003}, {{0., 4.75, 1.32}, -103.}, {{0., 4.75, 1.34}, -102.997}, {{0., 4.75, 1.35}, -102.996}, {{0., 4.75, 1.36}, -102.994}, {{0., 5., 1.3}, -103.003}, {{0., 5., 1.32}, -102.999}, {{0., 5., 1.34}, -102.996}, {{0., 5., 1.35}, -102.995}, {{0., 5., 1.36}, -102.993}, {{0., 5.25, 1.3}, -103.002}, {{0., 5.25, 1.32}, -102.999}, {{0., 5.25, 1.34}, -102.995}, {{0., 5.25, 1.35}, -102.994}, {{0., 5.25, 1.36}, -102.992}, {{0., 5.5, 1.3}, -103.001}, {{0., 5.5, 1.32}, -102.998}, {{0., 5.5, 1.34}, -102.995}, {{0., 5.5, 1.35}, -102.993}, {{0., 5.5, 1.36}, -102.992}, {{15., 4., 1.3}, -103.003}, {{15., 4., 1.32}, -103.}, {{15., 4., 1.34}, -102.997}, {{15., 4., 1.35}, -102.995}, {{15., 4., 1.36}, -102.993}, {{15., 4.25, 1.3}, -103.004}, {{15., 4.25, 1.32}, -103.001}, {{15., 4.25, 1.34}, -102.997}, {{15., 4.25, 1.35}, -102.996}, {{15., 4.25, 1.36}, -102.994}, {{15., 4.5, 1.3}, -103.003}, {{15., 4.5, 1.32}, -103.}, {{15., 4.5, 1.34}, -102.997}, {{15., 4.5, 1.35}, -102.995}, {{15., 4.5, 1.36}, -102.994}, {{15., 4.75, 1.3}, -103.003}, {{15., 4.75, 1.32}, -103.}, {{15., 4.75, 1.34}, -102.996}, {{15., 4.75, 1.35}, -102.995}, {{15., 4.75, 1.36}, -102.993}, {{15., 5., 1.3}, -103.002}, {{15., 5., 1.32}, -102.999}, {{15., 5., 1.34}, -102.996}, {{15., 5., 1.35}, -102.994}, {{15., 5., 1.36}, -102.992}, {{15., 5.5, 1.3}, -103.001}, {{15., 5.5, 1.32}, -102.998}, {{15., 5.5, 1.34}, -102.995}, {{15., 5.5, 1.35}, -102.993}, {{15., 5.5, 1.36}, -102.991}, {{30., 4., 1.3}, -103.}, {{30., 4., 1.32}, -102.997}, {{30., 4., 1.34}, -102.993}, {{30., 4., 1.35}, -102.992}, {{30., 4., 1.36}, -102.99}, {{30., 4.25, 1.3}, -103.001}, {{30., 4.25, 1.32}, -102.998}, {{30., 4.25, 1.34}, -102.995}, {{30., 4.25, 1.35}, -102.993}, {{30., 4.25, 1.36}, -102.992}, {{30., 4.5, 1.3}, -103.001}, {{30., 4.5, 1.32}, -102.998}, {{30., 4.5, 1.34}, -102.995}, {{30., 4.5, 1.35}, -102.993}, {{30., 4.5, 1.36}, -102.992}, {{30., 4.75, 1.3}, -103.001}, {{30., 4.75, 1.32}, -102.998}, {{30., 4.75, 1.34}, -102.995}, {{30., 4.75, 1.35}, -102.993}, {{30., 4.75, 1.36}, -102.992}, {{30., 5., 1.3}, -103.001}, {{30., 5., 1.32}, -102.998}, {{30., 5., 1.34}, -102.994}, {{30., 5., 1.35}, -102.993}, {{30., 5., 1.36}, -102.991}, {{30., 5.5, 1.3}, -103.}, {{30., 5.5, 1.32}, -102.997}, {{30., 5.5, 1.34}, -102.994}, {{30., 5.5, 1.35}, -102.992}, {{30., 5.5, 1.36}, -102.991}, {{45., 4., 1.3}, -102.999}, {{45., 4., 1.32}, -102.996}, {{45., 4., 1.34}, -102.993}, {{45., 4., 1.35}, -102.991}, {{45., 4., 1.36}, -102.989}, {{45., 4.25, 1.3}, -103.}, {{45., 4.25, 1.32}, -102.997}, {{45., 4.25, 1.34}, -102.993}, {{45., 4.25, 1.35}, -102.992}, {{45., 4.25, 1.36}, -102.99}, {{45., 4.5, 1.3}, -103.}, {{45., 4.5, 1.32}, -102.997}, {{45., 4.5, 1.34}, -102.994}, {{45., 4.5, 1.35}, -102.992}, {{45., 4.5, 1.36}, -102.99}, {{45., 4.75, 1.3}, -103.}, {{45., 4.75, 1.32}, -102.997}, {{45., 4.75, 1.34}, -102.994}, {{45., 4.75, 1.35}, -102.992}, {{45., 4.75, 1.36}, -102.99}, {{45., 5., 1.3}, -103.}, {{45., 5., 1.32}, -102.997}, {{45., 5., 1.34}, -102.994}, {{45., 5., 1.35}, -102.992}, {{45., 5., 1.36}, -102.99}, {{45., 5.5, 1.3}, -103.}, {{45., 5.5, 1.32}, -102.997}, {{45., 5.5, 1.34}, -102.993}, {{45., 5.5, 1.35}, -102.992}, {{45., 5.5, 1.36}, -102.99}, {{60., 4., 1.3}, -102.999}, {{60., 4., 1.32}, -102.996}, {{60., 4., 1.34}, -102.993}, {{60., 4., 1.35}, -102.991}, {{60., 4., 1.36}, -102.99}, {{60., 4.25, 1.3}, -103.}, {{60., 4.25, 1.32}, -102.996}, {{60., 4.25, 1.34}, -102.993}, {{60., 4.25, 1.35}, -102.991}, {{60., 4.25, 1.36}, -102.99}, {{60., 4.5, 1.3}, -103.}, {{60., 4.5, 1.32}, -102.996}, {{60., 4.5, 1.34}, -102.993}, {{60., 4.5, 1.35}, -102.992}, {{60., 4.5, 1.36}, -102.99}, {{60., 4.75, 1.3}, -103.}, {{60., 4.75, 1.32}, -102.996}, {{60., 4.75, 1.34}, -102.993}, {{60., 4.75, 1.35}, -102.991}, {{60., 4.75, 1.36}, -102.99}, {{60., 5., 1.3}, -102.999}, {{60., 5., 1.32}, -102.996}, {{60., 5., 1.34}, -102.993}, {{60., 5., 1.35}, -102.991}, {{60., 5., 1.36}, -102.99}, {{60., 5.5, 1.3}, -102.999}, {{60., 5.5, 1.32}, -102.996}, {{60., 5.5, 1.34}, -102.993}, {{60., 5.5, 1.35}, -102.991}, {{60., 5.5, 1.36}, -102.99}}

$\endgroup$
2

0

Browse other questions tagged or ask your own question.