Read .genx IDL save files with Python

160 views
Skip to first unread message

Will Barnes

unread,
Jun 13, 2016, 2:50:15 AM6/13/16
to SunPy
This is perhaps only tangentially related to SunPy, but has anyone come up with a way to read the SSW .genx IDL save files with Python (e.g. into a dictionary)? For example, $SSW/sdo/aia/response/aia_V6_all_fullinst.genx holds information about the AIA wavelength response functions. 

These appear to not be "normal" IDL .save files and are written and read by $SSW/gen/idl/io/{savegen,restgen}.pro, respectively. I know that scipy.io has a readsav function for reading IDL save files, but unfortunately this does not appear to work for these file types (raises an 'Invalid Signature' exception).

Creating a new normal IDL save file for each .genx file and then using the aforementioned scipy routine seems to work ok, but is a bit hacky. Just wondering if anyone had come up with a better solution.

DVD PS

unread,
Jun 13, 2016, 6:16:57 AM6/13/16
to sunpy
On 13 June 2016 at 07:50, Will Barnes <will.t...@gmail.com> wrote:
This is perhaps only tangentially related to SunPy, but has anyone come up with a way to read the SSW .genx IDL save files with Python (e.g. into a dictionary)? For example, $SSW/sdo/aia/response/aia_V6_all_fullinst.genx holds information about the AIA wavelength response functions. 

 
These appear to not be "normal" IDL .save files and are written and read by $SSW/gen/idl/io/{savegen,restgen}.pro, respectively. I know that scipy.io has a readsav function for reading IDL save files, but unfortunately this does not appear to work for these file types (raises an 'Invalid Signature' exception).

Will, I think I had... and in fact I did... but it seems there are two things:
 - savegenx and restgenx -> which are simpy save files from idl (and suppose to read/write geny files)
 - savegen and restgen -> which is the one you pointed to, and it uses a normal openw to write the file with maybe a /xdr keyword.

It seems python can understand these[1] but probably breaking up the wrt_genx.pro and understand what's writing will help. I don't think it should take too long to come up with a python reader (Sadly I've got not much time at the moment).

[1] https://docs.python.org/3/library/xdrlib.html
[2] https://darts.isas.jaxa.jp/pub/ssw/gen/idl/io/wrt_genx.pro
 
Creating a new normal IDL save file for each .genx file and then using the aforementioned scipy routine seems to work ok, but is a bit hacky. Just wondering if anyone had come up with a better solution.

That's a solution for one off, but not to keep it sustainable  :)

sorry for not being of much more help,
David



Will Barnes

unread,
Jun 13, 2016, 11:33:47 AM6/13/16
to SunPy
Hi David,

Thanks for the tips! The xdrlib module seems promising if in fact these were written with the /xdr keyword. Perhaps this is why scipy.io.readsav cannot handle these files...

True this hack is not a sustainable solution, though in the end we would ideally not rely on these .genx files at all for computing the response functions of the different telescopes (assuming there is another way to get at the data!). 

Will
Reply all
Reply to author
Forward
0 new messages