Closed abrahamneben closed 9 years ago
This is quite an annoying error. I never know which IDL sav file is going to work...
Did you close the ticket by mistake?
Yes, closed by mistake. Now reopened.
@astrofrog any chance you can look at this?
@rgommers - yes, I will take a look at this in a couple of days. In the mean time, @abrahamneben - can you tell me what kind of data this file should contain?
@abrahamneben - I managed to read in all the data except the 'CONVERGENCE' column. Is there anything special about these variables on the IDL side?
Really? I get the below error: I'm in python 2.7.3, scipy 0.15.1, numpy 1.10.0, CentOS release 6.3. Not sure if there is something special about the IDL datafile. At the bottom I'll put the IDL help message about the "cal" structure that gets restored from this file.
abrahamn@eor-09:~$ python impoPython 2.7.3 (default, Jan 13 2013, 09:19:58) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. rt>>> import scipy sci>>> scipy.version '0.15.1'
a=scipy.io.readsav('1066671952_cal.sav') Traceback (most recent call last): File "
", line 1, in AttributeError: 'module' object has no attribute 'io' import scipy.io a=scipy.io.readsav('1066671952_cal.sav') Traceback (most recent call last): File " ", line 1, in File "/nfs/eor-00/h1/abrahamn/lib/python2.7/site-packages/scipy/io/idl.py", line 821, in readsav replace, new = _replace_heap(r['data'], heap) File "/nfs/eor-00/h1/abrahamn/lib/python2.7/site-packages/scipy/io/idl.py", line 609, in _replace_heap replace, new = _replace_heap(record, heap) File "/nfs/eor-00/h1/abrahamn/lib/python2.7/site-packages/scipy/io/idl.py", line 621, in _replace_heap replace, new = _replace_heap(value, heap) File "/nfs/eor-00/h1/abrahamn/lib/python2.7/site-packages/scipy/io/idl.py", line 635, in _replace_heap replace, new = _replace_heap(variable.item(iv), heap) File "/nfs/eor-00/h1/abrahamn/lib/python2.7/site-packages/scipy/io/idl.py", line 595, in _replace_heap variable = heap[variable.index] KeyError: 543708
IDL> help,cal
\ Structure
@abrahamneben - thanks for the info! Just to clarify, I can only read it in (except for that column) locally after hacking around, but I still have the same issue as you with the stable SciPy.
@abrahamneben - could you show me the contents of the CONVERGENCE
component?
"convergence" seems to be a length 2 pointer array, but both elements are null pointers. That seems likely to be the problem.
IDL> print,cal.convergence < NullPointer > < NullPointer >
An if statement that lets readsav fail just on null variables would be a nice solution here.
@abrahamneben - ok, thanks! My plan at the moment is to add a condition that if a pointer is not pointing to a valid heap variable, then we just return None
for those specific values. Does that sounds reasonable? (edit: seems like you are thinking along the same lines!)
@astrofrog nice!
I will do a PR tomorrow - thanks for the report!
@abrahamneben - would it be easy for you to produce a SAV file that contains JUST the CONVERGENCE
variable? If so, I could include that in a regression test in #4710.
@astrofrog Here's an IDL sav file that contains that array of two null pointers stored as the variable "a". https://dl.dropboxusercontent.com/u/22819/idl_array_of_null_pointers.sav
@abrahamneben - just for info, this is now fixed in the developer version of SciPy. Thanks for reporting this and for providing a test file!
not fixed --> now fixed :)
@rgommers - thanks, clearly need more :coffee: :smile:
Hi do we need to explicitly close the file after the readsav operation? And how?
Thanks,
No, it's closed within the function.
scipy.io.readsav doesn't work many sav files, such as this one https://dl.dropboxusercontent.com/u/22819/1066671952_cal.sav
Python 2.7.3 (default, Jan 13 2013, 09:19:58) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.