How to open a sav file in Python
In [ ]:
#Sometimes I have to deal with codes written by others in others programming languages (like IDL!), it is not hard to learn but definitely not cool as python ;)
#I always like to re-write those codes in python, simply because I am used to it. And for that, I need to check if both codes return the same output, which sometimes rises the need to convert images from sav format (output of IDL) to fits.
#In python, this is possible using the module IDLSave, below is the documentary link:
#http://astrofrog.github.io/idlsave/
#I wrote a function that simply takes the sav file and convert it to fits:
import idlsave
import pyfits
def SAV2FITS(image,output):
im = idlsave.read(image)
data = im.values()[0]
hdu = pyfits.PrimaryHDU(data)
hdu.writeto(output)