Python Forum

Full Version: loading a 3D array from a bin file
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello Python forum

I am trying to load a 3D array from a bin file. However, when I load it is displayed as a long vector instead.

data=np.fromfile("turbine32x32x8192.bin",dtype=float, sep='')
data.shape
>> (4194304,)
where it should have the shape
data.shape
(32,32,8192)
What I am doing wrong ?

Thank you for reading!

BR Mark

Hello again Python Forum
I figured out a solution to the problem (Or rather I got help from an instructor)

import numpy as np
data=np.fromfile("turbine32x32x8192.bin",dtype=np.float32, sep='')
then the array becomes
Output:
data.shape >>(8388608,0)
Finally I can reshape the file the my desired array
data=data.reshape(32,32,8192)
Output:
data.shape >>(32,32,8192)
Thanks for posting the solution, glad you got it working :)