'write attributes of this instance to python module given by filename
Parameters
what : list or None
list of attributes that are added to the module. If None (default)
then all attributes in __dict__ that do not start with an underline
will be saved.
filename : string
specifies filename with path. If the file does not exist, it will be
created. If the file is already exists, then the new data will be
appended to the file.
header : bool
If true, then the imports of the module and the class definition are
written before writing the data.
useinstance : bool
If true, then the data in the module are attached to an instance of a
holder class. If false, then each array will be saved as separate
variable.
comment : string
If comment is not empty then this string will be attached as a
description comment to the data instance in the saved module.
print_options : dict or None
The print_options for the numpy arrays will be updated with this.
see notes
Notes
The content of an numpy array are written using repr, which can be
controlled with the np.set_printoptions. The numpy default is updated
with:  precision=20, linewidth=100, nanstr=\'nan\', infstr=\'inf\'
This should provide enough precision for double floating point numbers.
If one array has more than 1000 elements, then threshold should be
overwritten by the user, see keyword argument print_options.'

def save(self, what=None, filename=None, header=True, useinstance=True, comment=None, print_options=None):

    print_opt_old = np.get_printoptions()
    print_opt = dict(precision=20, linewidth=100, nanstr='nan', infstr='inf')
    if print_options:
        print_opt.update(print_options)
    np.set_printoptions(**print_opt)
    if (what is None):
        what = (i for i in self.__dict__ if (i[0] != '_'))
    if header:
        txt = ['import    numpy    as    np\nfrom    numpy    import    array,    rec,    inf,    nan\n\n']
        if useinstance:
            txt.append('class    Holder(object):\n                pass\n\n')
    else:
        txt = []
    if useinstance:
        txt.append(('%s    =    Holder()' % self.name))
        prefix = ('%s.' % self.name)
    else:
        prefix = ''
    if (not (comment is None)):
        txt.append(("%scomment    =    '%s'" % (prefix, comment)))
    for x in what:
        txt.append(('%s%s    =    %s' % (prefix, x, repr(getattr(self, x)))))
    txt.extend(['', ''])
    if (not (filename is None)):
        file(filename, 'a+').write('\n'.join(txt))
    np.set_printoptions(**print_opt_old)
    self._filename = filename
    self._useinstance = useinstance
    self._what = what
    return txt
