Griff
Griff

Reputation: 2124

getting x,y,z, mean through a 3D data array

Suppose I have an array which is NxNxN and I want to create an averaged array which stacks each direction. x-y (averaged over z), x-z (averaged over y), y-z (averaged over x)

For x-y I would do:

np.mean(data,axis=1, dtype=np.float64)

Do I simply use axis=1 [or 2 or 3] to stack it in each direction?

Upvotes: 5

Views: 895

Answers (1)

Saullo G. P. Castro
Saullo G. P. Castro

Reputation: 58915

If your NxNxN array is a numpy.ndarray:

xy = NNN.mean(axis=2)
xz = NNN.mean(axis=1)
yz = NNN.mean(axis=0)

Upvotes: 1

Related Questions