source: trunk/python/asapmath.py @ 101

Last change on this file since 101 was 101, checked in by mar637, 20 years ago

the asap python math functions

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1from scantable import scantable
2def average_scan(scan):
3    """
4        Return a (time) averaged a scan, i.e. all correlator cycles
5        are averaged into one "scan".
6    """
7    from asap._asap import average as _av
8    return scantable(_av(scan))
9
10
11def average_scans(*args, **kwargs):
12    """
13        Return the (time) average of a list of scans. [in channels only]
14        Parameters:
15            a comma separated list of scans
16            mask:     an optional mask
17        Example:
18            scanav = average_scans(scana,scanb)
19            # return a time averaged scan from scan and scanb
20            # without using a mask
21    """
22
23    if len(args) < 2:
24        print "Please give at least two scantables"
25        return
26
27    from asap._asap import averages as _av
28    d = [args[0].nbeam(),args[0].nif(),args[0].npol(),args[0].nchan()]
29    for s in args:
30        if not isinstance(s,scantable):
31            print "Please give a list of scantables"
32            return
33        dim = [s.nbeam(),s.nif(),s.npol(),s.nchan()]
34        if (dim != d):
35            print "All scans have to have the same numer of Beams/IFs/Pols/Chans"
36            return
37    if kwargs.has_key('mask'):
38        return scantable(_av(args, kwargs.get('mask')))
39    else:
40        from numarray import ones
41        mask = list(ones(d[3]))
42        return scantable(_av((args), mask))
43
44def quotient(source, reference):
45    """
46    Return the quotient of a 'source' scan and a 'reference' scan
47    Parameters:
48        source:        the 'on' scan
49        reference:     the 'off' scan
50    """
51    from asap._asap import quotient as _quot
52    return scantable(_quot(source, reference))
53
54def scale(scan, factor):
55    """
56    Return a scan where all spectra are scaled by the give 'factor'
57    Parameters:
58        scan:        a scantable
59        factor:      the sclaing factor
60    Note:
61        This currently applies the all beams/IFs/pols
62    """
63    from asap._asap import scale as _scale
64    return scantable(_scale(scan, factor))
65
66
67def bin(scan, binwidth=5):
68    """
69    """
70    from asap._asap import bin as _bin
71    return scantable(_bin(scan, binwidth))
Note: See TracBrowser for help on using the repository browser.