loading a 3D array from a bin file - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: loading a 3D array from a bin file (/thread-9916.html) |
loading a 3D array from a bin file - Mark3232 - May-04-2018 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 Finally I can reshape the file the my desired array data=data.reshape(32,32,8192)
RE: loading a 3D array from a bin file - j.crater - May-04-2018 Thanks for posting the solution, glad you got it working :) |