Changeset 1515 for branches/alma


Ignore:
Timestamp:
02/23/09 21:39:09 (16 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (CAS-1079)

Ready to Release: Yes

Interface Changes: Yes

What Interface Changed:
You can select stat='minpos' or 'maxpos' in scantable.stats() to
get minimum or maximum value with its channel/frequency/velocity.
Also a new method pos2data(self, rowno=0, pos=0) is added.

Test Programs:

Run scantable.stats() with stat='minpos' or 'maxpos'.

Put in Release Notes: No

Module(s): Module Names change impacts.

Description:

You can get min/max values with their position (channels/frequencies/velocities)
by selecting stat='minpos' or 'maxpos'.

The new method pos2data() returns abcissa and ordinate values of a spectrum
at an arbitrary row (rowno) and channel (pos) in the scantable.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/alma/python/scantable.py

    r1496 r1515  
    341341        Takes a 'mask' as an optional parameter to specify which
    342342        channels should be excluded.
    343         Parameters:
    344             stat:    'min', 'max', 'sumsq', 'sum', 'mean'
    345                      'var', 'stddev', 'avdev', 'rms', 'median'
     343        You can get min/max values with their position
     344        (channels/frequencies/velocities) by selecting stat='minpos'
     345        or 'maxpos'.
     346        Parameters:
     347            stat:    'min', 'max', 'minpos', 'maxpos', 'sumsq', 'sum',
     348                     'mean', 'var', 'stddev', 'avdev', 'rms', 'median'
    346349            mask:    an optional mask specifying where the statistic
    347350                     should be determined.
     
    359362                             "to select individual IFs")
    360363
    361         statvals = self._math._stats(self, mask, stat)
     364        if stat.lower().find('pos') == -1:
     365            statvals = self._math._stats(self, mask, stat)
     366            position = False
     367            sstat = str(stat)
     368        else:
     369            pos = self._math._minmaxpos(self, mask, stat)
     370            position = True
     371            statvals = []
     372            sstat = stat.lower().strip('pos')
    362373        out = ''
    363374        axes = []
     
    372383            tm = self._gettime(i)
    373384            src = self._getsourcename(i)
     385            xpos = ''
     386            if position:
     387                qx, y = self.pos2data(rowno=i, pos=pos[i])
     388                statvals.append(y)
     389                xpos = '(x = %3.3f' % (qx['value'])+' ['+qx['unit']+'])'
    374390            out += 'Scan[%d] (%s) ' % (axis[0], src)
    375391            out += 'Time[%s]:\n' % (tm)
     
    377393            if self.nif(-1) > 1: out +=  ' IF[%d] ' % (axis[2])
    378394            if self.npol(-1) > 1: out +=  ' Pol[%d] ' % (axis[3])
    379             out += '= %3.3f\n' % (statvals[i])
     395            out += '= %3.3f   ' % (statvals[i]) +xpos+'\n'
    380396            out +=  "--------------------------------------------------\n"
    381397
    382398        if rcParams['verbose']:
    383399            print "--------------------------------------------------"
    384             print " ", stat
     400            print " ", sstat
    385401            print "--------------------------------------------------"
    386402            print out
     
    390406            #           'data': statvals}
    391407        return statvals
     408
     409    def pos2data(self, rowno=0, pos=0):
     410        """
     411        Returns the abcissa and ordinate value of a spectrum
     412        at an arbitrary row and channel in the scantable.
     413        Parameters:
     414            rowno:   a row number in the scantable. Default is the
     415                     first row, i.e. rowno=0
     416            pos:     a channel in the scantable. Default is the first
     417                     channel, i.e. pos=0
     418        """
     419        if isinstance(rowno, int) and isinstance(pos, int):
     420            x, xlbl = self.get_abcissa(rowno)
     421            qx = {'unit': xlbl, 'value': x[pos]}
     422            return qx, self._getspectrum(rowno)[pos]
    392423
    393424    def stddev(self, mask=None):
Note: See TracChangeset for help on using the changeset viewer.