Changeset 143 for trunk/python


Ignore:
Timestamp:
12/24/04 23:36:34 (20 years ago)
Author:
kil064
Message:

rework binding to 'average_time'. Now invokes just one
C++ function. Add new arguments 'scanav' and 'weight'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/asapmath.py

    r141 r143  
    11from scantable import scantable
    22
    3 def average_time(*args,**kwargs):
     3def average_time(*args, **kwargs):
    44    """
    55    Return the (time) average of a scan or list of scans. [in channels only]
    66    Parameters:
    77        one scan or comma separated  scans
    8         mask:     an optional mask
     8        mask:     an optional mask (only used for 'var' and 'tsys' weighting)
     9        scanav:   False (default) averages all scans together,
     10                  True averages each scan separately
     11        weight:   Weighting scheme. 'none' (default), 'var' (variance
     12                  weighted), 'tsys'
    913    Example:
    1014        # return a time averaged scan from scana and scanb
     
    1418        # all correlator cycles
    1519        scanav = average_time(scan)
    16        
     20
    1721    """
    18     lst = args
    19     if len(args) < 2:
    20         if type(args[0]) is list:
    21             if  len(args[0]) < 2:
    22                 print "Please give at least two scantables"
    23                 return
    24         else:
    25             s = args[0]
    26             if s.nrow() > 1:
    27                 from asap._asap import average as _av
    28                 return scantable(_av(s))
    29             else:
    30                 print "Given scantable is already time averaged"
    31                 return
    32         lst = tuple(args[0])
    33     else:
    34         lst = tuple(args)
    35     from asap._asap import averages as _avs
    36     d = [lst[0].nbeam(),lst[0].nif(),lst[0].npol(),lst[0].nchan()]
     22    scanAv = False
     23    if kwargs.has_key('scanav'):
     24       scanAv = kwargs.get('scanav')
     25#
     26    weight = 'none'
     27    if kwargs.has_key('weight'):
     28       weight = kwargs.get('weight')
     29#
     30    mask = ()
     31    if kwargs.has_key('mask'):
     32        mask = kwargs.get('mask')
     33#
     34    lst = tuple(args)
     35    from asap._asap import average as _av
    3736    for s in lst:
    3837        if not isinstance(s,scantable):
    3938            print "Please give a list of scantables"
    4039            return
    41         dim = [s.nbeam(),s.nif(),s.npol(),s.nchan()]
    42         if (dim != d):
    43             print "All scans have to have the same numer of Beams/IFs/Pols/Chans"
    44             return
    45     if kwargs.has_key('mask'):
    46         return scantable(_avs(lst, kwargs.get('mask')))
    47     else:
    48         from numarray import ones
    49         mask = tuple(ones(d[3]))
    50         return scantable(_avs(lst, mask))
     40    return scantable(_av(lst, mask, scanAv, weight))
    5141
    5242def quotient(source, reference):
Note: See TracChangeset for help on using the changeset viewer.