Message Boards Message Boards

[?] Interpolate a 3D vector field?

Posted 7 years ago

Hello, So I'm trying to take a 3D magnetic field, and then interpolate it so I can take the differentials and plot nice magnetic fields. I'm struggling to tell interpolate how to interpolate my data - I get an error reading

ListInterpolation::inhr: Requested order is too high; order has been reduced to {3,3,3,2}

Which I don't quite understand.

The data is fine because I can plot it correctly using ListVectorPlot3D

Minimum Working Example:

(*define the vectors for each dimension*) 
vx = ConstantArray[1, {5, 5, 5}]
vx = ConstantArray[3, {5, 5, 5}]
vy = ConstantArray[2, {5, 5, 5}]

(*put each dimension to gether to get a 3D vector field - i.e. each point has a 3 vector at it *) 
together = 
 ArrayReshape[Transpose[Flatten /@ {vx, vy, vz}], {5, 5, 5, 3}]

interpolation = ListInterpolation[together]

ListVectorPlot3D[together]
VectorPlot3D[interpolation[x, y, z], {x, 1, 5}, {y, 1, 5}, {z, 1, 5}]

Can interpolate not work with this complicated data structures, i.e. might they be scalars. Would it then be possible to combine 3 interpolation functions?

POSTED BY: Tomi Baikie
3 Replies
Posted 7 years ago

Mhm, so does that mean that interpolate is not interpolating between the different "deepest" dimensions. I.e. I want interpolate to describe the vector field, not just each point with only 3 data points.

Would a work around be then to create a interpolation for each dimension (x,y,z) then put those together to form a description for the whole vector field.

POSTED BY: Tomi Baikie

create an interpolation function for each 'component':

vx = ConstantArray[1, {5, 5, 5}]
vy = ConstantArray[3, {5, 5, 5}]
vz = ConstantArray[2, {5, 5, 5}]

ClearAll[if]
ifs = ListInterpolation /@ {vx, vy, vz}
if[x_, y_, z_] := (#[x, y, z] & /@ ifs)
VectorPlot3D[if[x, y, z], {x, 1, 5}, {y, 1, 5}, {z, 1, 5}]
POSTED BY: Sander Huisman

The default order of interpolation is 3 for which you need at least 4 data-points. You 'deepest' dimensions has only length 3. So it can be at most order 2 interpolation...

POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract