示例#1
0
def parse_ants(ant_str, nants):
    """Generate list of (baseline, include, pol) tuples based on parsing of the
    string associated with the 'ants' command-line option."""
    rv, cnt = [], 0
    while cnt < len(ant_str):
        m = re.search(bl_re, ant_str[cnt:])
        if m is None:
            if ant_str[cnt:].startswith('all'): rv = []
            elif ant_str[cnt:].startswith('auto'): rv.append(('auto', 1, -1))
            elif ant_str[cnt:].startswith('cross'): rv.append(('auto', 0, -1))
            else: raise ValueError('Unparsible ant argument "%s"' % ant_str)
            c = ant_str[cnt:].find(',')
            if c >= 0: cnt += c + 1
            else: cnt = len(ant_str)
        else:
            m = m.groups()
            cnt += len(m[0])
            if m[2] is None:
                ais = [m[8]]
                ajs = range(nants)
            else:
                if m[3] is None: ais = [m[2]]
                else: ais = m[3].split(',')
                if m[6] is None: ajs = [m[5]]
                else: ajs = m[6].split(',')
            include = None
            for i in ais:
                for j in ajs:
                    if type(i) == str and i.startswith('-'):
                        i = i[1:]  #nibble the - off the string
                        include = 0
                    if type(j) == str and j.startswith('-'):
                        j = j[1:]
                        include = 0
                    elif include == 0:
                        pass
                    else:
                        include = 1
                    pol = None
                    i, j = str(i), str(j)
                    if not i.isdigit():
                        ai = re.search(r'(\d+)([x,y])', i).groups()
                    if not j.isdigit():
                        aj = re.search(r'(\d+)([x,y])', j).groups()
                    if i.isdigit() and not j.isdigit():
                        pol = ['x' + aj[1], 'y' + aj[1]]
                        ai = [i, '']
                    elif not i.isdigit() and j.isdigit():
                        pol = [ai[1] + 'x', ai[1] + 'y']
                        aj = [j, '']
                    elif not i.isdigit() and not j.isdigit():
                        pol = [ai[1] + aj[1]]
                    if not pol is None:
                        bl = miriad.ij2bl(abs(int(ai[0])), abs(int(aj[0])))
                        for p in pol:
                            rv.append((bl, include, p))
                    else:
                        bl = miriad.ij2bl(abs(int(i)), abs(int(j)))
                        rv.append((bl, include, -1))
    return rv
示例#2
0
def parse_ants(ant_str, nants):
    """Generate list of (baseline, include, pol) tuples based on parsing of the
    string associated with the 'ants' command-line option."""
    rv,cnt = [], 0
    while cnt < len(ant_str):
        m = re.search(bl_re, ant_str[cnt:])
        if m is None:
            if ant_str[cnt:].startswith('all'): rv = []
            elif ant_str[cnt:].startswith('auto'): rv.append(('auto',1,-1))
            elif ant_str[cnt:].startswith('cross'): rv.append(('auto',0,-1))
            else: raise ValueError('Unparsible ant argument "%s"' % ant_str)
            c = ant_str[cnt:].find(',')
            if c >= 0: cnt += c + 1
            else: cnt = len(ant_str)
        else:
            m = m.groups()
            cnt += len(m[0])
            if m[2] is None:
                ais = [m[8]]
                ajs = range(nants)
            else:
                if m[3] is None: ais = [m[2]]
                else: ais = m[3].split(',')
                if m[6] is None: ajs = [m[5]]
                else: ajs = m[6].split(',')
            include = None
            for i in ais:
                for j in ajs:
                    if type(i) == str and i.startswith('-'):
                         i = i[1:] #nibble the - off the string
                         include = 0 
                    if type(j) == str and j.startswith('-'):
                        j = j[1:]
                        include = 0
                    elif include==0:pass
                    else: include = 1
                    pol = None
                    i,j = str(i),str(j)
                    if not i.isdigit():
                        ai = re.search(r'(\d+)([x,y])',i).groups()
                    if not j.isdigit():
                        aj = re.search(r'(\d+)([x,y])',j).groups()
                    if i.isdigit() and not j.isdigit():
                        pol = ['x'+aj[1],'y'+aj[1]]
                        ai = [i,'']
                    elif not i.isdigit() and j.isdigit():
                        pol = [ai[1]+'x',ai[1]+'y']
                        aj = [j,'']
                    elif not i.isdigit() and not j.isdigit():
                        pol = [ai[1]+aj[1]]
                    if not pol is None:
                        bl = miriad.ij2bl(abs(int(ai[0])),abs(int(aj[0])))
                        for p in pol:
                            rv.append((bl,include,p))
                    else: 
                        bl = miriad.ij2bl(abs(int(i)),abs(int(j)))
                        rv.append((bl,include,-1))
    return rv
