Changeset 1237 for tags


Ignore:
Timestamp:
09/05/06 09:31:15 (18 years ago)
Author:
mar637
Message:

re-enabled history in constructor. history can be written to a file now (auto-overwrite)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tags/Release2.1.0b/python/scantable.py

    r1236 r1237  
    3333        if average is None:
    3434            average = rcParams['scantable.autoaverage']
    35         #varlist = vars()
     35        varlist = vars()
    3636        from asap._asap import stmath
    3737        self._math = stmath()
     
    7272                  and isinstance(filename[-1], str):
    7373                self._fill(filename, unit, average)
     74        self._add_history("scantable", varlist)
    7475        print_log()
    7576
     
    831832
    832833
    833     def history(self):
     834    def history(self, filename=None):
     835        """
     836        Print the history. Optionally to a file.
     837        """
    834838        hist = list(self._gethistory())
    835839        out = "-"*80
     
    848852                    out += "\n   %s = %s" % (s[0], s[1])
    849853                out += "\n"+"-"*80
    850         try:
    851             from IPython.genutils import page as pager
    852         except ImportError:
    853             from pydoc import pager
    854         pager(out)
     854        if filename is not None:
     855            if filename is "":
     856                filename = 'scantable_history.txt'
     857            import os
     858            filename = os.path.expandvars(os.path.expanduser(filename))
     859            if not os.path.isdir(filename):
     860                data = open(filename, 'w')
     861                data.write(out)
     862                data.close()
     863            else:
     864                msg = "Illegal file name '%s'." % (filename)
     865                if rcParams['verbose']:
     866                    print msg
     867                else:
     868                    raise IOError(msg)
     869        if rcParams['verbose']:
     870            try:
     871                from IPython.genutils import page as pager
     872            except ImportError:
     873                from pydoc import pager
     874            pager(out)
     875        else:
     876            return out
    855877        return
    856 
    857878    #
    858879    # Maths business
     
    16671688            self.set_fluxunit(unit)
    16681689        self.set_freqframe(rcParams['scantable.freqframe'])
    1669         #self._add_history("scantable", varlist)
    1670 
     1690
Note: See TracChangeset for help on using the changeset viewer.