[Numpy-discussion] Reading 12bits numbers ?

2010-06-08 Thread Martin Raspaud
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, Is it possible to read an array of 12bit encoded numbers from file (or string) using numpy ? Thanks, Martin -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

Re: [Numpy-discussion] Reading 12bits numbers ?

2010-06-08 Thread Nadav Horesh
Raspaud Sent: Tue 08-Jun-10 15:04 To: Discussion of Numerical Python Subject: [Numpy-discussion] Reading 12bits numbers ? -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, Is it possible to read an array of 12bit encoded numbers from file (or string) using numpy ? Thanks, Martin -BEGIN PGP

Re: [Numpy-discussion] Reading 12bits numbers ?

2010-06-08 Thread Martin Raspaud
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Nadav Horesh skrev: You can. If each number occupies 2 bytes (16 bits) it is straight forward. If it is a continues 12 bits stream you have to unpack by your self: data = np.fromstring(str12bits, dtype=np.uint8) data1 = data.astype(no.uint16)