I found a problem. The correct way to import binary data in a single-precision floating-point format is read(f, Float32, NUM_VALS) , where f is the file stream, Float32 is the data type, and NUM_VALS is the number of words (values ββor data points) in the binary data file .
It turns out that every time you call read(f, [...]) , the data pointer iterates over the next element in the binary.
This allows people to read data in turn simply:
f = open("my_file.bin") first_item = read(f, Float32) second_item = read(f, Float32)
However, I wanted to load all the data in one line of code. When I debugged, I used read() several times in the same file pointer without re-declaring the file pointer. As a result, when I experimented with the correct operation, namely read(f, Float32, NUM_VALS) , I received an unexpected value.
source share