Skip to content
This repository has been archived by the owner on Jun 16, 2018. It is now read-only.

Exception: VARSTART is not 7 #8

Merged
merged 3 commits into from Sep 28, 2014
Merged

Exception: VARSTART is not 7 #8

merged 3 commits into from Sep 28, 2014

Conversation

astrofrog
Copy link
Owner

I did encountered again same problem as another issue. I'm trying to read a structure.

In [4]: import idlsave

In [5]: idlsave.__version__
Out[5]: '1.0.0'

In [6]: s  = idlsave.read('CMR31303.cxf')
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-6-01f74964d9e5> in <module>()
----> 1 s  = idlsave.read('CMR31303.cxf')

/afs/ipp/home/m/mcavedon/.local/lib/python2.7/site-packages/idlsave/idlsave.pyc in read(file_name, idict, python_dict, uncompressed_file_name, verbose)
    802     # Loop through records, and add them to the list
    803     while True:
--> 804         r = _read_record(f)
    805         records.append(r)
    806         if 'end' in r:

/afs/ipp/home/m/mcavedon/.local/lib/python2.7/site-packages/idlsave/idlsave.pyc in _read_record(f)
    355         varstart = _read_long(f)
    356         if varstart != 7:
--> 357             raise Exception("VARSTART is not 7")
    358
    359         if rectypedesc['structure']:

Exception: VARSTART is not 7

Thanks

@astrofrog
Copy link
Owner

@mcave - thanks for the report, could you send the file to thomas.robitaille@gmail.com?

@cave-git-p
Copy link
Author

Thanks for the prompt answer. I had to create a link because the file is too big:

https://www.dropbox.com/s/ulbmkofdvq1jcxq/test.sav?dl=0

@astrofrog
Copy link
Owner

@mcave - I had a first look at this but could not find any easy solution. In order to help with the debugging, could you let me know what kind of variable is in the file? Could you reduce it to the simplest example that produces a failure?

@cave-git-p
Copy link
Author

I think the problem are the pointers:

IDL> restore,'pointer.sav'
IDL> help,point
POINT           POINTER   = <PtrHeapVar1>




In [1]: import idlsave
In [2]: s  = idlsave.read('pointer.sav')
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-11-929a835ddc16> in <module>()
----> 1 s  = idlsave.read('pointer.sav')

/afs/ipp/home/m/mcavedon/.local/lib/python2.7/site-packages/idlsave/idlsave.pyc in read(file_name, idict, python_dict, uncompressed_file_name, verbose)
    802     # Loop through records, and add them to the list
    803     while True:
--> 804         r = _read_record(f)
    805         records.append(r)
    806         if 'end' in r:

/afs/ipp/home/m/mcavedon/.local/lib/python2.7/site-packages/idlsave/idlsave.pyc in _read_record(f)
    355         varstart = _read_long(f)
    356         if varstart != 7:
--> 357             raise Exception("VARSTART is not 7")
    358
    359         if rectypedesc['structure']:

Exception: VARSTART is not 7

I send you by email the file.

Marco

@astrofrog
Copy link
Owner

@mcave - thanks for sending this over! Just to help me debug, how do you view the content the pointer is pointing to in IDL? I tried:

IDL> print,point   
<PtrHeapVar2>
IDL> print,*point  
% PRINT: Variable is undefined: <PtrHeapVar2>.
% Execution halted at: $MAIN$     
``

@cave-git-p
Copy link
Author

This is just null pointer (http://www.exelisvis.com/docs/IDL_Pointers.html). It's dirty, I know, but it is how IDL works. Would it be possibly to assign simply an empty numpy array for this cases? Thank you

@astrofrog
Copy link
Owner

Ah, I see! I'll try and understand how IDL is encoding that information to see how to deal with it. Maybe simply using the Python None would be more appropriate.

@cave-git-p
Copy link
Author

You are right, it sounds better. Thank you again

@astrofrog
Copy link
Owner

@mcave - I think I figured it out, but just to test, can you send me a new file that includes this variable, followed by a variable named 'check' that is set to the value of 5? (integer)

@cave-git-p
Copy link
Author

Sent!

@astrofrog
Copy link
Owner

@mcave - thanks for the file, and sorry for the delay! The code attached to this issue now fixes this. I'll wait to see if the tests pass. I'll also fix the same issue in scipy.io.idl (which is the same as idlsave).

astrofrog added a commit that referenced this pull request Sep 28, 2014
Exception: VARSTART is not 7
@astrofrog astrofrog merged commit 77f8daf into master Sep 28, 2014
@astrofrog
Copy link
Owner

@mcave - this should now be fixed. Try updating to the latest developer version of idlsave - could you let me know if your files work fine now?

@cave-git-p
Copy link
Author

It does work! Thank you fow your help

@astrofrog
Copy link
Owner

@mcave - and thanks for your patience!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants