Friday, October 17, 2008

SAVE / RESTORE in Python

Save/Restore is probably the single best feature of IDL that, sadly, is very poorly replicated in Python. For 1 or 2 dimensional variables, you can use Pylab's save/load, but I never use such piddling tiny arrays. For higher dimensional objects, either using FITS files (a pain because of header definitions) or pickling ought to work.


import numpy
import pickle
X = pickle.load(open('x.pysav','r'))

No comments: