Issue
I have an array called result that has a shape of (1200,67,67). Along the axis with length 1200 the array is correct. However, the other two axis have been flipped. I am getting:
result[0,:,:] = array([
[-0.4182856 , -0.12402566, 0.26624826, ..., 0.65988034, 0.7642574, 0.4524528],
[-0.39774683, -0.18033904, 0.14606595, ..., 0.7325263 , 0.75217724, 0.32839388],
[-0.34418693, -0.15839723, 0.05166954, ..., 0.70598584, 0.57750726, 0.18543348],
...,
[-0.5998102 , -0.512376 , -0.00168504, ..., 0.08733568, -0.28331557, -0.6596785 ],
[-0.5967892 , -0.28394988, 0.03711865, ..., -0.03314218, -0.33655524, -0.671829 ],
[-0.54678684, -0.21562685, 0.01694722, ..., -0.03415907,-0.36989942, -0.66516656]
], dtype=float32)
But I should be getting the second version.
result[0,:,:] = array([
[0.45245281, 0.76425737, 0.65988034, ..., 0.26624826, -0.12402566, -0.41828561 ],
[0.32839388, 0.75217724, 0.73252630, ..., 0.14606595, -0.18033904, -0.39774683],
[0.18543348, 0.57750726, 0.70598584, ..., 0.051669542, -0.15839723, -0.34418693],
...
[-0.65967852, -0.28331557, 0.087335683, ..., -0.0016850400, -0.51237601, -0.59981018 ],
[-0.67182899, -0.33655524, -0.033142179, ..., 0.037118647, -0.28394988, -0.59678918 ],
[-0.66516656, -0.36989942, -0.034159068, ..., 0.016947223, -0.21562685, -0.54678684]
], dtype=float32)
So I want to try to alter the 3d array to then flip the two axis of 67 length. Thanks.
Solution
this should be as simple as transposing the y and z axis. so the question can use the transpose
function like this:
import numpy as np
# Define the dimensions for the x, y, and z axes
x_dim = 1200
y_dim = 67
z_dim = 67
# Create a NumPy array with the specified dimensions initialized with zeros
original_array = np.zeros((x_dim, y_dim, z_dim))
# fill the array with your own specific numbers
# ...
# ...
# Flip the y and z axes using numpy.transpose
flipped_array = np.transpose(original_array, (0, 2, 1))
# Print the shape of the new array to confirm the axes have been flipped
print(flipped_array.shape)
I just show an array shape of zero's for the purpose of the example, but the OP can populate it with appropriate numbers.
The result is a new array with y and z flipped (same shape since y = z = 67):
(1200, 67, 67)
Answered By - D.L
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.