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

Home » Public Forums » archive » Re: Python reader for IDL save files.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Python reader for IDL save files. [message #44256] Thu, 02 June 2005 13:34
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> 1. Has anyone worked on the problem of reading IDL save files from
> within python? This seems like a reasonable project for the usual IDL
> variable types.

I had this same question a while back and came to find out that the IDL
save file format does not have a public description and that RSI
reserves the right to change the format at any time they want. In
short, they don't want people to know the format or to start messing
around with their save files.


> 2. The only problem I have thought of is how to represent arrays of IDL
> structures in Python. The one attempt I made at this was succesful, but
> the resulting data structures (lists of lists, I think) were very slow
> to work with. Has anyone worked on this problem?

With the way that Python data structures work, it doesn't seem like
there would be any good way to directly translate an array of structures
in IDL to something in Python. If I may ask, why are you attempting to
use IDL and Python together in this way? I ask only because there may
be another way to go about solving your problem so there'll be less
burden on the Python side, which seems to be the bottleneck.

I have written programs where IDL has communicated with programs in
other languages (e.g. Python, Java), but each time I've written
something extremely specific rather than trying to find the general
solution. That may be what you need to do -- code the specific solution
such that you can make the best use of Python for this particular project.

-Mike
Re: Python reader for IDL save files. [message #44262 is a reply to message #44256] Thu, 02 June 2005 06:53 Go to previous message
Matt Feinstein is currently offline  Matt Feinstein
Messages: 33
Registered: July 2002
Member
On 1 Jun 2005 18:29:09 -0700, lefsky@gmail.com wrote:

>
> 2. The only problem I have thought of is how to represent arrays of IDL
> structures in Python. The one attempt I made at this was succesful, but
> the resulting data structures (lists of lists, I think) were very slow
> to work with. Has anyone worked on this problem?

You might try the 'Object Array' type in the numarray module.
Operations on numarray arrays are generally speedier than
corresponding operations on Python lists since the implementor can
assume that the elements in a numarray are all of the same type.

Matt Feinstein

--
There is no virtue in believing something that can be proved to be true.
Re: Python reader for IDL save files. [message #44263 is a reply to message #44262] Thu, 02 June 2005 05:37 Go to previous message
Thomas Pfaff is currently offline  Thomas Pfaff
Messages: 15
Registered: April 2005
Junior Member
> 2. The only problem I have thought of is how to represent arrays of IDL
> structures in Python. The one attempt I made at this was succesful, but
> the resulting data structures (lists of lists, I think) were very slow
> to work with. Has anyone worked on this problem?

Just by analogy, what about implementing arrays as lists and structs as
dictionaries? Then the syntax would be quite similar yet not completely
identical.

# IDL - an array
# python - a list
a = [1,2,3,4]

# IDL - an array of structs
b = [{a:1, b:3},{a:3, b:4}]
# python - a list of dictionaries
b = [{"a":1, "b":3},{"a":3, "b":4}]

#IDL
c = b[0].a
#python
c = b[0]["a"]


Cheers,


Thomas
Re: Python reader for IDL save files. [message #44267 is a reply to message #44263] Thu, 02 June 2005 00:30 Go to previous message
Chris Lee is currently offline  Chris Lee
Messages: 101
Registered: August 2003
Senior Member
In article <1117675749.189108.60990@z14g2000cwz.googlegroups.com>,
"Unknown" <lefsky@gmail.com> wrote:


> I have two questions:
> 1. Has anyone worked on the problem of reading IDL save files from
> within python? This seems like a reasonable project for the usual IDL
> variable types.
> 2. The only problem I have thought of is how to represent arrays of IDL
> structures in Python. The one attempt I made at this was succesful, but
> the resulting data structures (lists of lists, I think) were very slow
> to work with. Has anyone worked on this problem? M
>

I may be wrong, but I thought IDL didn't use arrays of structures, it
used a single structure of arrays, which is why structure have to conform
to be put into the same array

IDL> help, [{b:2,c:3}, {a:2,c:3}]
<Expression> STRUCT = -> <Anonymous> Array[2]
IDL> help, [{b:2,c:3}, {a:2,c:3d}]
% Conflicting data structures:
IDL> help, [{b:2,c:3}, {a:2,c:3,d:3}]
% Conflicting data structures:

If you want to store these in a python 'structure', then I'd guess a
dictionary is what you want, e.g. s={'a':[1,2,3], 'b':['bob','joe','fred']}, but you
would probably need to use a class and redefine the __getattr__ method
or similar if you want the access method to be s[0].b

Chris.
Re: Python reader for IDL save files. [message #44268 is a reply to message #44267] Wed, 01 June 2005 22:11 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
lefsky@gmail.com writes:
> 1. Has anyone worked on the problem of reading IDL save files from
> within python? This seems like a reasonable project for the usual IDL
> variable types.

I have not, but I did unofficially document the save file format for
data:

http://cow.physics.wisc.edu/~craigm/idl/cmsave.html

RSI and Kodak threatened a lawsuit about a previous version of that
library, so hopefully somebody will get some use out of my past
distress.

Good luck,
Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: LIDAR .las format
Next Topic: Re: extracting values from an array

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

Current Time: Wed Oct 08 15:39:33 PDT 2025

Total time taken to generate the page: 0.00663 seconds