Photon-HDF5 / phconvert

Convert Beker&Hickl, PicoQuant and other formats to Photon-HDF5
http://photon-hdf5.github.io/phconvert
Other
16 stars 14 forks source link

numpy array is not writable #48

Closed mayeshh closed 4 years ago

mayeshh commented 4 years ago

I'm using numpy version 1.17.2, and am getting an error when loading .sm files: d = loader.usalex(fname=fname)

resulting error:



---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-e1248430f5f7> in <module>
----> 1 d = loader.usalex(fname=fnames[1])

~/software/FRETBursts/fretbursts/loader.py in usalex(fname, leakage, gamma, header, BT)
    427                     '    The header length is now computed automatically.')
    428     print(" - Loading '%s' ... " % fname)
--> 429     ph_times_t, det_t, labels = load_sm(fname, return_labels=True)
    430     print(" [DONE]\n")
    431 

~/anaconda3/envs/py37-fb/lib/python3.7/site-packages/phconvert/smreader.py in load_sm(fname, return_labels)
    122 
    123     # Swap byte order inplace to little endian
--> 124     data.setflags(write=True)
    125     data = data.byteswap(True).newbyteorder()
    126 

ValueError: cannot set WRITEABLE flag to True of this array```
mayeshh commented 4 years ago

I'm using numpy version 1.17.2, and am getting an error when loading .sm files: d = loader.usalex(fname=fname)

resulting error:


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-e1248430f5f7> in <module>
----> 1 d = loader.usalex(fname=fnames[1])

~/software/FRETBursts/fretbursts/loader.py in usalex(fname, leakage, gamma, header, BT)
    427                     '    The header length is now computed automatically.')
    428     print(" - Loading '%s' ... " % fname)
--> 429     ph_times_t, det_t, labels = load_sm(fname, return_labels=True)
    430     print(" [DONE]\n")
    431 

~/anaconda3/envs/py37-fb/lib/python3.7/site-packages/phconvert/smreader.py in load_sm(fname, return_labels)
    122 
    123     # Swap byte order inplace to little endian
--> 124     data.setflags(write=True)
    125     data = data.byteswap(True).newbyteorder()
    126 

ValueError: cannot set WRITEABLE flag to True of this array```

I have tried changing the code to make sm_dtype little endian:

sm_dtype = np.dtype([('timestamp', '<i8'), ('detector', '<u4')])

and commented out the following lines:


  data.setflags(write=True)
   data = data.byteswap(True).newbyteorder()```

This raises the ValueError: output array is read-only error later in my notebook when I try to assign detector specs to the data object using d.add

I want to submit a PR, but so far I have not figured out how to make the array writable.

mayeshh commented 4 years ago

... apparently I had two versions of phconvert. The newest one, forked and cloned locally, does not give this error. Closing this issue.