Re: raw contents of data memory [message #90292 is a reply to message #90272] |
Wed, 18 February 2015 12:21   |
Russell[1]
Messages: 101 Registered: August 2011
|
Senior Member |
|
|
Hi guys.
Thanks for the response... but I'm not quite sure I understand. To be a bit more concrete, I have a 2-d floating point array that I want to convert using this type of thing. I can certainly write the data out using writeu, but I didn't know if there was a way to convert the data in IDL. I'm trying to pass the data into another program's stdin, and using byte or string or some such then that doesn't seem quite right...
Russell
On Tuesday, February 17, 2015 at 4:07:47 PM UTC-5, Helder wrote:
> I agree with Chris, string will do.
> But just a remark. The result shown by python is different if you use the python print or implicit print (version 2.7.3 on a Raspberry Pi):
>
>>>> a = np.array([112,121,116,104,111,110,32,105,115,32,40,115,111,1 09,101,116,105,109,101,115,41,32,97,108,115,111,32,102,117,1 10])
>>>> a.tostring()
> 'p\x00\x00\x00y\x00\x00\x00t\x00\x00\x00h\x00\x00\x00o\x00\x 00\x00n\x00\x00\x00 \x00\x00\x00i\x00\x00\x00s\x00\x00\x00 \x00\x00\x00(\x00\x00\x00s\x00\x00\x00o\x00\x00\x00m\x00\x00 \x00e\x00\x00\x00t\x00\x00\x00i\x00\x00\x00m\x00\x00\x00e\x0 0\x00\x00s\x00\x00\x00)\x00\x00\x00 \x00\x00\x00a\x00\x00\x00l\x00\x00\x00s\x00\x00\x00o\x00\x00 \x00 \x00\x00\x00f\x00\x00\x00u\x00\x00\x00n\x00\x00\x00'
>>>> print a.tostring()
> python is (sometimes) also fun
>
> notice also that:
>>>> print 'p\x00\x00\x00y\x00\x00\x00t\x00\x00\x00h\x00\x00\x00o\x00\x 00\x00n\x00\x00\x00 \x00\x00\x00i\x00\x00\x00s\x00\x00\x00 \x00\x00\x00(\x00\x00\x00s\x00\x00\x00o\x00\x00\x00m\x00\x00 \x00e\x00\x00\x00t\x00\x00\x00i\x00\x00\x00m\x00\x00\x00e\x0 0\x00\x00s\x00\x00\x00)\x00\x00\x00 \x00\x00\x00a\x00\x00\x00l\x00\x00\x00s\x00\x00\x00o\x00\x00 \x00 \x00\x00\x00f\x00\x00\x00u\x00\x00\x00n\x00\x00\x00'
> python is (sometimes) also fun
>
>>>> print r'A\x00\x00\x00B\x00\x00\x00'
> A\x00\x00\x00B\x00\x00\x00
>>>> print r'p\x00\x00\x00y\x00\x00\x00t\x00\x00\x00h\x00\x00\x00o\x00\ x00\x00n\x00\x00\x00 \x00\x00\x00i\x00\x00\x00s\x00\x00\x00 \x00\x00\x00(\x00\x00\x00s\x00\x00\x00o\x00\x00\x00m\x00\x00 \x00e\x00\x00\x00t\x00\x00\x00i\x00\x00\x00m\x00\x00\x00e\x0 0\x00\x00s\x00\x00\x00)\x00\x00\x00 \x00\x00\x00a\x00\x00\x00l\x00\x00\x00s\x00\x00\x00o\x00\x00 \x00 \x00\x00\x00f\x00\x00\x00u\x00\x00\x00n\x00\x00\x00'
> p\x00\x00\x00y\x00\x00\x00t\x00\x00\x00h\x00\x00\x00o\x00\x0 0\x00n\x00\x00\x00 \x00\x00\x00i\x00\x00\x00s\x00\x00\x00 \x00\x00\x00(\x00\x00\x00s\x00\x00\x00o\x00\x00\x00m\x00\x00 \x00e\x00\x00\x00t\x00\x00\x00i\x00\x00\x00m\x00\x00\x00e\x0 0\x00\x00s\x00\x00\x00)\x00\x00\x00 \x00\x00\x00a\x00\x00\x00l\x00\x00\x00s\x00\x00\x00o\x00\x00 \x00 \x00\x00\x00f\x00\x00\x00u\x00\x00\x00n\x00\x00\x00
>
> The implicit print option is a bit more complicated to reproduce in IDL (at least I guess that it involves quite a bit of formatting).
>
> Regards,
> Helder
>
> ps: I think I put into those lines just about all of my python knowledge. Not much.
> ps2: not sure if IDL or Python are fun... But for sure the latter can be a real pain...
|
|
|