I have some weird problem while reading file with Python3. With Matlab I have code
fid = fopen('histograms_testi.bin','r');
data = fread(fid,'*uint16','ieee-be');
fclose(fid);
%reshaping
data = reshape(data,4096,numel(data)/4096);
where the data is now some matrix of shape (10127 , 4096 ) which is fine (later I'm reshaping it to 10100x 4096 form)
With Python3 I tried to read the same file using different methods, i.e.
data = np.fromfile('histograms_testi.bin', dtype='>f8', count=-1)
that was given in Reading binary big endian files in python . Unfortunately this then gives error of
ValueError: cannot reshape array of size 10370048 into shape (2531,4096)
The way I got this working with Python3 is following
data= np.fromfile('histograms_testi.bin', 'uint16')
and I can easily reshape it into the shape I want
rs = data.reshape(int(len(data)/4096),4096)
rs = rs[:10100]
Now the problem/weird part is that, the scale on the y-axis is completely different. (x-axis seems completely same).
The maximum value of the first data 'row' using matlab (data(:,1)) is 118, while with the Python it is 30208.
I am a bit worried, that the results will not be completely correct, eventhough the shape of the figures are same (scale on y-axis are not).
Any ideas?