comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » IDL to Python bridge and "file-like" Python object
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: IDL to Python bridge and "file-like" Python object [message #93250 is a reply to message #93249] Thu, 19 May 2016 13:34 Go to previous message
lecacheux.alain is currently offline  lecacheux.alain
Messages: 325
Registered: January 2008
Senior Member
Le jeudi 19 mai 2016 20:22:26 UTC+2, Jim P a écrit :
> On Thursday, May 19, 2016 at 5:39:55 AM UTC-6, alx wrote:
>> Le jeudi 19 mai 2016 11:53:19 UTC+2, Fabien a écrit :
>>> On 05/18/2016 06:22 PM, alx wrote:
>>>> Of course, as you said, it is possible to cast the bytes variable inside Python, then to transfer it to IDL. But it is a bit laborious (and slow ?).
>>>
>>> Does your package support python3? It seems that the bytarray problems
>>> has something to do with str representations in legacy python.
>>>
>>> Cheers,
>>>
>>> Fabien
>>
>> I am using FDB 1.6, Python 3.4 (both quoted as compatible) and IDL 8.5.1.
>> From my previous post you can check that the FDB blobReader output is a binary bytearray (bytes) within Python, but a string within IDL.
>> Therefore, the issue looks like to not come from Python but from the IDL/Python bridge, which (incorrectly, I guess) converts Python bytes variable into IDL string (as you can see in the Exelis Python bridge documentation).
>> This choice is unfortunate because Python bytes variable (afaik, but I am not familiar enough with Python) can contain zero values.
>> alain.
>
> I assume the actual numeric values stored in the blob are not bytes, but are integers, floats, etc.
>
> In this case, you might need to use a utility like Python's struct to reconstitute your data appropriately. Even if you were to get the data into IDL as a BYTARR() you would still need to perform a conversion to INTEGER, FLOAT, etc., AND concern yourself with endianness.
>
> You may be better off by simply letting the existing Python tools do that work for you first.
>
> This reference may be of use, or there may be better solutions:
>
> https://docs.python.org/2/library/struct.html
>
> Jim P.

Thank you Jim P. for your helping trick.

My data are indeed made of 2560 floats (forming the 10240 bytes blob), so that:

>>> q = struct.unpack('2560f', r2.read())

done on Python side, is doing the job.

However, it would be nice if the translation from bytes/bytearray into string could be improved in further releases of the IDL Python bridge.

alain.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: issues appending roi from IDLanROI to IDLanROIGroup
Next Topic: Read ASCII line till semicolon

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Nov 28 09:48:50 PST 2025

Total time taken to generate the page: 0.30554 seconds