示例#3
0
def parse_ants(ant_str, nants):
    """Generate list of (baseline, inlude) tuples based on parsing of the
    string associated with the 'ants' command-line option."""
    rv, cnt = [], 0
    while cnt < len(ant_str):
        m = re.search(bl_re, ant_str[cnt:])
        if m is None:
            if ant_str[cnt:].startswith('all'): rv = []
            elif ant_str[cnt:].startswith('auto'): rv.append(('auto', 1))
            elif ant_str[cnt:].startswith('cross'): rv.append(('auto', 0))
            else: raise ValueError('Unparsible ant argument "%s"' % ant_str)
            c = ant_str[cnt:].find(',')
            if c >= 0: cnt += c + 1
            else: cnt = len(ant_str)
        else:
            m = m.groups()
            cnt += len(m[0])
            if m[2] is None:
                ais = [m[8]]
                ajs = range(nants)
            else:
                if m[3] is None: ais = [m[2]]
                else: ais = m[3].split(',')
                if m[6] is None: ajs = [m[5]]
                else: ajs = m[6].split(',')
            for i in ais:
                for j in ajs:
                    if type(i) == str and i.startswith('-') or \
                            type(j) == str and j.startswith('-'):
                        include = 0
                    else:
                        include = 1
                    if not i.isdigit():
                        ai = re.search(r'(\d+)([x,y])', i).groups()
                        aj = re.search(r'(\d+)([x,y])', j).groups()
                        pol = ai[1] + aj[1]
                    else:
                        pol = 'yy'
                    bl = miriad.ij2bl(abs(int(ai[0])), abs(int(aj[0])))
                    rv.append((bl, include, pol))
    return rv
示例#4
0
def parse_ants(ant_str, nants):
    """Generate list of (baseline, inlude) tuples based on parsing of the
    string associated with the 'ants' command-line option."""
    rv,cnt = [], 0
    while cnt < len(ant_str):
        m = re.search(bl_re, ant_str[cnt:])
        if m is None:
            if ant_str[cnt:].startswith('all'): rv = []
            elif ant_str[cnt:].startswith('auto'): rv.append(('auto',1))
            elif ant_str[cnt:].startswith('cross'): rv.append(('auto',0))
            else: raise ValueError('Unparsible ant argument "%s"' % ant_str)
            c = ant_str[cnt:].find(',')
            if c >= 0: cnt += c + 1
            else: cnt = len(ant_str)
        else:
            m = m.groups()
            cnt += len(m[0])
            if m[2] is None:
                ais = [m[8]]
                ajs = range(nants)
            else:
                if m[3] is None: ais = [m[2]]
                else: ais = m[3].split(',')
                if m[6] is None: ajs = [m[5]]
                else: ajs = m[6].split(',')
            for i in ais:
                for j in ajs:
                    if type(i) == str and i.startswith('-') or \
                            type(j) == str and j.startswith('-'):
                        include = 0
                    else: include = 1
                    if not i.isdigit():
                        ai = re.search(r'(\d+)([x,y])',i).groups()
                        aj = re.search(r'(\d+)([x,y])',j).groups()
                        pol = ai[1]+aj[1]
                    else: pol='yy'
                    bl = miriad.ij2bl(abs(int(ai[0])),abs(int(aj[0])))
                    rv.append((bl,include,pol))
    return rv
示例#5
0
文件: phs.py 项目: DavidFMoore/aipy
 def ij2bl(self, i, j):
     """Convert baseline i,j (0 indexed) to Miriad's (i+1) << 8 | (j+1) 
     indexing scheme."""
     return ij2bl(i,j)
示例#6
0
文件: phs.py 项目: zuoshifan/aipy
 def ij2bl(self, i, j):
     """Convert baseline i,j (0 indexed) to Miriad's (i+1) << 8 | (j+1) 
     indexing scheme."""
     return ij2bl(i, j)