Changeset 143
- Timestamp:
- 12/24/04 23:36:34 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapmath.py
r141 r143 1 1 from scantable import scantable 2 2 3 def average_time(*args, **kwargs):3 def average_time(*args, **kwargs): 4 4 """ 5 5 Return the (time) average of a scan or list of scans. [in channels only] 6 6 Parameters: 7 7 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' 9 13 Example: 10 14 # return a time averaged scan from scana and scanb … … 14 18 # all correlator cycles 15 19 scanav = average_time(scan) 16 20 17 21 """ 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 37 36 for s in lst: 38 37 if not isinstance(s,scantable): 39 38 print "Please give a list of scantables" 40 39 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)) 51 41 52 42 def quotient(source, reference):
Note:
See TracChangeset
for help on using the changeset viewer.