Problem reading css format


I’m trying to read data in CSS format, the data is stored as s3 which is one of the allowed data formats in CSS. I’m getting an error regarding the s3, with data in t4 the program work OK.

Any suggestions?

Cheers Yochai

Hi Yochai,

s3 is a weird 3-byte integer type that numpy doesn’t natively support. I’ve looked into ways to coax it into a 4-byte integer type, and found a snippet from a SciPy issue that may help (pasted below): It’s for multi-dimensional arrays, but could probably be modified for 1D arrays. If this doesn’t do what you want, the Pisces project (I’m an author) can read CSS s3 type:

If you’re able to do this using just the snippet, please let me know. I’d be curious how it works for you.


data = numpy.fromfile(fid, dtype='u1', count=size) # first read byte per byte
a = numpy.empty((len(data)/3, 4), dtype=`u1`)
a[:, :3] = data.reshape((-1, 3))
a[:, 3:] = (a[:, 3 - 1:3] >> 7) * 255
data = a.view('<i4').reshape(a.shape[:-1])

Dear Jon,

Thanks for your replay, I’m still in the trying to import the pisces project into my python and to operate it.




Feel free to email me directly with any questions.


Jon Shalom,

I’m using Python 2.7.13 |Anaconda 4.3.1 (64-bit). I installed pisces using pip. However, I’m getting the following:

In [5]: from pisces import Route, AppContainer, Router

In [6]: from pisces import read_waveform

Hi Jon,

I reinstalled the piscs and now it is working!