taborlab / Iris

The Light Program Interface
BSD 3-Clause "New" or "Revised" License
12 stars 2 forks source link

error of unexpected header while following ProduceLPFDemo.ipynb #307

Closed cuong450 closed 6 years ago

cuong450 commented 6 years ago

Hi, it seems that the .lpf file (generated by the LPFEncoder demo ) does not fit the expected header format of LPFParser.

lpfdata = lpfp.LPFtoArray(paths['TestFile']) # loading the LPFEncoder written .lpf file Printed output: Header: (1, 0, 48, 0, 50, 0, 72001, 0) <------ seems to be scrambled (maybe caused by .flatten function) Header Data: LPF ver: 1 Number of channels (total): 0 Time step: 48 (ms) Number of time steps: 0 Traceback (most recent call last):

LPFencorder header = ar.array('l', header) # 32-bit ---->prints: header = array('l', [1, 48, 50, 72001, 0, 0, 0, 0]) but then...

output = ar.array('h', self.gsVals.flatten()) # 16-bit

write the bytes to file

    outfile = open(filename, 'wb')
    header.tofile(outfile)
    output.tofile(outfile)
    outfile.close()

---->writes program.lpf shows scrambled header

Do you have any suggestions on this issue?

SynbioLucas commented 6 years ago

I was able to reproduce this bug when running on Linux, but not when on Windows 10. I was then able to identify an issue related to byte size differences when writing to disk between the two operating systems. The code in the most recent commit (38bf5f717bc4de3c62c8a1af955de2de755a6791) on the master branch should fix this issue. I'm closing the issue for now, but if it's not resolved for you, feel free to comment and I'll reopen.