tdgrant1 / denss

Calculate electron density from a solution scattering profile
GNU General Public License v3.0
31 stars 20 forks source link

enable the possibility for denss.fit_data.py to read RAW .dat files #3

Closed normcyr closed 5 years ago

normcyr commented 5 years ago

denss.fit_data.py was returning a string to float conversion error for .dat files containing a header before and after the numerical values.

$ denss.fit_data.py -f S_A_02492_A1_MerB3_063_c.dat 
/home/sbio/norm/softwares/denss/venv/local/lib/python2.7/site-packages/saxstats/saxstats.pyc
Traceback (most recent call last):
  File "/home/sbio/norm/softwares/denss/venv/bin/denss.fit_data.py", line 73, in <module>
    Iq = np.loadtxt(args.file)
  File "/home/sbio/norm/softwares/denss/venv/local/lib/python2.7/site-packages/numpy/lib/npyio.py", line 1134, in loadtxt
    for x in read_data(_loadtxt_chunksize):
  File "/home/sbio/norm/softwares/denss/venv/local/lib/python2.7/site-packages/numpy/lib/npyio.py", line 1061, in read_data
    items = [conv(val) for (conv, val) in zip(converters, vals)]
  File "/home/sbio/norm/softwares/denss/venv/local/lib/python2.7/site-packages/numpy/lib/npyio.py", line 768, in floatconv
    return float(x)
ValueError: could not convert string to float: Q

These headers are found in .dat files generated by RAW (using v.1.5.1 in my case) where column names are specified above the data, and additional information is provided after the data with respect to analysis performed in RAW.

Using numpy.genfromtxt instead of numpy.loadtxt solved the problem. NaN values were however created and needed some extra code to remove them.

tdgrant1 commented 5 years ago

thanks!