Changeset 1590


Ignore:
Timestamp:
07/02/09 13:56:26 (15 years ago)
Author:
Malte Marquarding
Message:

Tidy up/factored out printin part of stats to _row_callback

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/scantable.py

    r1589 r1590  
    358358        if mask == None:
    359359            mask = []
    360         axes = ['Beam', 'IF', 'Pol', 'Time']
    361360        if not self._check_ifs():
    362361            raise ValueError("Cannot apply mask as the IFs have different "
     
    365364
    366365        statvals = self._math._stats(self, mask, stat)
    367         out = ''
    368         axes = []
    369         for i in range(self.nrow()):
    370             axis = []
    371             axis.append(self.getscan(i))
    372             axis.append(self.getbeam(i))
    373             axis.append(self.getif(i))
    374             axis.append(self.getpol(i))
    375             axis.append(self.getcycle(i))
    376             axes.append(axis)
    377             tm = self._gettime(i)
    378             src = self._getsourcename(i)
    379             out += 'Scan[%d] (%s) ' % (axis[0], src)
    380             out += 'Time[%s]:\n' % (tm)
    381             if self.nbeam(-1) > 1: out +=  ' Beam[%d] ' % (axis[1])
    382             if self.nif(-1) > 1: out +=  ' IF[%d] ' % (axis[2])
    383             if self.npol(-1) > 1: out +=  ' Pol[%d] ' % (axis[3])
    384             out += '= %3.3f\n' % (statvals[i])
    385             out +=  "--------------------------------------------------\n"
    386 
    387         if rcParams['verbose']:
    388             print "--------------------------------------------------"
    389             print " ", stat
    390             print "--------------------------------------------------"
    391             print out
    392         #else:
    393             #retval = { 'axesnames': ['scanno', 'beamno', 'ifno', 'polno', 'cycleno'],
    394             #           'axes' : axes,
    395             #           'data': statvals}
    396         return statvals
     366        def cb(i):
     367            return statvals[i]
     368
     369        return self._row_callback(cb, stat)
    397370
    398371    def stddev(self, mask=None):
     
    429402
    430403    def _row_callback(self, callback, label):
    431         axes = []
    432         axesnames = ['scanno', 'beamno', 'ifno', 'polno', 'cycleno']
    433404        out = ""
    434405        outvec = []
     406        sep = '-'*50
    435407        for i in range(self.nrow()):
    436             axis = []
    437             axis.append(self.getscan(i))
    438             axis.append(self.getbeam(i))
    439             axis.append(self.getif(i))
    440             axis.append(self.getpol(i))
    441             axis.append(self.getcycle(i))
    442             axes.append(axis)
    443408            tm = self._gettime(i)
    444409            src = self._getsourcename(i)
    445             out += 'Scan[%d] (%s) ' % (axis[0], src)
     410            out += 'Scan[%d] (%s) ' % (self.getscan(i), src)
    446411            out += 'Time[%s]:\n' % (tm)
    447             if self.nbeam(-1) > 1: out +=  ' Beam[%d] ' % (axis[1])
    448             if self.nif(-1) > 1: out +=  ' IF[%d] ' % (axis[2])
    449             if self.npol(-1) > 1: out +=  ' Pol[%d] ' % (axis[3])
     412            if self.nbeam(-1) > 1:
     413                out +=  ' Beam[%d] ' % (self.getbeam(i))
     414            if self.nif(-1) > 1: out +=  ' IF[%d] ' % (self.getif(i))
     415            if self.npol(-1) > 1: out +=  ' Pol[%d] ' % (self.getpol(i))
    450416            outvec.append(callback(i))
    451417            out += '= %3.3f\n' % (outvec[i])
    452             out +=  "--------------------------------------------------\n"
     418            out +=  sep+'\n'
    453419        if rcParams['verbose']:
    454             print "--------------------------------------------------"
     420            print sep
    455421            print " %s" % (label)
    456             print "--------------------------------------------------"
     422            print sep
    457423            print out
    458         # disabled because the vector seems more useful
    459         #retval = {'axesnames': axesnames, 'axes': axes, 'data': outvec}
    460424        return outvec
    461425
Note: See TracChangeset for help on using the changeset viewer.